Skip to content
Snippets Groups Projects
Commit 669b6f7b authored by Martin Trigaux's avatar Martin Trigaux Committed by Raphael Collet
Browse files

[FIX] tools: less strict evaluation of translations

Do not parse the translation of an attribute value.  The content of a
translatable node attribute (such as 'string') should not be tested for
XML/HTML validity: the value can contain special chars such as `&` in its
source and should not be escaped when evaluated.

This fixes escaped page title in the partner form
`Sales & Purchases` => `Ventes & Achats`
parent 47bb1bd2
No related branches found
No related tags found
No related merge requests found
......@@ -219,6 +219,12 @@ class XMLTranslator(object):
text = text.replace(term, trans)
return text
def process_attr(self, attr):
""" Translate the given node attribute value. """
term = attr.strip()
trans = term and self.callback(term)
return attr.replace(term, trans) if trans else attr
def process(self, node):
""" Process the given xml `node`: collect `todo` and `done` items. """
if (
......@@ -249,7 +255,7 @@ class XMLTranslator(object):
# complete translations and serialize result as done
for attr in TRANSLATED_ATTRS:
if node.get(attr):
node.set(attr, self.process_text(node.get(attr)))
node.set(attr, self.process_attr(node.get(attr)))
self.done(self.serialize(node.tag, node.attrib, child_trans.get_done()))
# add node tail as todo
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment