diff --git a/src/client/init.ts b/src/client/init.ts index e5d5b72467..472965fac6 100644 --- a/src/client/init.ts +++ b/src/client/init.ts @@ -81,10 +81,6 @@ const html = document.documentElement; html.setAttribute('lang', lang); //#endregion -const i18n = createI18n({ - legacy: true, -}); - //#region Fetch user const signout = () => { store.dispatch('logout'); @@ -158,17 +154,24 @@ app.use(store); app.use(router); app.use(VueHotkey); app.use(VAnimateCss); -app.use(i18n); app.component('fa', FontAwesomeIcon); -//#region Fetch locale data -/*await count(clientDb.i18n).then(async n => { - if (n === 0) return setI18nContexts(lang, version, i18n); - if ((await get('_version_', clientDb.i18n) !== version)) return setI18nContexts(lang, version, i18n, true); +//#region Init i18n +const locale = await count(clientDb.i18n).then(async n => { + if (n === 0) return await setI18nContexts(lang, version, i18n); + if ((await get('_version_', clientDb.i18n) !== version)) return await setI18nContexts(lang, version, i18n, true); - i18n.locale = lang; - i18n.setLocaleMessage(lang, await getLocale()); -});*/ + return await getLocale(); +}); + +const i18n = createI18n({ + legacy: true, + sync: false, + locale: lang, + messages: { [lang]: locale } +}); + +app.use(i18n); //#endregion widgets(app); diff --git a/src/client/scripts/set-i18n-contexts.ts b/src/client/scripts/set-i18n-contexts.ts index acd12386fd..de3d3de1bf 100644 --- a/src/client/scripts/set-i18n-contexts.ts +++ b/src/client/scripts/set-i18n-contexts.ts @@ -11,7 +11,6 @@ export function setI18nContexts(lang: string, version: string, i18n: I18n, clear .then(locale => { const flatLocaleEntries = deepEntries(locale, delimitEntry) as [string, string][]; bulkSet(flatLocaleEntries, clientDb.i18n); - i18n.locale = lang; - i18n.setLocaleMessage(lang, Object.fromEntries(flatLocaleEntries)); + return Object.fromEntries(flatLocaleEntries); }); }