-
-
Notifications
You must be signed in to change notification settings - Fork 159
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
Incompatible with multiple apps with different translations #107
Comments
For reference, Flask-SQLAlchemy implements a |
The same goes for FYI, Flask-SQLAlchemy and Flask-Mail store app specific states in |
…e them all in a typed config objects pinned to a specific app. (#107)
Hi, I am trying out version 3.0 that was just released and am hitting the deprecation in
What is the recomended approach to use instead of above, to be compatible with Flask-Babel v3.0? Thanks! EDIT: As best I can tell, before the upgrade with the old decorator, this EDIT2: Sorry, my mistake. I found the answer digging into the diffs made to the documentation above. Leaving the answer for any others who hit this on upgrade to v3.0. My old code:
Changed to work with Flask-Babel v3.0:
|
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.
Flask-Babel stores an app instance in
self.app
, which will be set ininit_app()
regardless. This means that using the same Babel instance with multiple apps (each app runningbabel_instance.init_app(app)
doesn't work as expected: Only the translations from the last app configured will be used.The text was updated successfully, but these errors were encountered: