diff --git a/src/init.tsx b/src/init.tsx index 0ab5994..51c4bb9 100755 --- a/src/init.tsx +++ b/src/init.tsx @@ -15,6 +15,7 @@ import { getTranslationJSON, ELocalesPlacement, language, + setLanguage, } from "./locales"; import App from "./components/App"; import metricService from "./services/metric/metricService"; @@ -27,6 +28,7 @@ pdfjs.GlobalWorkerOptions.workerSrc = `https://unpkg.com/pdfjs-dist@${pdfjs.vers const environments = import.meta.env; const init = async () => { + await setLanguage(); const api = createApi(); const currentPlacement = localStorage.getItem( "locales-placement" diff --git a/src/locales/index.ts b/src/locales/index.ts index 9a6badc..e3c4f38 100644 --- a/src/locales/index.ts +++ b/src/locales/index.ts @@ -23,8 +23,12 @@ export const getClientLocale = async () => { } export const getClientTimezone = () => Intl.DateTimeFormat().resolvedOptions().timeZone -export const language = await getClientLocale() export const fallbackLng = 'en' +export let language: string = fallbackLng; + +export const setLanguage = async () => { + language = await getClientLocale(); +}; const omitKeys = ['href', 'title', 'url_slug', 'type'] // const isWeb = (group: Elements.ElementGroup) => group.name === 'web'