diff options
| author | Christophe Simonis <chs@odoo.com> | 2019-01-08 17:08:48 +0100 |
|---|---|---|
| committer | Christophe Simonis <chs@odoo.com> | 2019-01-08 17:08:48 +0100 |
| commit | 3e4138deaa23b3631dc3fce33cd6d1b3be28ffbd (patch) | |
| tree | 8f8b5557363374af71baeeea97d4565a7ca1cce1 /odoo/tools | |
| parent | 232675c49b8cabdedce98b9b9c2ccc6d963b4d9a (diff) | |
| parent | 2d824a5b7ad9e2d834bb39feb79c986eba28d6cc (diff) | |
[MERGE] forward port branch saas-11.3 up to 2d824a5b7ad
Diffstat (limited to 'odoo/tools')
| -rw-r--r-- | odoo/tools/translate.py | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/odoo/tools/translate.py b/odoo/tools/translate.py index 28ded26eb79..ae552b6535e 100644 --- a/odoo/tools/translate.py +++ b/odoo/tools/translate.py @@ -163,7 +163,7 @@ def translate_xml_node(node, callback, parse, serialize): """ def nonspace(text): - return bool(text) and not text.isspace() + return bool(text) and len(re.sub(r'\W+', '', text)) > 1 def concat(text1, text2): return text2 if text1 is None else text1 + (text2 or "") @@ -255,7 +255,10 @@ def translate_xml_node(node, callback, parse, serialize): # complete result and return it append_content(result, todo) result.tail = node.tail - has_text = todo_has_text or nonspace(result.text) or nonspace(result.tail) + has_text = ( + todo_has_text or nonspace(result.text) or nonspace(result.tail) + or any(name in TRANSLATED_ATTRS for name in result.attrib) + ) return (has_text, result) # translate the content of todo and append it to result @@ -815,14 +818,6 @@ def trans_generate(lang, modules, cr): # empty and one-letter terms are ignored, they probably are not meant to be # translated, and would be very hard to translate anyway. sanitized_term = (source or '').strip() - try: - # verify the minimal size without eventual xml tags - # wrap to make sure html content like '<a>b</a><c>d</c>' is accepted by lxml - wrapped = u"<div>%s</div>" % sanitized_term - node = etree.fromstring(wrapped) - sanitized_term = etree.tostring(node, encoding='unicode', method='text') - except etree.ParseError: - pass # remove non-alphanumeric chars sanitized_term = re.sub(r'\W+', '', sanitized_term) if not sanitized_term or len(sanitized_term) <= 1: |
