diff options
| author | Christophe Simonis <chs@odoo.com> | 2019-01-08 11:52:15 +0100 |
|---|---|---|
| committer | Christophe Simonis <chs@odoo.com> | 2019-01-08 11:52:15 +0100 |
| commit | b50883d17b6d10acd3ef776b1ef6bb857b442236 (patch) | |
| tree | 7966306506d1d75fec9d8c90e5c313f9f1a3aca1 /odoo/tools/translate.py | |
| parent | 27a084eb814acd81679db1e461c53389d6afc875 (diff) | |
| parent | c07b7200b26d5bcac032338ee2912bc96e4d2195 (diff) | |
[MERGE] forward port branch 11.0 up to c07b7200b26
Diffstat (limited to 'odoo/tools/translate.py')
| -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 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: |
