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 'translation_directories' #111
Comments
Just in case someone find this useful: I had the same problem, but i tracked it down to an incorrect import of gettext (between flask-babel and flask-babelex). To reproduce the error : from flask import Flask
from flask_babelex import Babel
from flask_babel import gettext# <- This is incorrect, it should be imported from flask_babelex
app = Flask(__name__)
babel = Babel(app)
@app.route('/')
def hello_world():
return gettext("Hello World")
app.run() |
@jb-l Thank you so much for taking the time to post! |
I had just a similar problem but with babel.load_locale: |
My comment is a bit misleading : I don't think it is a Flask-Babel problem but it is more a problem for Flask-Babelex or on documentation of packages using Flask-Babelex. These problems appear when you start mixing Flask-Babel and Flask-Babelex (it seems that today Flask-Babelex is not API compatible with Flask-Babel) . Actually I started with your problem @Chamaeleon- (it took me some time to notice that Flask-Security relies on Flask-Babelex). |
@jb-l uh, Flask-Security uses Babelex? I wonderd why i got problems with mixing up Babelex and Babel, because i only use Babel in my code. |
Using Flask-Security, I had the same error:
I found out that I still used in one handwritten library
instead of
Now, I corrected this issue and it works fine. |
I have the exact same problem, but importing from flask_babelex didn't solve it. Does anyone have other suggestions? Update: scratch that. I forgot about Babel itself. This solves it for me
|
did you first uninstall babel or do you have babel and babelex installed. This could still cause issues just use bablex as recommended in the docks |
I am getting a:
'Babel' object has no attribute 'translation_directories'
error after updating Flask-Babel from 0.9 to 0.11.1.
I found a similar reference at https://github.com/airbnb/superset/issues/847 which claims the issue was flask extension compatibility related.
I have been looking for any sort of documentation that indicates what flask extensions have compatibility with one another, is it just assumed that the minor version (major.minor.build) must match to be compatible?
Here are my current application versions that are having the issue:
Babel (2.3.4)
Flask (0.11.1)
Flask-Babel (0.11.1)
Flask-BabelEx (0.9.3)
Flask-Compress (1.3.2)
Flask-Login (0.4.0)
itsdangerous (0.24)
Jinja2 (2.8)
MarkupSafe (0.23)
pytz (2016.7)
setuptools (28.8.0)
speaklater (1.3)
Werkzeug (0.11.11)
Again, all works with version 0.9 of flask-babel, just trying to understand if compatibility is the root cause or is there a real issue lurking.
The text was updated successfully, but these errors were encountered: