[FIX] translate: do not translate <!DOCTYPE>
Avoid the DOCTYPE tranlation. If this tag is changed, the html rendering is altered. The other effet is that the web_editor wrap the content with <span> to translate, but some explorer eject tags (doctype, head content, script, style, meta) et insert this tags in the body. NB: DOCTYPE is not a node but a text.
This commit is contained in:
@@ -151,6 +151,8 @@ TRANSLATED_ATTRS = {
|
||||
'string', 'help', 'sum', 'avg', 'confirm', 'placeholder', 'alt', 'title',
|
||||
}
|
||||
|
||||
avoid_pattern = re.compile(r"[\s\n]*<!DOCTYPE", re.IGNORECASE)
|
||||
|
||||
class XMLTranslator(object):
|
||||
""" A sequence of serialized XML/HTML items, with some of them to translate
|
||||
(todo) and others already translated (done). The purpose of this object
|
||||
@@ -241,7 +243,8 @@ class XMLTranslator(object):
|
||||
|
||||
# process children nodes locally in child_trans
|
||||
child_trans = XMLTranslator(self.callback, self.method, parser=self.parser)
|
||||
child_trans.todo(escape(node.text or ""))
|
||||
if node.text and not avoid_pattern.match(node.text):
|
||||
child_trans.todo(escape(node.text))
|
||||
for child in node:
|
||||
child_trans.process(child)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user