mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
i18n helper fetchLocale handles 404 gracefully
This commit is contained in:
parent
08e67c4e4a
commit
0d71dd7ca0
@ -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 = {
|
||||
|
Loading…
Reference in New Issue
Block a user