Skip to content
Permalink
Browse files

[FIX] base: ignore empty translatable attribute

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
  • Loading branch information...
mart-e committed Mar 21, 2019
1 parent f7acbf6 commit f6ae39214d54f8b3ebc7c95dbc3802f958a49b02
Showing with 14 additions and 1 deletion.
  1. +13 −0 odoo/addons/base/tests/test_translate.py
  2. +1 −1 odoo/tools/translate.py
@@ -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 = []
@@ -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((name in TRANSLATED_ATTRS and len(result.attrib[name])) for name in result.attrib)
)
return (has_text, result)

0 comments on commit f6ae392

Please sign in to comment.
You can’t perform that action at this time.