Saturday, 15 August 2015

python - Babel and jinja2 with coffin extension -



python - Babel and jinja2 with coffin extension -

i'm trying translate jinja2/coffin template babel using command line tool. issue function babel_extract jams on coffin tags {% url %} or {% csrf_token %}.

first, observe problem, have modify jinja.ext.babel_extract , added "print e" on exceptions while rendering.

try: node = environment.parse(source) tokens = list(environment.lex(environment.preprocess(source))) except templatesyntaxerror, e: # skip templates syntax errors print e homecoming

when run extract method babel, print out error:

encountered unknown tag 'url'. jinja looking next tags: 'endblock'. innermost block needs closed 'block'. extracting messages templates/contact.html (encoding="utf-8")

then have edit babel config add together coffin library. have set environements variables add together django project python path , set django settings module settings.py.

[python: src/**.py] [jinja2: templates/**.html] encoding = utf-8 extensions = coffin.template.library [extractors] jinja2 = jinja2.ext:babel_extract

now, when run extract method, error happens:

extracting messages templates/brands.html (extensions="coffin.template.library", encoding="utf-8") traceback (most recent phone call last): file "/usr/local/bin/pybabel", line 9, in <module> load_entry_point('babel==0.9.6', 'console_scripts', 'pybabel')() file "/library/python/2.7/site-packages/babel-0.9.6-py2.7.egg/babel/messages/frontend.py", line 1107, in main homecoming commandlineinterface().run(sys.argv) file "/library/python/2.7/site-packages/babel-0.9.6-py2.7.egg/babel/messages/frontend.py", line 651, in run homecoming getattr(self, cmdname)(args[1:]) file "/library/python/2.7/site-packages/babel-0.9.6-py2.7.egg/babel/messages/frontend.py", line 912, in extract filename, lineno, message, comments in extracted: file "/library/python/2.7/site-packages/babel-0.9.6-py2.7.egg/babel/messages/extract.py", line 171, in extract_from_dir strip_comment_tags): file "/library/python/2.7/site-packages/babel-0.9.6-py2.7.egg/babel/messages/extract.py", line 201, in extract_from_file strip_comment_tags)) file "/library/python/2.7/site-packages/babel-0.9.6-py2.7.egg/babel/messages/extract.py", line 275, in extract lineno, funcname, messages, comments in results: file "/library/python/2.7/site-packages/jinja2/ext.py", line 588, in babel_extract auto_reload=false file "/library/python/2.7/site-packages/jinja2/environment.py", line 279, in __init__ self.extensions = load_extensions(self, extensions) file "/library/python/2.7/site-packages/jinja2/environment.py", line 76, in load_extensions result[extension.identifier] = extension(environment) typeerror: __init__() takes 1 argument (2 given)

python django babel coffin

No comments:

Post a Comment