-
Notifications
You must be signed in to change notification settings - Fork 155
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
'Babel' object has no attribute 'load_locale': Babelex not compatible when app is using flask_babel #353
Comments
I havent seen babelplus before - and looks like he just re-started updating that package - that is great news since Flask-BabelEx has basically been abandoned. |
I have flask-babel installed, trying to move to this security-too repo but then stuck at finding out what to do with my translations (which I do not really like to change as well).
|
Ahh yes - flask-security needs a flask-babelex interface (which as you point out has been problematic since it isn't supported). Flask-Babel isn't enough since it doesn't support multiple domains. Multiple folks have tried to cajole the Flask-Babel maintainers to backport the domain changes - but so far they haven't. Here's something to try - after installing flask-security-too - uninstall Flask-BabelEx and install Flask-BabelPlus. I haven't really looked into how to support flask-babel directly (which might require the application to copy all the Flask-Security translations into their own. Any ideas would be welcome - I would love to get rid of the Flask-BabelEx dependency.. |
What works (on a dev environment, so not really heavily tested) is to uninstall flask-babel and flask-babelex So not really going back to babel, but getting it working with a recently updated module. |
Thanks! I'll look into making the change so applications can choose babelEx or bableplus... |
Flask-Babel just released with support for the Domain feature from Flask-BabelEx... Yea! 4.0 will use that. |
Great. It would still be nice though to inc;lude an optional load of babelplus. Something like |
I am building an app and using flask_babel for translations.
Trying out your security version (which seems the only one maintained, thanks) but am hitting an issue with first use:
Been reading up a bit and I think this is due to the impossibility for the flask-babels to work from two installations (domains):
mrjoes/flask-babelex#16
I encountered this fork, which promises to be able to use more than one domain:
https://flask-babelplus.readthedocs.io/en/latest/
https://github.com/sh4nks/flask-babelplus
Have you tried it with that one instead of Babelex?
Part of the error generated:
''' File "/home/michelv/.local/share/virtualenvs/localshare-CVNR5Qnw/lib/python3.7/site-packages/flask/app.py", line 1821, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/home/michelv/.local/share/virtualenvs/localshare-CVNR5Qnw/lib/python3.7/site-packages/flask/_compat.py", line 39, in reraise
raise value
File "/home/michelv/.local/share/virtualenvs/localshare-CVNR5Qnw/lib/python3.7/site-packages/flask/app.py", line 1950, in full_dispatch_request
rv = self.dispatch_request()
File "/home/michelv/.local/share/virtualenvs/localshare-CVNR5Qnw/lib/python3.7/site-packages/flask/app.py", line 1936, in dispatch_request
return self.view_functionsrule.endpoint
File "/home/michelv/.local/share/virtualenvs/localshare-CVNR5Qnw/lib/python3.7/site-packages/flask_login/utils.py", line 271, in decorated_view
return current_app.login_manager.unauthorized()
File "/home/michelv/.local/share/virtualenvs/localshare-CVNR5Qnw/lib/python3.7/site-packages/flask_login/login_manager.py", line 162, in unauthorized
flash(self.localize_callback(self.login_message),
File "/home/michelv/.local/share/virtualenvs/localshare-CVNR5Qnw/lib/python3.7/site-packages/werkzeug/local.py", line 375, in
call = lambda x, *a, **kw: x._get_current_object()(*a, **kw)
File "/home/michelv/.local/share/virtualenvs/localshare-CVNR5Qnw/lib/python3.7/site-packages/flask_babelex/init.py", line 533, in gettext
t = self.get_translations()
File "/home/michelv/.local/share/virtualenvs/localshare-CVNR5Qnw/lib/python3.7/site-packages/flask_babelex/init.py", line 510, in get_translations
locale = get_locale()
File "/home/michelv/.local/share/virtualenvs/localshare-CVNR5Qnw/lib/python3.7/site-packages/flask_babelex/init.py", line 224, in get_locale
locale = babel.load_locale(rv)
AttributeError: 'Babel' object has no attribute 'load_locale''''
The text was updated successfully, but these errors were encountered: