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['BABEL_DEFAULT_LOCALE'] = 'en'
|
||||
|
||||
app.config['BABEL_TRANSLATION_DIRECTORIES'] = "./language/translations"
|
||||
babel = Babel(app)
|
||||
|
||||
db.init_app(app)
|
||||
|
||||
@babel.localeselector
|
||||
def get_locale():
|
||||
# if a user is logged in, use the locale from the user settings
|
||||
user = getattr(g, 'user', None)
|
||||
if user is not None:
|
||||
return user.locale
|
||||
elif session['lang']:
|
||||
if not session.get('lang') is None:
|
||||
return session['lang']
|
||||
# otherwise try to guess the language from the user accept
|
||||
# header the browser transmits. We support fr/en in this
|
||||
|
|
Loading…
Reference in New Issue