i18n(html): sync html language with i18n language

This commit is contained in:
Timothy Jaeryang Baek
2025-02-28 16:06:28 -08:00
parent 88c02d5a14
commit fe44e4d344
3 changed files with 12 additions and 4 deletions
+8
View File
@@ -66,6 +66,9 @@ export const initI18n = (defaultLocale: string | undefined) => {
escapeValue: false // not needed for svelte as it escapes by default
}
});
const lang = i18next?.language || defaultLocale || 'en-US';
document.documentElement.setAttribute('lang', lang);
};
const i18n = createI18nStore(i18next);
@@ -75,5 +78,10 @@ export const getLanguages = async () => {
const languages = (await import(`./locales/languages.json`)).default;
return languages;
};
export const changeLanguage = (lang: string) => {
document.documentElement.setAttribute('lang', lang);
i18next.changeLanguage(lang);
};
export default i18n;
export const isLoading = isLoadingStore;