From 9733eaf85115444718a1f6a32b971d29bd54d0ca Mon Sep 17 00:00:00 2001 From: Stefan Malzner Date: Thu, 7 Dec 2017 00:08:45 +0100 Subject: [PATCH] fix(i18n): Fallback to system language or english --- src/config.js | 3 ++- src/stores/AppStore.js | 8 +++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/config.js b/src/config.js index e6d8958e6..e66594c59 100644 --- a/src/config.js +++ b/src/config.js @@ -14,7 +14,8 @@ export const DEFAULT_APP_SETTINGS = { showMessageBadgeWhenMuted: true, enableSpellchecking: true, // spellcheckingLanguage: 'auto', - locale: 'en-US', + locale: '', + fallbackLocale: 'en-US', beta: false, isAppMuted: false, }; diff --git a/src/stores/AppStore.js b/src/stores/AppStore.js index 17ec832cf..dcdb11a12 100644 --- a/src/stores/AppStore.js +++ b/src/stores/AppStore.js @@ -255,8 +255,10 @@ export default class AppStore extends Store { _setLocale() { const locale = this.stores.settings.all.locale; - if (locale && locale !== this.locale) { + if (locale && Object.prototype.hasOwnProperty.call(locales, locale) && locale !== this.locale) { this.locale = locale; + } else if (!locale) { + this.locale = this._getDefaultLocale(); } } @@ -281,6 +283,10 @@ export default class AppStore extends Store { locale = defaultLocale; } + if (!locale) { + locale = DEFAULT_APP_SETTINGS.fallbackLocale; + } + return locale; }