From cb67faa53fe9e0f292973912f3426a3134d69c34 Mon Sep 17 00:00:00 2001 From: 233dada <2474129326@qq.com> Date: Sat, 12 Oct 2024 18:29:12 +0800 Subject: [PATCH] According to browser's language to choose default language --- .../modules/userSettings/defaultSettings.ts | 16 +++++++++++++++- tsconfig.json | 1 + 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/store/modules/userSettings/defaultSettings.ts b/src/store/modules/userSettings/defaultSettings.ts index 7627e5b4..f24cc034 100644 --- a/src/store/modules/userSettings/defaultSettings.ts +++ b/src/store/modules/userSettings/defaultSettings.ts @@ -1,5 +1,19 @@ +import langData from "@i18n/index.json"; +function extractLangs(data: any): string[]{ + return Object.values(data).map((locale: any) => locale.Code); +}; +const langList = extractLangs(langData); +if(navigator.language === 'zh-CN') + { + var lan = 'zh-si' + }else{ + var lan = navigator.language + }; +if(langList.includes(lan)){}else{ + var lan = 'en' +}; export default Object.freeze({ - language: 'zh-si', + language: lan, disableFilters: false, compactModulesByArtTypeTable: true, planetsCalcSp2: false, diff --git a/tsconfig.json b/tsconfig.json index 01700633..d990eed8 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,5 +1,6 @@ { "compilerOptions": { + "resolveJsonModule": true, "target": "esnext", "module": "esnext", "strict": true,