We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent c53cd78 commit de5e0fbCopy full SHA for de5e0fb
1 file changed
src/lib/i18n/index.ts
@@ -14,8 +14,11 @@ const createI18nStore = (i18n: i18nType) => {
14
i18nWritable.set(i18n);
15
});
16
i18n.on('added', () => i18nWritable.set(i18n));
17
- i18n.on('languageChanged', () => {
+ i18n.on('languageChanged', (lang) => {
18
19
+ if (typeof document !== 'undefined') {
20
+ document.documentElement.setAttribute('lang', lang);
21
+ }
22
23
return i18nWritable;
24
};
@@ -67,9 +70,6 @@ export const initI18n = (defaultLocale?: string | undefined) => {
67
70
escapeValue: false // not needed for svelte as it escapes by default
68
71
}
69
72
-
- const lang = i18next?.language || defaultLocale || 'en-US';
- document.documentElement.setAttribute('lang', lang);
73
74
75
const i18n = createI18nStore(i18next);
0 commit comments