Skip to content
This repository has been archived by the owner on Aug 27, 2020. It is now read-only.

Not working with Flask-Babel? #13

Open
vincentwhales opened this issue Dec 17, 2017 · 1 comment
Open

Not working with Flask-Babel? #13

vincentwhales opened this issue Dec 17, 2017 · 1 comment

Comments

@vincentwhales
Copy link

I am using two extensions:

Flask-User (which uses Flask-Babel), and
Flask-Admin (which uses Flask-Babelex)

When I try to get i18n working for my application, I am seeing cryptic errors such as:

Traceback (most recent call last):
  File "/Users/vng/.virtualenvs/portal/lib/python2.7/site-packages/flask/app.py", line 1997, in __call__
    return self.wsgi_app(environ, start_response)
  File "/Users/vng/.virtualenvs/portal/lib/python2.7/site-packages/flask/app.py", line 1985, in wsgi_app
    response = self.handle_exception(e)
  File "/Users/vng/.virtualenvs/portal/lib/python2.7/site-packages/flask/app.py", line 1540, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "/Users/vng/.virtualenvs/portal/lib/python2.7/site-packages/flask/app.py", line 1982, in wsgi_app
    response = self.full_dispatch_request()
  File "/Users/vng/.virtualenvs/portal/lib/python2.7/site-packages/flask/app.py", line 1614, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/Users/vng/.virtualenvs/portal/lib/python2.7/site-packages/flask/app.py", line 1517, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/Users/vng/.virtualenvs/portal/lib/python2.7/site-packages/flask/app.py", line 1612, in full_dispatch_request
    rv = self.dispatch_request()
  File "/Users/vng/.virtualenvs/portal/lib/python2.7/site-packages/flask/app.py", line 1598, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/Users/vng/.virtualenvs/portal/lib/python2.7/site-packages/flask_user/views.py", line 293, in logout
    flash(_('You have signed out successfully.'), 'success')
  File "/Users/vng/.virtualenvs/portal/lib/python2.7/site-packages/flask_user/translations.py", line 51, in gettext
    translations = get_translations()
  File "/Users/vng/.virtualenvs/portal/lib/python2.7/site-packages/flask_user/translations.py", line 47, in get_translations
    return ctx.flask_user_translations.merge(babel.get_translations())
  File "/Users/vng/.virtualenvs/portal/lib/python2.7/site-packages/flask_babel/__init__.py", line 224, in get_translations
    for dirname in babel.translation_directories:
AttributeError: 'Babel' object has no attribute 'translation_directories'

Is there a guide to integrating both extensions at the same time?

@rnd0101
Copy link

rnd0101 commented Dec 22, 2017

Good question. Does anyone happen to know what is the overall situation of Flask-Babel vs Flask-BabelEx? Planning upgrade Flask app to all latest. Using Flask-Babel now, but seems like some Flask libraries qill require BabelEx (and as pointed above those are not compatible), plus force_locale missing from BabelEx. OTOH, BabelEx is not being actively developed (last commit almost a year ago), or is it?. I was even thinking to make some kind of BabelEx with force_locale, but not quite sure whether there is any perspective.

PS. You can probably get away by importing gettext from Flask-BabelEx instead of Flask-Babel, but I unfortunately can't.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants