summaryrefslogtreecommitdiff
path: root/npybabel.py
diff options
context:
space:
mode:
authorOlivier Dony <odo@openerp.com>2012-02-07 19:22:55 +0100
committerOlivier Dony <odo@openerp.com>2012-02-07 19:22:55 +0100
commitdf0b4f8c3546755f0df3590f3edfd87fa75889de (patch)
treea604575d75a010cddaee33ec6e42dc4ba1f41a96 /npybabel.py
parentb33f8d708798e9e4a1c0bf1f00976cec53b86e36 (diff)
[IMP] i18n extractor now ignores comments and PIs + additional spurious translations removed
PO templates updated accordingly bzr revid: odo@openerp.com-20120207182255-23s4yp4hrteierht
Diffstat (limited to 'npybabel.py')
-rwxr-xr-xnpybabel.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/npybabel.py b/npybabel.py
index 8b582e17e5a..6759a4a6166 100755
--- a/npybabel.py
+++ b/npybabel.py
@@ -17,6 +17,10 @@ XMLJS_EXPR = re.compile(r"""(?:\_t *\( *((?:"(?:[^"\\]|\\.)*")|(?:'(?:[^'\\]|\\.
TRANSLATION_FLAG_COMMENT = "openerp-web"
+# List of etree._Element subclasses that we choose to ignore when parsing XML.
+# We include the *Base ones just in case, currently they seem to be subclasses of the _* ones.
+SKIPPED_ELEMENT_TYPES = (elt._Comment, elt._ProcessingInstruction, elt.CommentBase, elt.PIBase)
+
def extract_xmljs(fileobj, keywords, comment_tags, options):
"""Extract messages from Javascript code embedded into XML documents.
This complements the ``extract_javascript`` extractor which works
@@ -70,6 +74,7 @@ def extract_qweb(fileobj, keywords, comment_tags, options):
# the ancestor element had a reason to be skipped
def iter_elements(current_element):
for el in current_element:
+ if isinstance(el, SKIPPED_ELEMENT_TYPES): continue
if "t-js" not in el.attrib and \
not ("t-jquery" in el.attrib and "t-operation" not in el.attrib) and \
not ("t-translation" in el.attrib and el.attrib["t-translation"].strip() == "off"):