Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to Python-Babel 3.0.0 #1550

Closed
wants to merge 2 commits into from
Closed

Update to Python-Babel 3.0.0 #1550

wants to merge 2 commits into from

Conversation

ethhics
Copy link

@ethhics ethhics commented Feb 21, 2023

A couple of weeks ago, the Python-Babel dependency release version 3.0.0 which contains a breaking change for fava.
This PR changes fava's usage to support the new syntax.

Fixes #1549

I am a small-time contributor who just wants to get this fixed; if you want to add to this PR and/or want me to make modifications, that's all fine

In version 2.x, Babel stores information only for the most recent app;
this prevents multiple apps from using the same Babel instance (see python-babel/flask-babel#107).
To add support for multiple apps, Babel 3.x moves locale selection into per-app state,
which requires a change from the previous function decoration syntax for selecting locale.

Annoyingly, the new syntax is not supported in any 2.x release, which means that either we'll have to trust that the 3.x babel branch works (all tests pass, so that's good), or we'll have to modify this PR to support 2.x or 3.x based on the installed version.

The 3.0.0 release of Babel changes the syntax for specifying a locale_selector.
In 2.x, Babel stores information only for the most recent app;
this prevents multiple apps from using the same Babel instance (see python-babel/flask-babel#107).
To add support for multiple apps, Babel 3.x moves locale selection into state,
and the previous function decoration syntax was removed.

Fortunately for fava, all this means is we need to change how we attach `get_locale()` to Babel.
It's a simple, two-line change.
@ethhics ethhics changed the title Update to Python-Babel 3.0.0 (Fixes #1549) Update to Python-Babel 3.0.0 Feb 21, 2023
@yagebu
Copy link
Member

yagebu commented Feb 21, 2023

Thanks for the PR. I've added two branches to support both older and the new version.

Closed by d61295c

@yagebu yagebu closed this Feb 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

AttributeError with flask-babel 3
2 participants