summaryrefslogtreecommitdiff
path: root/odoo/tools/translate.py
diff options
context:
space:
mode:
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 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: