diff --git a/package-lock.json b/package-lock.json index b3f69e3e..6244a445 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1943,7 +1943,7 @@ }, "chalk": { "version": "1.1.3", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", + "resolved": "http://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", "dev": true, "requires": { @@ -2343,7 +2343,7 @@ }, "browserify-aes": { "version": "1.2.0", - "resolved": "https://registry.npmjs.org/browserify-aes/-/browserify-aes-1.2.0.tgz", + "resolved": "http://registry.npmjs.org/browserify-aes/-/browserify-aes-1.2.0.tgz", "integrity": "sha512-+7CHXqGuspUn/Sl5aO7Ea0xWGAtETPXNSAjHo48JfLdPWcMng33Xe4znFvQweqc/uzk5zSOI3H52CYnjCfb5hA==", "dev": true, "requires": { @@ -2380,7 +2380,7 @@ }, "browserify-rsa": { "version": "4.0.1", - "resolved": "https://registry.npmjs.org/browserify-rsa/-/browserify-rsa-4.0.1.tgz", + "resolved": "http://registry.npmjs.org/browserify-rsa/-/browserify-rsa-4.0.1.tgz", "integrity": "sha1-IeCr+vbyApzy+vsTNWenAdQTVSQ=", "dev": true, "requires": { @@ -3417,7 +3417,7 @@ }, "create-hash": { "version": "1.2.0", - "resolved": "https://registry.npmjs.org/create-hash/-/create-hash-1.2.0.tgz", + "resolved": "http://registry.npmjs.org/create-hash/-/create-hash-1.2.0.tgz", "integrity": "sha512-z00bCGNHDG8mHAkP7CtT1qVu+bFQUPjYq/4Iv3C3kWjTFV10zIjfSoeqXo9Asws8gwSHDGj/hl2u4OGIjapeCg==", "dev": true, "requires": { @@ -3430,7 +3430,7 @@ }, "create-hmac": { "version": "1.1.7", - "resolved": "https://registry.npmjs.org/create-hmac/-/create-hmac-1.1.7.tgz", + "resolved": "http://registry.npmjs.org/create-hmac/-/create-hmac-1.1.7.tgz", "integrity": "sha512-MJG9liiZ+ogc4TzUwuvbER1JRdgvUFSB5+VR/g5h82fGaIRWMWddtKBHi7/sVhfjQZ6SehlyhvQYrcYkaUIpLg==", "dev": true, "requires": { @@ -3864,7 +3864,7 @@ }, "diffie-hellman": { "version": "5.0.3", - "resolved": "https://registry.npmjs.org/diffie-hellman/-/diffie-hellman-5.0.3.tgz", + "resolved": "http://registry.npmjs.org/diffie-hellman/-/diffie-hellman-5.0.3.tgz", "integrity": "sha512-kqag/Nl+f3GwyK25fhUMYj81BUOrZ9IuJsjIcDE5icNM9FJHAVm3VcUDxdLPoQtTuUylWm6ZIknYJwwaPxsUzg==", "dev": true, "requires": { @@ -4205,7 +4205,7 @@ } }, "electron-window-state": { - "version": "github:warpdesign/electron-window-state#67246877c53f14eda8bb1034a9533709b9f46ccf", + "version": "github:warpdesign/electron-window-state#2701d9a0f90a44dc8dbf81430538ceb16c9ff27a", "from": "github:warpdesign/electron-window-state", "requires": { "jsonfile": "^4.0.0", @@ -4453,7 +4453,7 @@ }, "events": { "version": "1.1.1", - "resolved": "https://registry.npmjs.org/events/-/events-1.1.1.tgz", + "resolved": "http://registry.npmjs.org/events/-/events-1.1.1.tgz", "integrity": "sha1-nr23Y1rQmccNzEwqH1AEKI6L2SQ=", "dev": true }, @@ -5315,7 +5315,7 @@ }, "get-stream": { "version": "3.0.0", - "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz", + "resolved": "http://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz", "integrity": "sha1-jpQ9E1jcN1VQVOy+LtsFqhdO3hQ=", "dev": true }, @@ -5747,7 +5747,7 @@ }, "html-webpack-plugin": { "version": "3.2.0", - "resolved": "https://registry.npmjs.org/html-webpack-plugin/-/html-webpack-plugin-3.2.0.tgz", + "resolved": "http://registry.npmjs.org/html-webpack-plugin/-/html-webpack-plugin-3.2.0.tgz", "integrity": "sha1-sBq71yOsqqeze2r0SS69oD2d03s=", "dev": true, "requires": { @@ -6414,7 +6414,7 @@ }, "is-obj": { "version": "1.0.1", - "resolved": "https://registry.npmjs.org/is-obj/-/is-obj-1.0.1.tgz", + "resolved": "http://registry.npmjs.org/is-obj/-/is-obj-1.0.1.tgz", "integrity": "sha1-PkcprB9f3gJc19g6iW2rn09n2w8=", "dev": true }, @@ -7574,7 +7574,7 @@ }, "load-json-file": { "version": "1.1.0", - "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-1.1.0.tgz", + "resolved": "http://registry.npmjs.org/load-json-file/-/load-json-file-1.1.0.tgz", "integrity": "sha1-lWkFcI1YtLq0wiYbBPWfMcmTdMA=", "dev": true, "requires": { @@ -8262,12 +8262,12 @@ }, "mobx": { "version": "3.6.2", - "resolved": "https://registry.npmjs.org/mobx/-/mobx-3.6.2.tgz", + "resolved": "http://registry.npmjs.org/mobx/-/mobx-3.6.2.tgz", "integrity": "sha512-Dq3boJFLpZEvuh5a/MbHLUIyN9XobKWIb0dBfkNOJffNkE3vtuY0C9kSDVpfH8BB0BPkVw8g22qCv7d05LEhKg==" }, "mobx-react": { "version": "4.4.3", - "resolved": "https://registry.npmjs.org/mobx-react/-/mobx-react-4.4.3.tgz", + "resolved": "http://registry.npmjs.org/mobx-react/-/mobx-react-4.4.3.tgz", "integrity": "sha1-uqnsQRZe41rnud8ZvKEBkPNvEX4=", "requires": { "hoist-non-react-statics": "^2.3.1" @@ -8563,7 +8563,7 @@ }, "rimraf": { "version": "2.4.5", - "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.4.5.tgz", + "resolved": "http://registry.npmjs.org/rimraf/-/rimraf-2.4.5.tgz", "integrity": "sha1-7nEM5dk6j9uFb7Xqj/Di11k0sto=", "dev": true, "optional": true, @@ -8626,7 +8626,7 @@ }, "ncp": { "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ncp/-/ncp-2.0.0.tgz", + "resolved": "http://registry.npmjs.org/ncp/-/ncp-2.0.0.tgz", "integrity": "sha1-GVoh1sRuNh0vsSgbo4uR6d9727M=", "dev": true, "optional": true @@ -9859,7 +9859,7 @@ }, "readable-stream": { "version": "1.1.14", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz", + "resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz", "integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=", "dev": true, "requires": { @@ -10881,7 +10881,7 @@ }, "sax": { "version": "1.2.1", - "resolved": "https://registry.npmjs.org/sax/-/sax-1.2.1.tgz", + "resolved": "http://registry.npmjs.org/sax/-/sax-1.2.1.tgz", "integrity": "sha1-e45lYZCyKOgaZq6nSEgNgozS03o=", "dev": true }, @@ -11028,7 +11028,7 @@ }, "sha.js": { "version": "2.4.11", - "resolved": "https://registry.npmjs.org/sha.js/-/sha.js-2.4.11.tgz", + "resolved": "http://registry.npmjs.org/sha.js/-/sha.js-2.4.11.tgz", "integrity": "sha512-QMEp5B7cftE7APOjk5Y6xgrbWu+WkLVQwk8JNjZ8nKRciZaByEW6MubieAiToS7+dwvrjGhH8jRXz3MVd0AYqQ==", "dev": true, "requires": { @@ -13397,7 +13397,7 @@ }, "xmlbuilder": { "version": "9.0.7", - "resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-9.0.7.tgz", + "resolved": "http://registry.npmjs.org/xmlbuilder/-/xmlbuilder-9.0.7.tgz", "integrity": "sha1-Ey7mPS7FVlxVfiD0wi35rKaGsQ0=", "dev": true }, diff --git a/src/locale/i18n.ts b/src/locale/i18n.ts index 5ddc9148..3a7dac4d 100644 --- a/src/locale/i18n.ts +++ b/src/locale/i18n.ts @@ -37,4 +37,6 @@ i18next.on('languageChanged', () => { ipcRenderer.send('languageChanged', i18next.t('APP_MENUS', { returnObjects: true })); }); -export { i18next }; +const languageList = Object.keys(locales); + +export { i18next, languageList }; diff --git a/src/state/settingsState.ts b/src/state/settingsState.ts index 6cd68978..28996bf9 100644 --- a/src/state/settingsState.ts +++ b/src/state/settingsState.ts @@ -1,7 +1,7 @@ import { observable, action } from "mobx"; import { remote } from 'electron'; import { JSObject } from "../components/Log"; -import { i18next } from '../locale/i18n'; +import { i18next, languageList } from '../locale/i18n'; import { isMojave, isWin, isMac, defaultFolder } from '../utils/platform'; const { systemPreferences } = remote; @@ -71,19 +71,15 @@ export class SettingsState { lang = remote.app.getLocale(); } - // Note: it seems i18next may not always - // have cached all languages, even though it will correctly work. - // Comment this out for now since it prevents locale other than English - // from working - // if (i18next.languages.indexOf(lang) < 0) { - // lang = 'en'; - // } + // fallback to English if preferred language + // isn't available + if (languageList.indexOf(lang) < 0) { + lang = 'en'; + } // finally set requested language i18next.changeLanguage(lang); - console.log('setting language to', i18next.language); - this.lang = i18next.language; } @@ -118,6 +114,7 @@ export class SettingsState { @action loadAndUpgradeSettings(): JSObject { let settings = this.getParam(APP_STORAGE_KEY); + // no settings set: first time the app is run if (settings === null) { settings = this.getDefaultSettings();