translate.py
This file
Path
examples/basic/translate.py
14 lines · 524 bytes · Python
Last changed by
Fixed a broken example. This fies #45Armin Ronacherbefore adoptionff115c4
History of this fileTake it
The walk stopped after 200 commits: lines older than 6cc2b23 point at it.
Added benchmark for chameleon/chameleon-genshi.Rodrigo Moraesbefore adoption6cc2b23
lines 1–2why, one step back1from jinja2 import Environment2Fixed a broken example. This fies #45Armin Ronacherbefore adoptionff115c4
lines 3–11why, one step back3env = 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("""\Added benchmark for chameleon/chameleon-genshi.Rodrigo Moraesbefore adoption6cc2b23
lines 12–13why, one step back12{% trans %}Hello {{ user }}!{% endtrans %}13{% trans count=users|count %}{{ count }} user{% pluralize %}{{ count }} users{% endtrans %}Fixed a broken example. This fies #45Armin Ronacherbefore adoptionff115c4
line 14why, one step back14""").render(user="someone", users=[1, 2, 3])