[IMP] web: remove _lt from env
Having _lt in the env doesn't make much sense, as it is useless at run time, and it would incite people to require 'web.env' to use it (at load time). The env should never be directly imported, it is automatically propagated from parents to children. To sum up, in Owl components: - when terms have to be translated at run time (e.g. in a function called when the user clicks on a button), the env is available and env._t must be used - when terms have to be translated at load time (e.g. a JS module defining a component with a translatable static property), one must require 'web.translation' and use function _lt it exports. closes odoo/odoo#50656 Signed-off-by: Géry Debongnie (ged) <ged@openerp.com>
This commit is contained in:
@@ -3,11 +3,12 @@ odoo.define("web.env", function (require) {
|
||||
|
||||
const { jsonRpc } = require('web.ajax');
|
||||
const { device, isDebug } = require("web.config");
|
||||
const { _lt, _t, bus, serviceRegistry } = require("web.core");
|
||||
const { bus, serviceRegistry } = require("web.core");
|
||||
const dataManager = require('web.data_manager');
|
||||
const { blockUI, unblockUI } = require("web.framework");
|
||||
const rpc = require("web.rpc");
|
||||
const session = require("web.session");
|
||||
const { _t } = require('web.translation');
|
||||
const utils = require("web.utils");
|
||||
|
||||
const qweb = new owl.QWeb({ translateFn: _t });
|
||||
@@ -131,7 +132,6 @@ odoo.define("web.env", function (require) {
|
||||
// See https://github.com/odoo/owl/blob/master/doc/reference/environment.md#content-of-an-environment
|
||||
// for more information on environments.
|
||||
return {
|
||||
_lt,
|
||||
_t,
|
||||
bus,
|
||||
dataManager,
|
||||
|
||||
@@ -3,9 +3,7 @@ odoo.define('web.basic_fields_owl', function (require) {
|
||||
|
||||
const AbstractField = require('web.AbstractFieldOwl');
|
||||
const CustomCheckbox = require('web.CustomCheckbox');
|
||||
const core = require('web.core');
|
||||
|
||||
const _lt = core._lt;
|
||||
const { _lt } = require('web.translation');
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -34,7 +34,6 @@ odoo.define('web.test_env', async function (require) {
|
||||
let testEnv = {};
|
||||
const defaultEnv = {
|
||||
_t: env._t || Object.assign((s => s), { database }),
|
||||
_lt: env._lt || Object.assign((s => s), { database }),
|
||||
bus: new Bus(),
|
||||
device: Object.assign({ isMobile: false }, env.device),
|
||||
isDebug: env.isDebug || (() => false),
|
||||
|
||||
Reference in New Issue
Block a user