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

Translation not changing inside jinja2 array. #216

Closed thilojaeggi closed 1 year ago

thilojaeggi commented 1 year ago

I have the following array for generating my navigation items but when I change the language on my site (by changing the cookie) all the pages translate but the navigation items stay in the previous language.

I assume jinja2 is caching something here?

This is my array: {% set navigationbar = [ ('user.dash', ('Dash')), ('user.stats', ('Statistics')), ('user.automations', ('Automations')), ] -%}

TkTech commented 1 year ago

I'm going to suggest you post on the Jinja tracker. This isn't a flask-babel bug (we're just the glue). You may be able to work around this issue by using our lazygettext instead of , since in theory even if Jinja is caching this set the string should proxy at display time.

thilojaeggi commented 1 year ago

How do I use lazy_gettext in Jinja though? Do I need to add it manually?