[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:
@@ -2,7 +2,6 @@
|
||||
|
||||
import core, { _t } from "@web/legacy/js/services/core";
|
||||
import checkoutForm from '@payment/js/checkout_form';
|
||||
import { sprintf } from '@web/core/utils/strings';
|
||||
|
||||
checkoutForm.include({
|
||||
events: Object.assign({}, checkoutForm.prototype.events || {}, {
|
||||
@@ -46,7 +45,7 @@ checkoutForm.include({
|
||||
const $field = this.$('input[name="' + id + '"],select[name="' + id + '"]');
|
||||
$field.removeClass('is-invalid').popover('dispose');
|
||||
if (!$field.val().trim()) {
|
||||
errorFields[id] = sprintf(_t("Field '%s' is mandatory"), mandatoryFields[id]);
|
||||
errorFields[id] = _t("Field '%s' is mandatory", mandatoryFields[id]);
|
||||
}
|
||||
}
|
||||
if (Object.keys(errorFields).length) {
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
/** @odoo-module **/
|
||||
|
||||
import { sprintf } from '@web/core/utils/strings';
|
||||
import { _t } from "@web/core/l10n/translation";
|
||||
import publicWidget from '@web/legacy/js/public/public_widget';
|
||||
|
||||
@@ -141,7 +140,7 @@ publicWidget.registry.DonationSnippet = publicWidget.Widget.extend({
|
||||
} else if (amount < parseFloat(minAmount)) {
|
||||
const before = this.currency.position === "before" ? this.currency.symbol : "";
|
||||
const after = this.currency.position === "after" ? this.currency.symbol : "";
|
||||
errorMessage = sprintf(_t("The minimum donation amount is %s%s%s"), before, minAmount, after);
|
||||
errorMessage = _t("The minimum donation amount is %s%s%s", before, minAmount, after);
|
||||
}
|
||||
if (errorMessage) {
|
||||
$(ev.currentTarget).before($('<p>', {
|
||||
|
||||
Reference in New Issue
Block a user