aboutsummaryrefslogtreecommitdiffstats
path: root/ui/i18n-helper.js
diff options
context:
space:
mode:
authorAlexander Tseung <alextsg@gmail.com>2018-09-01 03:12:12 +0800
committerAlexander Tseung <alextsg@gmail.com>2018-09-13 10:48:51 +0800
commite5ca2aac6f123e3e1db5e18c5854351c58af42b2 (patch)
treeede6090102ca887cc6c4adbc8ba19e66772a4cb0 /ui/i18n-helper.js
parent31089778ba3c97443e25bd3a7a901f45757894d9 (diff)
downloadtangerine-wallet-browser-e5ca2aac6f123e3e1db5e18c5854351c58af42b2.tar
tangerine-wallet-browser-e5ca2aac6f123e3e1db5e18c5854351c58af42b2.tar.gz
tangerine-wallet-browser-e5ca2aac6f123e3e1db5e18c5854351c58af42b2.tar.bz2
tangerine-wallet-browser-e5ca2aac6f123e3e1db5e18c5854351c58af42b2.tar.lz
tangerine-wallet-browser-e5ca2aac6f123e3e1db5e18c5854351c58af42b2.tar.xz
tangerine-wallet-browser-e5ca2aac6f123e3e1db5e18c5854351c58af42b2.tar.zst
tangerine-wallet-browser-e5ca2aac6f123e3e1db5e18c5854351c58af42b2.zip
Allow more than 2 variable substitutions in the translation function
Diffstat (limited to 'ui/i18n-helper.js')
-rw-r--r--ui/i18n-helper.js8
1 files changed, 4 insertions, 4 deletions
diff --git a/ui/i18n-helper.js b/ui/i18n-helper.js
index bc927ee65..c6a7d0bf1 100644
--- a/ui/i18n-helper.js
+++ b/ui/i18n-helper.js
@@ -20,10 +20,10 @@ const getMessage = (locale, key, substitutions) => {
let phrase = entry.message
// perform substitutions
if (substitutions && substitutions.length) {
- phrase = phrase.replace(/\$1/g, substitutions[0])
- if (substitutions.length > 1) {
- phrase = phrase.replace(/\$2/g, substitutions[1])
- }
+ substitutions.forEach((substitution, index) => {
+ const regex = new RegExp(`\\$${index + 1}`, 'g')
+ phrase = phrase.replace(regex, substitution)
+ })
}
return phrase
}