[FIX] *: replace %d by %s when using sprintf

*: web, web_editor, payment
Before this commit, templates with %d was given to sprintf but it was not interpreted by the function
After the commit, %d are replaced by %s in templates for sprintf
Also this commit converts a last _.str.sprintf into sprintf

PR#120143

closes odoo/odoo#120143

Signed-off-by: Michaël Mattiello <mcm@odoo.com>
This commit is contained in:
Pulinckx Pierre (PIPU)
2023-05-02 15:59:04 +02:00
parent f481475879
commit 126da95642
4 changed files with 6 additions and 5 deletions
@@ -1,5 +1,6 @@
/** @odoo-module alias=payment.payment_form_mixin **/
import { sprintf } from "@web/core/utils/strings";
import core from "web.core";
import Dialog from "web.Dialog";
@@ -94,7 +95,7 @@
const $checkedRadios = this.$('input[name="o_payment_radio"]:checked');
if ($checkedRadios.length !== 1) { // Cannot find selected payment option, show dialog
return new Dialog(null, {
title: _.str.sprintf(_t("Error: %s"), title),
title: sprintf(_t("Error: %s"), title),
size: 'medium',
$content: `<p>${escapeHTML(description) || ''}</p>`,
buttons: [{text: _t("Ok"), close: true}]
@@ -470,7 +470,7 @@ export class ListController extends Component {
this.notificationService.add(
sprintf(
this.env._t(
"Of the %d records selected, only the first %d have been archived/unarchived."
"Of the %s records selected, only the first %s have been archived/unarchived."
),
resIds.length,
total
@@ -5774,8 +5774,8 @@ const ImageHandlerOption = SnippetOptionWidget.extend({
1920: '1920px',
};
widths[img.naturalWidth] = sprintf(_t("%spx"), img.naturalWidth);
widths[optimizedWidth] = sprintf(_t("%dpx (Suggested)"), optimizedWidth);
widths[maxWidth] = sprintf(_t("%dpx (Original)"), maxWidth);
widths[optimizedWidth] = sprintf(_t("%spx (Suggested)"), optimizedWidth);
widths[maxWidth] = sprintf(_t("%spx (Original)"), maxWidth);
return Object.entries(widths)
.filter(([width]) => width <= maxWidth)
.sort(([v1], [v2]) => v1 - v2);
@@ -19,7 +19,7 @@ PortalChatter.include({
_reloadChatterContent: async function (data) {
await this._super(...arguments);
if (this.options.res_model === "slide.channel") {
$('#review-tab').text(sprintf(_t('Reviews (%d)'), data.rating_count));
$('#review-tab').text(sprintf(_t('Reviews (%s)'), data.rating_count));
}
},
});