Open dealmengor opened 5 months ago
Thanks for your report :raised_hands:
There are at the moment some ongoing refactoring in Starlight to improve/refactor some Internationalization support which also targets plugins and improve i18n support in plugins (which was not really possible before). When this is done, this plugin will be updated and refactored to work with such features as I did not want to "hack" around the current implementation as a temporary solution that would be broken in the near future.
Until then, I think something similar to your workaround could work. Let's say for example the 2 schemas had different labels, e.g. "PAD (en)" and "PAD (es)", you could use a component override for the <Sidebar>
component and filter out the group you want to remove based on the current language.
This could look something like this:
---
// src/overrides/Sidebar.astro
import type { Props } from '@astrojs/starlight/props';
import Default from '@astrojs/starlight/components/Sidebar.astro';
const isEnglishPage = Astro.url.pathname.startsWith('/en/');
Astro.props.sidebar = Astro.props.sidebar
.filter((entry) => (
// Filter out the group with the label "PAD (es)" if the current page is in English
if (isEnglishPage && entry.type === 'group' && entry.label === 'PAD (es)') {
return false;
} else if (!isEnglishPage && entry.type === 'group' && entry.label === 'PAD (en)') {
// or filter out the group with the label "PAD (en)" if the current page is not in English
return false;
}
return true
));
---
<Default {...Astro.props}><slot /></Default>
Hi HiDeoo, thank so much for your help, I was not able to see the notification with your answer but I really appreciate your time and explanation, nice work!
Is your feature request related to a problem?
I need to write a documentation in two languages, starlight have by default this support and works great; however the autogenerated routes and pages based on the opeanapi yaml, I wasn't able to create a version in both languages.
Describe the solution you'd like
I would like an easy way to read for example .yaml file in Spanish and another one in English and it make compatible with the Internationalization (i18n) from the Astro starlight template.
Describe alternatives you've considered
I almost find a workaround by my own but wasn't possible.
Additional Context
Thanks in advance and nice work doing this plugin!