[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:
@@ -7,7 +7,6 @@ import { evaluateExpr } from "@web/core/py_js/py";
|
||||
import { registry } from "@web/core/registry";
|
||||
import { Deferred, KeepLast } from "@web/core/utils/concurrency";
|
||||
import { useBus, useService } from "@web/core/utils/hooks";
|
||||
import { sprintf } from "@web/core/utils/strings";
|
||||
import { cleanDomFromBootstrap } from "@web/legacy/utils";
|
||||
import { View, ViewNotFoundError } from "@web/views/view";
|
||||
import { ActionDialog } from "./action_dialog";
|
||||
@@ -1306,10 +1305,7 @@ function makeActionManager(env) {
|
||||
const view = _getView(viewType);
|
||||
if (!view) {
|
||||
throw new ViewNotFoundError(
|
||||
sprintf(
|
||||
env._t("No view of type '%s' could be found in the current action."),
|
||||
viewType
|
||||
)
|
||||
env._t("No view of type '%s' could be found in the current action.", viewType)
|
||||
);
|
||||
}
|
||||
const newController = controller.action.controllers[viewType] || {
|
||||
|
||||
@@ -33,10 +33,7 @@ class InvalidAction extends Component {
|
||||
}
|
||||
|
||||
onMounted() {
|
||||
const message = sprintf(
|
||||
this.env._t("No action with id '%s' could be found"),
|
||||
this.props.actionId
|
||||
);
|
||||
const message = this.env._t("No action with id '%s' could be found", this.props.actionId);
|
||||
this.notification.add(message, { type: "danger" });
|
||||
}
|
||||
}
|
||||
|
||||
+3
-4
@@ -4,7 +4,6 @@ import { registry } from "@web/core/registry";
|
||||
import { _t } from "@web/core/l10n/translation";
|
||||
import { unique } from "@web/core/utils/arrays";
|
||||
import { useService } from "@web/core/utils/hooks";
|
||||
import { sprintf } from "@web/core/utils/strings";
|
||||
|
||||
import { Component, useState, onWillStart } from "@odoo/owl";
|
||||
import { standardWidgetProps } from "@web/views/widgets/standard_widget_props";
|
||||
@@ -70,15 +69,15 @@ class ResConfigInviteUsers extends Component {
|
||||
});
|
||||
switch (invalidEmails.length) {
|
||||
case 1:
|
||||
return sprintf(_t("Invalid email address: %(address)s"), {
|
||||
return _t("Invalid email address: %(address)s", {
|
||||
address: invalidEmails[0],
|
||||
});
|
||||
case 2:
|
||||
return sprintf(_t("Invalid email addresses: %(2 addresses)s"), {
|
||||
return _t("Invalid email addresses: %(2 addresses)s", {
|
||||
"2 addresses": listFormatter.format(invalidEmails),
|
||||
});
|
||||
default:
|
||||
return sprintf(_t("Invalid email addresses: %(addresses)s"), {
|
||||
return _t("Invalid email addresses: %(addresses)s", {
|
||||
addresses: listFormatter.format(invalidEmails),
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user