This commit is contained in:
Timothy Jaeryang Baek
2026-03-20 15:47:22 -05:00
parent c53cd78dcb
commit de5e0fbc00

View File

@@ -14,8 +14,11 @@ const createI18nStore = (i18n: i18nType) => {
i18nWritable.set(i18n);
});
i18n.on('added', () => i18nWritable.set(i18n));
i18n.on('languageChanged', () => {
i18n.on('languageChanged', (lang) => {
i18nWritable.set(i18n);
if (typeof document !== 'undefined') {
document.documentElement.setAttribute('lang', lang);
}
});
return i18nWritable;
};
@@ -67,9 +70,6 @@ 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);