diff options
author | Nick Doiron <ndoiron@mapmeld.com> | 2018-01-30 04:29:01 +0800 |
---|---|---|
committer | Nick Doiron <ndoiron@mapmeld.com> | 2018-01-30 04:29:01 +0800 |
commit | abfa74f09a0119345165a32090d88a1d95df6c80 (patch) | |
tree | 0b826ccd552f3c31524d2dc1c970ea0ddcb1083b /ui/i18n.js | |
parent | 1698541bcdce6c2933c8b3b4e1c89e2f391c3a68 (diff) | |
download | tangerine-wallet-browser-abfa74f09a0119345165a32090d88a1d95df6c80.tar tangerine-wallet-browser-abfa74f09a0119345165a32090d88a1d95df6c80.tar.gz tangerine-wallet-browser-abfa74f09a0119345165a32090d88a1d95df6c80.tar.bz2 tangerine-wallet-browser-abfa74f09a0119345165a32090d88a1d95df6c80.tar.lz tangerine-wallet-browser-abfa74f09a0119345165a32090d88a1d95df6c80.tar.xz tangerine-wallet-browser-abfa74f09a0119345165a32090d88a1d95df6c80.tar.zst tangerine-wallet-browser-abfa74f09a0119345165a32090d88a1d95df6c80.zip |
complete i18n across new UI
Diffstat (limited to 'ui/i18n.js')
-rw-r--r-- | ui/i18n.js | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/ui/i18n.js b/ui/i18n.js index 0f4e9fce4..db79c87e8 100644 --- a/ui/i18n.js +++ b/ui/i18n.js @@ -11,9 +11,20 @@ if ((chrome && chrome.i18n && chrome.i18n.getMessage) || } else { // fallback function console.warn('browser.i18n API not available?') - let msg = require('../app/_locales/en/messages.json') - getMessage = function (key) { - return msg[key].message + const msg = require('../app/_locales/en/messages.json') + getMessage = function (key, substitutions) { + if (!msg[key]) { + console.error(key) + throw new Error(key) + } + let phrase = msg[key].message + if (substitutions && substitutions.length) { + phrase = phrase.replace(/\$1/g, substitutions[0]) + if (substitutions.length > 1) { + phrase = phrase.replace(/\$2/g, substitutions[1]) + } + } + return phrase } } |