Server IP : 51.89.169.208 / Your IP : 216.73.216.178 Web Server : Apache System : Linux ns3209505.ip-198-244-202.eu 4.18.0-553.27.1.el8_10.x86_64 #1 SMP Tue Nov 5 04:50:16 EST 2024 x86_64 User : yellowleaf ( 1019) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /proc/self/root/proc/self/root/usr/share/doc/python3-jinja2/examples/basic/ |
Upload File : |
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])