summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/core/qweb.js
diff options
context:
space:
mode:
authorGéry Debongnie <ged@odoo.com>2017-12-18 14:43:27 +0100
committerGéry Debongnie <ged@odoo.com>2017-12-18 16:38:30 +0100
commit5e70e949d566269ae8df9ead7f8cc5aff790bbc0 (patch)
treea2c6988d2cf60ea0b05ab516b891a869ba30a0d2 /addons/web/static/src/js/core/qweb.js
parent2eb018002139a1061aef73cad005d89f47b9f9d7 (diff)
[FIX] web: prevent double translation in kanban view
The kanban view uses a template which comes from the server, already translated. Before this commit, it tried to retranslate again the template in qweb.js, which may be a problem (in addition to the useless work): if some english string A is translated in B (french), but B is also a valid english string which is translated into C in french, then we will have a wrong result. In this commit, we simply add a flag to disable the translation process, which should also slightly improve the kanban view rendering performance.
Diffstat (limited to 'addons/web/static/src/js/core/qweb.js')
-rw-r--r--addons/web/static/src/js/core/qweb.js15
1 files changed, 13 insertions, 2 deletions
diff --git a/addons/web/static/src/js/core/qweb.js b/addons/web/static/src/js/core/qweb.js
index 50742075e05..253e948d8ac 100644
--- a/addons/web/static/src/js/core/qweb.js
+++ b/addons/web/static/src/js/core/qweb.js
@@ -5,7 +5,18 @@ var translation = require('web.translation');
var _t = translation._t;
-function QWeb(debug, default_dict) {
+/**
+ * @param {boolean} debug
+ * @param {Object} default_dict
+ * @param {boolean} [enableTranslation=true] if true (this is the default),
+ * the rendering will translate all strings that are not marked with
+ * t-translation=off. This is useful for the kanban view, which uses a
+ * template which is already translated by the server
+ */
+function QWeb(debug, default_dict, enableTranslation) {
+ if (enableTranslation === undefined) {
+ enableTranslation = true;
+ }
var qweb = new QWeb2.Engine();
qweb.default_dict = _.extend({}, default_dict || {}, {
'_' : _,
@@ -16,7 +27,7 @@ function QWeb(debug, default_dict) {
'csrf_token': odoo.csrf_token,
});
qweb.debug = debug;
- qweb.preprocess_node = preprocess_node;
+ qweb.preprocess_node = enableTranslation ? preprocess_node : function () {};
return qweb;
}