mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Allow more than 2 variable substitutions in the translation function
This commit is contained in:
parent
31089778ba
commit
e5ca2aac6f
@ -20,10 +20,10 @@ const getMessage = (locale, key, substitutions) => {
|
|||||||
let phrase = entry.message
|
let phrase = entry.message
|
||||||
// perform substitutions
|
// perform substitutions
|
||||||
if (substitutions && substitutions.length) {
|
if (substitutions && substitutions.length) {
|
||||||
phrase = phrase.replace(/\$1/g, substitutions[0])
|
substitutions.forEach((substitution, index) => {
|
||||||
if (substitutions.length > 1) {
|
const regex = new RegExp(`\\$${index + 1}`, 'g')
|
||||||
phrase = phrase.replace(/\$2/g, substitutions[1])
|
phrase = phrase.replace(regex, substitution)
|
||||||
}
|
})
|
||||||
}
|
}
|
||||||
return phrase
|
return phrase
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user