[IMP] *: unify sprintf and gettext

Improve gettext to directly handle value injection within translations,
removing the need for sprintf.

closes odoo/odoo#123932

Related: odoo/enterprise#45370
Signed-off-by: Samuel Degueldre (sad) <sad@odoo.com>
This commit is contained in:
Louis Wicket (wil)
2023-08-10 18:14:04 +02:00
parent 62fba62067
commit f1722c7334
123 changed files with 353 additions and 495 deletions
@@ -171,3 +171,23 @@ QUnit.test("tamil has the correct numbering system", async (assert) => {
"௧௦/௧௨/௨௦௨௧ ௧௨:௦௦:௦௦"
);
});
QUnit.test(
"_t fills the format specifiers in translated terms with its extra arguments",
async (assert) => {
patchWithCleanup(translatedTerms, { "Due in %s days": "Échéance dans %s jours" });
const translatedStr = _t("Due in %s days", 513);
assert.strictEqual(translatedStr, "Échéance dans 513 jours");
}
);
QUnit.test(
"_t fills the format specifiers in lazy translated terms with its extra arguments",
async (assert) => {
translatedTerms[translationLoaded] = false;
const translatedStr = _t("Due in %s days", 513);
patchWithCleanup(translatedTerms, { "Due in %s days": "Échéance dans %s jours" });
translatedTerms[translationLoaded] = true;
assert.equal(translatedStr, "Échéance dans 513 jours");
}
);