Jinja2 i18n problem: UndefinedError: 'gettext' is undefined

246 views
Skip to first unread message

Honghai

unread,
Nov 25, 2008, 7:37:07 AM11/25/08
to Django users
Hi there,

I tried a very simple test to check the Jinja2 i18n, here is the code
(it is pretty much the same as the translate.py from jinja2):

from jinja2 import Environment

print Environment(extensions=['jinja2.ext.i18n']).from_string("""\
{% trans %}Hello {{ user }}!{% endtrans %}
{% trans count=users|count %}{{ count }} user{% pluralize %}
{{ count }} users{% endtrans %}
""").render(user="someone")

but I got the following error:


Traceback (most recent call last):
File "D:\Tools\jinja2\examples\basic\translate.py", line 6, in
<module>
""").render(user="someone")
File "<template>", line 1, in top-level template code
File "c:\python25\lib\site-packages\Jinja2-2.1dev_20081117-py2.5.egg
\jinja2\runtime.py", line 132, in call
return __obj(*args, **kwargs)
File "c:\python25\lib\site-packages\Jinja2-2.1dev_20081117-py2.5.egg
\jinja2\runtime.py", line 403, in _fail_with_undefined_error
raise self._undefined_exception(hint)
jinja2.exceptions.UndefinedError: 'gettext' is undefined

Can someone help me out? Thanks a lot!

cheers,

Honghai
Reply all
Reply to author
Forward
0 new messages