3

I am using jinja 2.10 and pybabel. When my template contains following code (with '%' char inside trans block) pybabel-compile does not translate the string. The extracted string (in .po) is OK but on the result page it is not translated at all.

<h3 class="title">{% trans %}100% anonymity{% endtrans %}</h3>

This code works but the trans-syntax looks better:

<h3 class="title">{{ _("100%% anonymity") }}</h3>

Also I cannot my bother my translating colleagues with using '%%' instead of '%'.

Machavity
  • 30,841
  • 27
  • 92
  • 100
Mirek
  • 41
  • 2

2 Answers2

0

Another way: {% trans percent='%' %}100{{ percent }} anonymity{% endtrans %}

vvkatwss vvkatwss
  • 3,345
  • 1
  • 21
  • 24
-1

I had stuck about this too, but I found in Babel documentation the solution:

##flask.ext.babel.gettext(string, **variables)##
##Translates a string with the current locale and passes in the given keyword arguments as mapping to a string formatting string.

gettext(u'Hello World!')
gettext(u'Hello %(name)s!', name='World')

And I translate to simple code like this:

_('Hello %(name)s!', name='World%')

I hope I help you :D