diff options
author | kumavis <kumavis@users.noreply.github.com> | 2018-04-06 06:08:19 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-04-06 06:08:19 +0800 |
commit | 79932b7e17dd12803e3674ed0780f0edad134a8a (patch) | |
tree | 0a4b0cfd2975ab219bfcd630aec61feb106953f8 /app/scripts/lib | |
parent | 24eef428cea095f9700dcf290ba90b8bd2a83840 (diff) | |
parent | 3c4b72bf2c5eab9c98531fcf7b0929a415b63f87 (diff) | |
download | tangerine-wallet-browser-79932b7e17dd12803e3674ed0780f0edad134a8a.tar tangerine-wallet-browser-79932b7e17dd12803e3674ed0780f0edad134a8a.tar.gz tangerine-wallet-browser-79932b7e17dd12803e3674ed0780f0edad134a8a.tar.bz2 tangerine-wallet-browser-79932b7e17dd12803e3674ed0780f0edad134a8a.tar.lz tangerine-wallet-browser-79932b7e17dd12803e3674ed0780f0edad134a8a.tar.xz tangerine-wallet-browser-79932b7e17dd12803e3674ed0780f0edad134a8a.tar.zst tangerine-wallet-browser-79932b7e17dd12803e3674ed0780f0edad134a8a.zip |
Merge pull request #3857 from MetaMask/match-local-localecodes
Ensure get-first-preferred-lang-code.js matches locale codes from loc…
Diffstat (limited to 'app/scripts/lib')
-rw-r--r-- | app/scripts/lib/get-first-preferred-lang-code.js | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/app/scripts/lib/get-first-preferred-lang-code.js b/app/scripts/lib/get-first-preferred-lang-code.js index 28612f763..e3635434e 100644 --- a/app/scripts/lib/get-first-preferred-lang-code.js +++ b/app/scripts/lib/get-first-preferred-lang-code.js @@ -2,14 +2,16 @@ const extension = require('extensionizer') const promisify = require('pify') const allLocales = require('../../_locales/index.json') -const existingLocaleCodes = allLocales.map(locale => locale.code) +const existingLocaleCodes = allLocales.map(locale => locale.code.toLowerCase().replace('_', '-')) async function getFirstPreferredLangCode () { const userPreferredLocaleCodes = await promisify( extension.i18n.getAcceptLanguages, { errorFirst: false } )() - const firstPreferredLangCode = userPreferredLocaleCodes.find(code => existingLocaleCodes.includes(code)) + const firstPreferredLangCode = userPreferredLocaleCodes + .map(code => code.toLowerCase()) + .find(code => existingLocaleCodes.includes(code)) return firstPreferredLangCode || 'en' } |