Skip to content
This repository has been archived by the owner on Jul 12, 2021. It is now read-only.

Commit

Permalink
Fix detection of Simplified Chinese as system language
Browse files Browse the repository at this point in the history
`electron-builder` did not generate all required `lproj` folders for Chinese
  • Loading branch information
samuelmeuli committed Jan 14, 2020
1 parent 6d13be0 commit 4554f3f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@
"tr",
"uk",
"zh",
"zh_CN",
"zh_TW"
],
"hardenedRuntime": true
Expand Down
4 changes: 4 additions & 0 deletions src/main/i18n/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export function initI18n(): void {
systemLang = app.getLocale();
const systemLangNoRegion = systemLang.split("-")[0];
const defaultTranslations = ALL_TRANSLATIONS[FALLBACK_LANG];
logger.log(`System language is "${systemLang}" ("${systemLangNoRegion}" without region)`);

if (systemLang in ALL_TRANSLATIONS) {
// This if-else statement can ensure that if there is any region-specified localizations found,
Expand All @@ -59,6 +60,7 @@ export function initI18n(): void {
...defaultTranslations,
...ALL_TRANSLATIONS[lang],
};
logger.log(`Using "${lang}" locale and translations`);
} else if (systemLangNoRegion in ALL_TRANSLATIONS) {
// Use system language if translations are available
lang = systemLang;
Expand All @@ -67,11 +69,13 @@ export function initI18n(): void {
...defaultTranslations,
...ALL_TRANSLATIONS[langNoRegion],
};
logger.log(`Using "${lang}" locale and "${langNoRegion}" translations`);
} else {
// Otherwise, fall back to default language
lang = FALLBACK_LANG;
langNoRegion = FALLBACK_LANG;
translations = defaultTranslations;
logger.log(`Using default locale and translations ("${FALLBACK_LANG}")`);
}
}

Expand Down

0 comments on commit 4554f3f

Please sign in to comment.