Skip to content

Commit 9733eaf

Browse files
committed
fix(i18n): Fallback to system language or english
1 parent ed0098f commit 9733eaf

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

src/config.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ export const DEFAULT_APP_SETTINGS = {
1414
showMessageBadgeWhenMuted: true,
1515
enableSpellchecking: true,
1616
// spellcheckingLanguage: 'auto',
17-
locale: 'en-US',
17+
locale: '',
18+
fallbackLocale: 'en-US',
1819
beta: false,
1920
isAppMuted: false,
2021
};

src/stores/AppStore.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -255,8 +255,10 @@ export default class AppStore extends Store {
255255
_setLocale() {
256256
const locale = this.stores.settings.all.locale;
257257

258-
if (locale && locale !== this.locale) {
258+
if (locale && Object.prototype.hasOwnProperty.call(locales, locale) && locale !== this.locale) {
259259
this.locale = locale;
260+
} else if (!locale) {
261+
this.locale = this._getDefaultLocale();
260262
}
261263
}
262264

@@ -281,6 +283,10 @@ export default class AppStore extends Store {
281283
locale = defaultLocale;
282284
}
283285

286+
if (!locale) {
287+
locale = DEFAULT_APP_SETTINGS.fallbackLocale;
288+
}
289+
284290
return locale;
285291
}
286292

0 commit comments

Comments
 (0)