fix(website/i18n): header sometimes not correctly translated

This commit is contained in:
Elian Doran
2025-10-25 21:13:48 +03:00
parent a4d92e12be
commit 71cd92e0b5
2 changed files with 13 additions and 9 deletions

View File

@@ -52,14 +52,15 @@ export function LocaleProvider({ children }) {
},
returnEmptyString: false
}).then(() => setLoaded(true))
}, []);
}, []);
useEffect(() => {
useLayoutEffect(() => {
if (!loaded) return;
changeLanguage(localeId);
const correspondingLocale = LOCALES.find(l => l.id === localeId);
document.documentElement.lang = localeId;
document.documentElement.dir = correspondingLocale?.rtl ? "rtl" : "ltr";
}, [ localeId ]);
}, [ loaded, localeId ]);
return (
<LocaleContext.Provider value={localeId}>