Fix translation
This commit is contained in:
parent
899487245d
commit
a760e2fabc
8
app.py
8
app.py
|
@ -22,18 +22,14 @@ app.config['SQLALCHEMY_DATABASE_URI'] = database_uri
|
||||||
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
|
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
|
||||||
|
|
||||||
app.config['BABEL_DEFAULT_LOCALE'] = 'en'
|
app.config['BABEL_DEFAULT_LOCALE'] = 'en'
|
||||||
|
app.config['BABEL_TRANSLATION_DIRECTORIES'] = "./language/translations"
|
||||||
babel = Babel(app)
|
babel = Babel(app)
|
||||||
|
|
||||||
db.init_app(app)
|
db.init_app(app)
|
||||||
|
|
||||||
@babel.localeselector
|
@babel.localeselector
|
||||||
def get_locale():
|
def get_locale():
|
||||||
# if a user is logged in, use the locale from the user settings
|
if not session.get('lang') is None:
|
||||||
user = getattr(g, 'user', None)
|
|
||||||
if user is not None:
|
|
||||||
return user.locale
|
|
||||||
elif session['lang']:
|
|
||||||
return session['lang']
|
return session['lang']
|
||||||
# otherwise try to guess the language from the user accept
|
# otherwise try to guess the language from the user accept
|
||||||
# header the browser transmits. We support fr/en in this
|
# header the browser transmits. We support fr/en in this
|
||||||
|
|
Loading…
Reference in New Issue