Skip to content

Commit

Permalink
fix: get proper language settings
Browse files Browse the repository at this point in the history
  • Loading branch information
3Shain committed Mar 18, 2023
1 parent ae37162 commit 1bae126
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions src/locale/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@ type Assertion = AssertKeysEqual<typeof zh_CN, typeof en>;
export type LocaleTextKey = keyof typeof zh_CN;

export const locales = {
zh_CN,
zh_cn: zh_CN,
en,
};

export async function createLocale() {
let lang = "zh_CN";
let lang = "zh_cn";
try {
lang = await getKey("config_lang");
lang = (await getKey("config_lang")).toLowerCase();
} catch {
lang = await Neutralino.os.getEnv("LANG");
lang = navigator.language.replaceAll("-", "_").toLowerCase();
if (lang == "") {
lang = "en";
} else {
Expand All @@ -36,10 +36,6 @@ export async function createLocale() {
if (lang.startsWith("en_")) {
lang = "en";
}
// Traditional Chinese to be done
// if(["zh-MO","zh-HK"].indexOf(lang)>=0) {
//
// }
}
let locale =
lang in locales ? locales[lang as keyof typeof locales] : locales["en"];
Expand Down

0 comments on commit 1bae126

Please sign in to comment.