[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:
@@ -3,7 +3,6 @@
|
||||
import { Component, onWillStart, onMounted, useState } from "@odoo/owl";
|
||||
import { registry } from "@web/core/registry";
|
||||
import { useService } from "@web/core/utils/hooks";
|
||||
import { sprintf } from "@web/core/utils/strings";
|
||||
import { FileInput } from "@web/core/file_input/file_input";
|
||||
import { useImportModel } from "../import_model";
|
||||
import { ImportDataContent } from "../import_data_content/import_data_content";
|
||||
@@ -171,10 +170,9 @@ export class ImportAction extends Component {
|
||||
}
|
||||
|
||||
if (!isTest && res.ids.length) {
|
||||
this.notification.add(
|
||||
sprintf(this.env._t("%s records successfully imported"), res.ids.length),
|
||||
{ type: "success" }
|
||||
);
|
||||
this.notification.add(this.env._t("%s records successfully imported", res.ids.length), {
|
||||
type: "success",
|
||||
});
|
||||
this.exit();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
import { Component, useState, onWillStart } from "@odoo/owl";
|
||||
import { _t } from "@web/core/l10n/translation";
|
||||
import { useService } from "@web/core/utils/hooks";
|
||||
import { sprintf } from "@web/core/utils/strings";
|
||||
|
||||
export class ImportDataOptions extends Component {
|
||||
static template = "ImportDataOptions";
|
||||
@@ -45,7 +44,7 @@ export class ImportDataOptions extends Component {
|
||||
const fields = await this.orm.call(this.currentModel, "fields_get");
|
||||
const selection = fields[this.props.fieldInfo.name].selection.map((opt) => [
|
||||
opt[0],
|
||||
sprintf(_t("Set to: %s"), opt[1]),
|
||||
_t("Set to: %s", opt[1]),
|
||||
]);
|
||||
options.push(...selection);
|
||||
} else {
|
||||
|
||||
@@ -5,7 +5,6 @@ import { registry } from "@web/core/registry";
|
||||
import { pick } from "@web/core/utils/objects";
|
||||
import { groupBy, sortBy } from "@web/core/utils/arrays";
|
||||
import { memoize } from "@web/core/utils/functions";
|
||||
import { sprintf } from "@web/core/utils/strings";
|
||||
import { useState } from "@odoo/owl";
|
||||
import { ImportBlockUI } from "./import_block_ui";
|
||||
|
||||
@@ -281,8 +280,8 @@ export class BaseImportModel {
|
||||
if (!importRes.hasError) {
|
||||
if (importRes.nextrow) {
|
||||
this._addMessage("warning", [
|
||||
sprintf(
|
||||
_t("Click 'Resume' to proceed with the import, resuming at line %s."),
|
||||
_t(
|
||||
"Click 'Resume' to proceed with the import, resuming at line %s.",
|
||||
importRes.nextrow + 1
|
||||
),
|
||||
_t("You can test or reload your file before resuming the import."),
|
||||
@@ -445,8 +444,8 @@ export class BaseImportModel {
|
||||
if (error.record !== undefined) {
|
||||
this._addMessage("danger", [
|
||||
error.rows.from === error.rows.to
|
||||
? sprintf(_t('Error at row %s: "%s"'), error.record, error.message)
|
||||
: sprintf(_t("%s at multiple rows"), error.message),
|
||||
? _t('Error at row %s: "%s"', error.record, error.message)
|
||||
: _t("%s at multiple rows", error.message),
|
||||
]);
|
||||
}
|
||||
// Handle global errors.
|
||||
|
||||
Reference in New Issue
Block a user