[REF] *: Unify _t and _lt

The goal of this commit is to prepare ground to remove
lazytranslate function _lt() and keep only _t()
for a better understanding of the use of the translation function.

In this commit,

the translate function _t() has been updated to return the translation
if they are loaded. If not, it throws an error.
the lazytranslate function _lt() returns _t() function.
Corollaries :
Steps in test tours are now a function that returns an array of steps
to avoid any interpolation of _t in this ones before translations has
been loaded.

Example :

registry.category("web_tour.tours").add("example", {
    test: true,
    steps: () => [
        {...},
        {...},
    ],
});

task-3292454

closes odoo/odoo#124157

Related: odoo/enterprise#43153
Signed-off-by: Samuel Degueldre (sad) <sad@odoo.com>
This commit is contained in:
Pierre Pulinckx (pipu)
2023-07-19 13:13:16 +02:00
parent ac90aa077d
commit 8bfa76a842
204 changed files with 3342 additions and 2887 deletions
@@ -6,7 +6,7 @@ import { stepUtils } from "@web_tour/tour_service/tour_utils";
registry.category("web_tour.tours").add('hr_employee_tour', {
test: true,
url: '/web',
steps: [
steps: () => [
stepUtils.showAppsMenuItem(),
{
content: "Open Employees app",
@@ -2,19 +2,30 @@
import { stepUtils } from "@web_tour/tour_service/tour_utils";
import { registry } from "@web/core/registry";
import { patch } from "@web/core/utils/patch";
/**
* As 'hr' changes the flow a bit and displays the user preferences form in a full view instead of
* a modal, we adapt the steps of the original tour accordingly.
*/
registry.category("web_tour.tours").get('mail/static/tests/tours/user_modify_own_profile_tour.js').steps = [{
content: 'Open user account menu',
trigger: '.o_user_menu button',
}, {
content: "Open preferences / profile screen",
trigger: '[data-menu=settings]',
}, {
content: "Update the email address",
trigger: 'div[name="email"] input',
run: 'text updatedemail@example.com',
}, ...stepUtils.saveForm()];
patch(registry.category("web_tour.tours").get("mail/static/tests/tours/user_modify_own_profile_tour.js"), "patch_user_modify_own_profile_tour", {
steps() {
return [
{
content: 'Open user account menu',
trigger: '.o_user_menu button',
},
{
content: "Open preferences / profile screen",
trigger: '[data-menu=settings]',
},
{
content: "Update the email address",
trigger: 'div[name="email"] input',
run: 'text updatedemail@example.com',
},
...stepUtils.saveForm(),
];
}
});