Skip to content

Commit

Permalink
fix(i18n): Fallback to system language or english
Browse files Browse the repository at this point in the history
  • Loading branch information
adlk committed Dec 6, 2017
1 parent ed0098f commit 9733eaf
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down
8 changes: 7 additions & 1 deletion src/stores/AppStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
Expand All @@ -281,6 +283,10 @@ export default class AppStore extends Store {
locale = defaultLocale;
}
if (!locale) {
locale = DEFAULT_APP_SETTINGS.fallbackLocale;
}
return locale;
}
Expand Down

0 comments on commit 9733eaf

Please sign in to comment.