aboutsummaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorDan <danjm.com@gmail.com>2018-03-24 01:01:15 +0800
committerDan <danjm.com@gmail.com>2018-03-24 01:01:15 +0800
commit0d71dd7ca0c0c3178670a9882c34d180495a7031 (patch)
treeb7df6bc5328761a30bfdaa60cf3904318958f7b6 /ui
parent08e67c4e4a7548cc90321e8eb172a428e03568b4 (diff)
downloadtangerine-wallet-browser-0d71dd7ca0c0c3178670a9882c34d180495a7031.tar
tangerine-wallet-browser-0d71dd7ca0c0c3178670a9882c34d180495a7031.tar.gz
tangerine-wallet-browser-0d71dd7ca0c0c3178670a9882c34d180495a7031.tar.bz2
tangerine-wallet-browser-0d71dd7ca0c0c3178670a9882c34d180495a7031.tar.lz
tangerine-wallet-browser-0d71dd7ca0c0c3178670a9882c34d180495a7031.tar.xz
tangerine-wallet-browser-0d71dd7ca0c0c3178670a9882c34d180495a7031.tar.zst
tangerine-wallet-browser-0d71dd7ca0c0c3178670a9882c34d180495a7031.zip
i18n helper fetchLocale handles 404 gracefully
Diffstat (limited to 'ui')
-rw-r--r--ui/i18n-helper.js16
1 files changed, 12 insertions, 4 deletions
diff --git a/ui/i18n-helper.js b/ui/i18n-helper.js
index dc83f45c9..3ce24ddfb 100644
--- a/ui/i18n-helper.js
+++ b/ui/i18n-helper.js
@@ -25,10 +25,18 @@ const getMessage = (locale, key, substitutions) => {
return phrase
}
-async function fetchLocale (localeName) {
- const response = await fetch(`/_locales/${localeName}/messages.json`)
- const locale = await response.json()
- return locale
+function fetchLocale (localeName) {
+ return new Promise((resolve, reject) => {
+ return fetch(`/_locales/${localeName}/messages.json`)
+ .then(response => response.json())
+ .then(
+ locale => resolve(locale),
+ error => {
+ log.error(`failed to fetch ${localeName} locale because of ${error}`)
+ resolve({})
+ }
+ )
+ })
}
module.exports = {