Skip to content

Commit

Permalink
[FIX] base: ignore empty translatable attribute
Browse files Browse the repository at this point in the history
Complete cd40808
  <span class="fa fa-globe" title="Title stuff"/>
is not correctly extracted but
  <span class="fa fa-globe" title=""/>
was also extracted while there is no content

Check the size of the content too

Similar content is present on odoo.com website and should not be translatable
on Transifex

closes #32018

Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
  • Loading branch information
mart-e committed Mar 21, 2019
1 parent 4a13d5d commit 4814311
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
13 changes: 13 additions & 0 deletions odoo/addons/base/tests/test_translate.py
Expand Up @@ -131,6 +131,19 @@ def test_translate_xml_inline4(self):
self.assertItemsEqual(terms,
['Form stuff', '<span class="fa fa-globe" title="Title stuff"/>'])

def test_translate_xml_inline5(self):
""" Test xml_translate() with inline elements with empty translated attrs only. """
terms = []
source = """<form string="Form stuff">
<div>
<label for="stuff"/>
<span class="fa fa-globe" title=""/>
</div>
</form>"""
result = xml_translate(terms.append, source)
self.assertEquals(result, source)
self.assertItemsEqual(terms, ['Form stuff'])

def test_translate_xml_t(self):
""" Test xml_translate() with t-* attributes. """
terms = []
Expand Down
2 changes: 1 addition & 1 deletion odoo/tools/translate.py
Expand Up @@ -257,7 +257,7 @@ def process(node):
result.tail = node.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)
or any((key in TRANSLATED_ATTRS and val) for key, val in result.attrib.items())
)
return (has_text, result)

Expand Down

0 comments on commit 4814311

Please sign in to comment.