[imp] improved wqweb scanning for translations
bzr revid: nicolas.vanhoren@openerp.com-20110816113400-f1laiorv1nx58yo9
This commit is contained in:
parent
be46b05129
commit
f713807311
12
npybabel.py
12
npybabel.py
|
@ -4,13 +4,16 @@ __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.
|
||||
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue