Permalink
Browse files

Fixed a broken example. This fies #45

  • Loading branch information...
1 parent 1655b4e commit ff115c4e7b2015604fb19a9528e936277cabad15 @mitsuhiko mitsuhiko committed Jul 7, 2011
Showing with 10 additions and 2 deletions.
  1. +10 −2 examples/basic/translate.py
@@ -1,6 +1,14 @@
from jinja2 import Environment
-print Environment(extensions=['jinja2.i18n.TransExtension']).from_string("""\
+env = Environment(extensions=['jinja2.ext.i18n'])
+env.globals['gettext'] = {
+ 'Hello %(user)s!': 'Hallo %(user)s!'
+}.__getitem__
+env.globals['ngettext'] = lambda s, p, n: {
+ '%(count)s user': '%(count)d Benutzer',
+ '%(count)s users': '%(count)d Benutzer'
+}[n == 1 and s or p]
+print env.from_string("""\
{% trans %}Hello {{ user }}!{% endtrans %}
{% trans count=users|count %}{{ count }} user{% pluralize %}{{ count }} users{% endtrans %}
-""").render(user="someone")
+""").render(user="someone", users=[1, 2, 3])

0 comments on commit ff115c4

Please sign in to comment.