summaryrefslogtreecommitdiff
path: root/odoo/tools/translate.py
diff options
context:
space:
mode:
authorChristophe Simonis <chs@odoo.com>2019-01-08 11:52:15 +0100
committerChristophe Simonis <chs@odoo.com>2019-01-08 11:52:15 +0100
commitb50883d17b6d10acd3ef776b1ef6bb857b442236 (patch)
tree7966306506d1d75fec9d8c90e5c313f9f1a3aca1 /odoo/tools/translate.py
parent27a084eb814acd81679db1e461c53389d6afc875 (diff)
parentc07b7200b26d5bcac032338ee2912bc96e4d2195 (diff)
[MERGE] forward port branch 11.0 up to c07b7200b26
Diffstat (limited to 'odoo/tools/translate.py')
-rw-r--r--odoo/tools/translate.py15
1 files changed, 5 insertions, 10 deletions
diff --git a/odoo/tools/translate.py b/odoo/tools/translate.py
index 59d882d84e6..cfa4cac05a3 100644
--- a/odoo/tools/translate.py
+++ b/odoo/tools/translate.py
@@ -159,7 +159,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 "")
@@ -251,7 +251,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
@@ -811,14 +814,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: