[ADD] Web client now support template translations

bzr revid: fme@openerp.com-20111020091619-1i2nhopdgszsy48q
This commit is contained in:
Fabien Meghazi 2011-10-20 11:16:19 +02:00
parent 8e34b97b09
commit 278955b207
2 changed files with 16 additions and 3 deletions

View File

@ -10,8 +10,6 @@ if (!console.debug) {
}
openerp.web.core = function(openerp) {
openerp.web.qweb = new QWeb2.Engine();
openerp.web.qweb.debug = (window.location.search.indexOf('?debug') !== -1);
/**
* John Resig Class with factory improvement
*/
@ -1040,6 +1038,21 @@ openerp.web.TranslationDataBase = openerp.web.Class.extend(/** @lends openerp.we
});
openerp.web._t = new openerp.web.TranslationDataBase().build_translation_function();
openerp.web.qweb = new QWeb2.Engine();
openerp.web.qweb.debug = (window.location.search.indexOf('?debug') !== -1);
openerp.web.qweb.format_text_node = function(s) {
// Note that 'this' is the Qweb Node of the text
var translation = this.node.parentElement.attributes['t-translation'];
if (translation && translation.value === 'off') {
return s;
}
var ts = _.trim(s);
if (ts.length === 0) {
return s;
}
var tr = openerp.web._t(ts);
return tr === ts ? s : tr;
}
};

View File

@ -54,7 +54,7 @@ def extract_qweb(fileobj, keywords, comment_tags, options):
for el in current_element:
if "t-js" not in el.attrib and \
not ("t-jquery" in el.attrib and "t-operation" not in el.attrib) and \
not ("t-trad" in el.attrib and el.attrib["t-trad"].strip() == "off"):
not ("t-translation" in el.attrib and el.attrib["t-translation"].strip() == "off"):
handle_text(el.text)
iter_elements(el)
handle_text(el.tail)