[FIX] translate: inline elements with translatable attributes only
This commit is contained in:
committed by
Martin Trigaux
parent
22637aadec
commit
cd4080839f
@@ -114,6 +114,20 @@ class TranslationToolsTestCase(unittest.TestCase):
|
|||||||
self.assertItemsEqual(terms,
|
self.assertItemsEqual(terms,
|
||||||
['Form stuff', 'Blah blah blah'])
|
['Form stuff', 'Blah blah blah'])
|
||||||
|
|
||||||
|
def test_translate_xml_inline4(self):
|
||||||
|
""" Test xml_translate() with inline elements with translated attrs only. """
|
||||||
|
terms = []
|
||||||
|
source = """<form string="Form stuff">
|
||||||
|
<div>
|
||||||
|
<label for="stuff"/>
|
||||||
|
<span class="fa fa-globe" title="Title stuff"/>
|
||||||
|
</div>
|
||||||
|
</form>"""
|
||||||
|
result = xml_translate(terms.append, source)
|
||||||
|
self.assertEquals(result, source)
|
||||||
|
self.assertItemsEqual(terms,
|
||||||
|
['Form stuff', '<span class="fa fa-globe" title="Title stuff"/>'])
|
||||||
|
|
||||||
def test_translate_xml_t(self):
|
def test_translate_xml_t(self):
|
||||||
""" Test xml_translate() with t-* attributes. """
|
""" Test xml_translate() with t-* attributes. """
|
||||||
terms = []
|
terms = []
|
||||||
|
|||||||
@@ -251,7 +251,10 @@ def translate_xml_node(node, callback, parse, serialize):
|
|||||||
# complete result and return it
|
# complete result and return it
|
||||||
append_content(result, todo)
|
append_content(result, todo)
|
||||||
result.tail = node.tail
|
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)
|
return (has_text, result)
|
||||||
|
|
||||||
# translate the content of todo and append it to result
|
# translate the content of todo and append it to result
|
||||||
|
|||||||
Reference in New Issue
Block a user