Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 9 additions & 10 deletions src/components/header/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -133,16 +133,15 @@ function LanguagePicker() {
}
aria-label={translate('i18n', 'selectYourLanguage')}
>
{typeof window !== 'undefined' &&
Object.entries(config.locales).map(([id, label]) => (
<button
class={cx(id == lang && style.current)}
data-value={id}
onClick={e => setLang(e.currentTarget.dataset.value)}
>
{label}
</button>
))}
Comment on lines -136 to -145
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIRC, I added the window check as we used to just roll with the hydration error as language was set during first render. A while back I fixed that so it's set in an effect after rendering, fixing the hydration issue, but evidently forgot to update this use here.

{Object.entries(config.locales).map(([id, label]) => (
<button
class={cx(id == lang && style.current)}
data-value={id}
onClick={e => setLang(e.currentTarget.dataset.value)}
>
{label}
</button>
))}
</ExpandableNavLink>
)}
</NavMenu>
Expand Down
2 changes: 1 addition & 1 deletion src/lib/i18n.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export function LanguageProvider({ children }) {
const [lang, setLang] = useState('en');

const translations = useResource(() => {
if (lang == 'en') return Promise.resolve(englishTranslations);
if (lang == 'en') return englishTranslations;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like a bug in how we hydrate suspense boundaries, the app shouldn't be falling over here. Not something I have time to dig too deep into though. A plain return works just as well for our needs.

let url = '';
for (const translationURL in translationURLs) {
if (translationURL.includes(`/${lang}.json`)) {
Expand Down