babel can't extract text from template with "with" statement #668

zfdang opened this Issue Jan 18, 2013 · 10 comments


None yet
5 participants

zfdang commented Jan 18, 2013

my template has the following code:

{% with messages = get_flashed_messages() %}
  {% if messages %}
  <div class="alert alert-info">
    <a class="close" data-dismiss="alert">&times;</a>
    {% for message in messages %}
      <li>{{ message }}</li>
    {% endfor %}
  {% endif %}
{% endwith %}

but pybabel can't extract text from this file unless I remove the {% with %} statement.

is there any mistake I made in this case?


untitaker commented Jan 21, 2013

Jinja2 doesn't have a with statement. This doesn't have anything to do with Flask or any plugins of it.

interru commented Jan 23, 2013

Jinja2 does have a with statement: ;)


untitaker commented Jan 23, 2013

I have no idea how i missed that. Sorry.


untitaker commented Jan 23, 2013

@Dantifer, do you still have this problem? Which errors do you get?

interru commented Jan 23, 2013

Did you use flask-babel and have you created a babel.cfg file which contents are similiar to the following?

[python: **.py]
[jinja2: **/templates/**.html]

zfdang commented Jan 24, 2013

yes, I have the babel.cfg file, but I did not add the extensions.
after adding the extensions, the with statement can work correctly now. so
it's my fault, but a bug.

thanks for your help!

On Wed, Jan 23, 2013 at 11:16 PM, Mathias Köhler

Did you use flask-babel and
have you created a babel.cfg file which contents are similiar to the

[python: **.py]
[jinja2: /templates/.html]

Reply to this email directly or view it on GitHub



mitsuhiko closed this Jan 27, 2013

My application templates folder structure :


when I extract files, babel doesn't extract files which in templates/website/_layouts/main.html. If I change file name from templates/website/_layouts/main.html to templates/website/layouts/main.html babel extract this file.


[python: **.py]
[jinja2: **/templates/**.html]

mitsuhiko commented Nov 3, 2015

I think babel ignores folders with leading underscores.

babel extract files in "templates/app/_parts/" but it doesn't extract files in "templates/app/_layouts/" and "templates/website/_layouts/". Does babel have a problem with "_layouts" word?

screen shot 2015-11-04 at 11 14 30


mitsuhiko commented Nov 4, 2015

Maybe you can make a testcase for this and open a new ticket.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment