Fix translation

This commit is contained in:
Samuel Ortion 2022-05-26 14:59:28 +02:00
parent 899487245d
commit a760e2fabc
1 changed files with 2 additions and 6 deletions

8
app.py
View File

@ -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