mirror of
https://github.com/FoggedLens/iD.git
synced 2026-03-21 18:43:23 +00:00
Allow translation with numerical token replacement
Just escapes the special regex characters when creating a new RegExp so that numerical keys can be used (e.g. my use case of replacing an arbitrary number of tokens from an array). Otherwise it is interpreted as a repetition.
This commit is contained in:
@@ -45,7 +45,7 @@ export function t(s, o, loc) {
|
||||
if (rep !== undefined) {
|
||||
if (o) {
|
||||
for (var k in o) {
|
||||
var variable = '{' + k + '}';
|
||||
var variable = '\\{' + k + '\\}';
|
||||
var re = new RegExp(variable, 'g'); // check globally for variables
|
||||
rep = rep.replace(re, o[k]);
|
||||
}
|
||||
@@ -124,4 +124,4 @@ export function languageName(context, code, options) {
|
||||
}
|
||||
}
|
||||
return code; // if not found, use the code
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user