summaryrefslogtreecommitdiff
path: root/npybabel.py
diff options
context:
space:
mode:
authorniv-openerp <nicolas.vanhoren@openerp.com>2011-08-16 13:34:00 +0200
committerniv-openerp <nicolas.vanhoren@openerp.com>2011-08-16 13:34:00 +0200
commitf713807311f84d2534bba1084b9839363f466dc3 (patch)
tree6dbd5c5b12fa25c3aa4fe1a858e9e49ee153b197 /npybabel.py
parentbe46b05129b13d70e30056973cdcc143e2728dc7 (diff)
[imp] improved wqweb scanning for translations
bzr revid: nicolas.vanhoren@openerp.com-20110816113400-f1laiorv1nx58yo9
Diffstat (limited to 'npybabel.py')
-rwxr-xr-xnpybabel.py14
1 files changed, 10 insertions, 4 deletions
diff --git a/npybabel.py b/npybabel.py
index 0c79e5d7d1e..3d9deaec676 100755
--- a/npybabel.py
+++ b/npybabel.py
@@ -4,14 +4,17 @@ __requires__ = 'Babel==0.9.6'
import sys
from pkg_resources import load_entry_point
import re
+import json
if __name__ == '__main__':
sys.exit(
load_entry_point('Babel==0.9.6', 'console_scripts', 'pybabel')()
)
-QWEB_EXPR = re.compile(r"""(?:\< *t\-tr *\>(.*?)\< *\/t\-tr *\>)|(?:\_t *\( *((?:\".*?\")|(?:\'.*?\')) *\))""")
-
+QWEB_EXPR = re.compile(r"""(?:\< *t\-tr *\>(.*?)\< *\/t\-tr *\>)|(?:\_t *\( *((?:"(?:[^"\\]|\\.)*")|(?:'(?:[^'\\]|\\.)*')) *\))""")
+XML_GROUP = 1
+JS_GROUP = 2
+
def extract_qweb(fileobj, keywords, comment_tags, options):
"""Extract messages from XXX files.
:param fileobj: the file-like object the messages should be extracted
@@ -31,10 +34,13 @@ def extract_qweb(fileobj, keywords, comment_tags, options):
index = 0
line_nbr = 0
for f in found:
- group = 1 if f.group(1) else 2
+ group = XML_GROUP if f.group(XML_GROUP) else JS_GROUP
+ mes = f.group(group)
+ if group == JS_GROUP:
+ mes = json.loads(mes)
while index < f.start():
if content[index] == "\n":
line_nbr += 1
index += 1
- result.append((line_nbr, None, f.group(group), ""))
+ result.append((line_nbr, None, mes, ""))
return result