0

I have a python web application with jinja2 templates. I am using pybabel for localization. When using the pybabel extract command, it exports everything exactly as intended, EXCEPT for any files which use the jinja2 autoescape tag.

My babel.cfg file has the following line:

extensions=jinja2.ext.autoescape,jinja2.ext.with_

And the extract command I am using is:

pybabel extract -F ./babel.cfg -o ./locale/messages.pot ./

I have a file called settings.html, which has the following tag:

{% autoescape false %}
{% endautoescape %}

And pybabel lists this file in the console, in the list of files it extracts from:

extracting messages from templates/cfg/settings.html

But, when I check my pot file, there are no translations from settings.html.

If I delete the autoescape tag from settings.html, then re-run the pybabel extract command, then it correctly extracts the translations.

So there must be something up with use of autoescape.

Any clues?

desertnaut
  • 57,590
  • 26
  • 140
  • 166
Gwyn Howell
  • 5,365
  • 2
  • 31
  • 48
  • This is an old question but I had a similar problem and it turned out that not all the Jinja2 extensions I used were in my babel.cfg. Did you make sure that they were all included? (except for i18n) – Arnaud May 19 '16 at 13:05
  • Yep, they were all included. Actually, it was a typo in the config file. – Gwyn Howell May 19 '16 at 13:07

0 Answers0