From: Armin Ronacher Date: Thu, 7 Jul 2011 13:42:25 +0000 (+0200) Subject: Fixed a broken example. This fies #45 X-Git-Tag: 2.6~6 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=ff115c4e7b2015604fb19a9528e936277cabad15;p=jinja2.git Fixed a broken example. This fies #45 --- diff --git a/examples/basic/translate.py b/examples/basic/translate.py index 3358765..1fb8ee6 100644 --- a/examples/basic/translate.py +++ b/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])