From a7f334d92d1b603a7c0787df197cde8be02a1f5a Mon Sep 17 00:00:00 2001 From: gofnnp Date: Thu, 29 Aug 2024 01:25:00 +0400 Subject: [PATCH] hotfix/AW-195-fix-error --- src/init.tsx | 2 ++ src/locales/index.ts | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) 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'