FIX: Escape $ in translations before interpolating (#8100)

The dollar sign (`$`) is a special replace pattern, and `$&` inserts the
matched string. Thus dollars signs need to be escaped with the special
pattern `$$`, which inserts a single `$`.
This commit is contained in:
Kyle Zhao
2019-09-16 10:52:49 -07:00
committed by Robin Ward
parent 7c494cc631
commit fb200e3055
2 changed files with 20 additions and 2 deletions

View File

@ -60,7 +60,8 @@ QUnit.module("lib:i18n", {
days: {
one: "%{count} day",
other: "%{count} days"
}
},
dollar_sign: "Hi {{description}}"
}
}
};
@ -223,3 +224,12 @@ QUnit.test("fallback", assert => {
"falls back to English translations"
);
});
QUnit.test("Dollar signs are properly escaped", assert => {
assert.equal(
I18n.t("dollar_sign", {
description: "$& $&"
}),
"Hi $& $&"
);
});