1
0
mirror of https://github.com/LibreTranslate/LibreTranslate.git synced 2024-12-18 08:27:03 +02:00

Fix compatibility with flask-babel v3+

Babel.locale_selector was removed in 3.0.0
This commit is contained in:
misuzu 2023-04-27 19:21:04 +03:00
parent df8c1b4b21
commit 0f8952fd10
2 changed files with 4 additions and 3 deletions

View File

@ -1079,14 +1079,15 @@ def create_app(args):
return jsonify(lazy_swag(swag))
app.config["BABEL_TRANSLATION_DIRECTORIES"] = 'locales'
babel = Babel(app)
@babel.localeselector
def get_locale():
override_lang = request.headers.get('X-Override-Accept-Language')
if override_lang and override_lang in get_available_locale_codes():
return override_lang
return session.get('preferred_lang', request.accept_languages.best_match(get_available_locale_codes()))
babel = Babel(app, locale_selector=get_locale)
app.jinja_env.globals.update(_e=gettext_escaped, _h=gettext_html)
# Call factory function to create our blueprint

View File

@ -3,7 +3,7 @@ Flask==2.2.2
flask-swagger==0.2.14
flask-swagger-ui==4.11.1
Flask-Limiter==2.6.3
Flask-Babel==2.0.0
Flask-Babel==3.1.0
Flask-Session==0.4.0
waitress==2.1.2
expiringdict==1.2.2