|
|
@ -25,10 +25,18 @@ const getMessage = (locale, key, substitutions) => { |
|
|
|
return phrase |
|
|
|
return phrase |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
async function fetchLocale (localeName) { |
|
|
|
function fetchLocale (localeName) { |
|
|
|
const response = await fetch(`/_locales/${localeName}/messages.json`) |
|
|
|
return new Promise((resolve, reject) => { |
|
|
|
const locale = await response.json() |
|
|
|
return fetch(`/_locales/${localeName}/messages.json`) |
|
|
|
return locale |
|
|
|
.then(response => response.json()) |
|
|
|
|
|
|
|
.then( |
|
|
|
|
|
|
|
locale => resolve(locale), |
|
|
|
|
|
|
|
error => { |
|
|
|
|
|
|
|
log.error(`failed to fetch ${localeName} locale because of ${error}`) |
|
|
|
|
|
|
|
resolve({}) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
module.exports = { |
|
|
|
module.exports = { |
|
|
|