From bcb7335027e447f2fde441ed8e857e7fa9760461 Mon Sep 17 00:00:00 2001 From: "P. Christeas" Date: Wed, 29 Dec 2010 13:33:34 +0200 Subject: [PATCH] tools/translate: don't export comments and PI nodes for translation We are not going to display them to user, so let the teams skip those strings. bzr revid: p_christ@hol.gr-20101229113334-71fe2bnw1dra167q --- bin/tools/translate.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/bin/tools/translate.py b/bin/tools/translate.py index 8cf09f96fef..6b7a0600956 100644 --- a/bin/tools/translate.py +++ b/bin/tools/translate.py @@ -468,12 +468,16 @@ def trans_export(lang, modules, buffer, format, dbname=None): _process(format, modules, trans, buffer, lang, newlang) del trans +# We'd better not import orm here, so copy this from osv.orm: +SKIPPED_ELEMENT_TYPES = (etree._Comment, etree._ProcessingInstruction, etree.CommentBase, etree.PIBase) def trans_parse_xsl(de): res = [] for n in de: if n.get("t"): - for m in [j for j in n if j.text]: + for m in n: + if isinstance(m, SKIPPED_ELEMENT_TYPES) or not m.text: + continue l = m.text.strip().replace('\n',' ') if len(l): res.append(l.encode("utf8")) @@ -483,7 +487,9 @@ def trans_parse_xsl(de): def trans_parse_rml(de): res = [] for n in de: - for m in [j for j in n if j.text]: + for m in n: + if isinstance(m, SKIPPED_ELEMENT_TYPES) or not m.text: + continue string_list = [s.replace('\n', ' ').strip() for s in re.split('\[\[.+?\]\]', m.text)] for s in string_list: if s: