python-babel / flask-babel

i18n and l10n support for Flask based on Babel and pytz
https://python-babel.github.io/flask-babel/
Other
432 stars 159 forks source link

Babel cannot find words in flask_caching blocks #208

Closed serkin closed 1 year ago

serkin commented 1 year ago

If I have html file content like

<html>
{% cache 3600, request.url %}
<tag>{{ _('h1') }}</tag>
{% endcache %}
</html>

And run pybabel extract -F babel.cfg -k _l -o translations/messages.pot .

Flask Babel cannot find new words in {% cache %} block

TkTech commented 1 year ago

Extraction is not handled by flask-babel, we're just the glue. Jinja2 registers a babel extractor plugin here, https://github.com/pallets/jinja/blob/main/setup.cfg#L44, which ultimately calls https://github.com/pallets/jinja/blob/main/src/jinja2/ext.py#L644.

Either Jinja2 or flask_caching need to add support for the {% cache %} tag.