Skip to content
Myr

Fixed a broken example. This fies #45

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Armin Ronacher · committed by Armin Ronacher · parent 1655b4e · Browse files · 1 file+10 added−2 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+10 added−2 removed

  • other:+10 added−2 removed

1 file+10 added−2 removed

modified:examples/basic/translate.py+10 added-2 removed
1from jinja2 import Environment23print Environment(extensions=['jinja2.i18n.TransExtension']).from_string("""\3env = Environment(extensions=['jinja2.ext.i18n'])4env.globals['gettext'] = {5 'Hello %(user)s!': 'Hallo %(user)s!'6}.__getitem__7env.globals['ngettext'] = lambda s, p, n: {8 '%(count)s user': '%(count)d Benutzer',9 '%(count)s users': '%(count)d Benutzer'10}[n == 1 and s or p]11print env.from_string("""\12{% trans %}Hello {{ user }}!{% endtrans %}13{% trans count=users|count %}{{ count }} user{% pluralize %}{{ count }} users{% endtrans %}6""").render(user="someone")14""").render(user="someone", users=[1, 2, 3])