D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
proc
/
thread-self
/
root
/
usr
/
share
/
doc
/
python2-jinja2
/
examples
/
basic
/
Filename :
translate.py
back
Copy
from jinja2 import Environment 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", users=[1, 2, 3])
Name
Size
Last Modified
Owner
Permissions
Actions
templates
Dir
May 29 2024 3:43:04
root
0755
cycle.py
0.271
KB
January 06 2017 3:24:25
root
0644
debugger.py
0.218
KB
January 06 2017 3:24:25
root
0644
inheritance.py
0.333
KB
January 06 2017 3:24:25
root
0644
test.py
0.598
KB
January 06 2017 3:24:25
root
0644
test_filter_and_linestatements.py
0.436
KB
January 06 2017 3:24:25
root
0644
test_loop_filter.py
0.289
KB
January 06 2017 3:24:25
root
0644
translate.py
0.512
KB
January 06 2017 3:24:25
root
0644
2017 © D7net | D704T team