diff options
author | kumavis <kumavis@users.noreply.github.com> | 2018-05-30 02:05:12 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-05-30 02:05:12 +0800 |
commit | 39069710d19df57daaed2617155261eb581a332f (patch) | |
tree | ffc23f89e285dbe0ca4eba02b473b5f4926437fe /app | |
parent | 41e38fe5530bce1fd7d19060774179a215087fac (diff) | |
parent | e3ecc94a521b040d8937bd7aaed2ecc7f029c586 (diff) | |
download | tangerine-wallet-browser-39069710d19df57daaed2617155261eb581a332f.tar tangerine-wallet-browser-39069710d19df57daaed2617155261eb581a332f.tar.gz tangerine-wallet-browser-39069710d19df57daaed2617155261eb581a332f.tar.bz2 tangerine-wallet-browser-39069710d19df57daaed2617155261eb581a332f.tar.lz tangerine-wallet-browser-39069710d19df57daaed2617155261eb581a332f.tar.xz tangerine-wallet-browser-39069710d19df57daaed2617155261eb581a332f.tar.zst tangerine-wallet-browser-39069710d19df57daaed2617155261eb581a332f.zip |
Merge pull request #4390 from MetaMask/i18n-brave-fix
i18n - getFirstPreferredLangCode - guard against missing i18n api
Diffstat (limited to 'app')
-rw-r--r-- | app/scripts/lib/get-first-preferred-lang-code.js | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/app/scripts/lib/get-first-preferred-lang-code.js b/app/scripts/lib/get-first-preferred-lang-code.js index 5473fccf0..1e6a83ba6 100644 --- a/app/scripts/lib/get-first-preferred-lang-code.js +++ b/app/scripts/lib/get-first-preferred-lang-code.js @@ -2,6 +2,12 @@ const extension = require('extensionizer') const promisify = require('pify') const allLocales = require('../../_locales/index.json') +const isSupported = extension.i18n && extension.i18n.getAcceptLanguages +const getPreferredLocales = isSupported ? promisify( + extension.i18n.getAcceptLanguages, + { errorFirst: false } +) : async () => [] + const existingLocaleCodes = allLocales.map(locale => locale.code.toLowerCase().replace('_', '-')) /** @@ -12,10 +18,7 @@ const existingLocaleCodes = allLocales.map(locale => locale.code.toLowerCase().r * */ async function getFirstPreferredLangCode () { - const userPreferredLocaleCodes = await promisify( - extension.i18n.getAcceptLanguages, - { errorFirst: false } - )() + const userPreferredLocaleCodes = await getPreferredLocales() const firstPreferredLangCode = userPreferredLocaleCodes .map(code => code.toLowerCase()) .find(code => existingLocaleCodes.includes(code)) |