diff --git a/cps/__init__.py b/cps/__init__.py index d9980778..9d8cfa92 100644 --- a/cps/__init__.py +++ b/cps/__init__.py @@ -36,7 +36,7 @@ from .reverseproxy import ReverseProxied from .server import WebServer from .dep_check import dependency_check from .updater import Updater -from .babel import babel +from .babel import babel, get_locale from . import config_sql from . import cache_buster from . import ub, db @@ -156,8 +156,11 @@ def create_app(): app.secret_key = os.getenv('SECRET_KEY', config_sql.get_flask_session_key(ub.session)) web_server.init_app(app, config) - - babel.init_app(app) + if hasattr(babel, "localeselector"): + babel.init_app(app) + babel.localeselector(get_locale) + else: + babel.init_app(app, locale_selector=get_locale) from . import services diff --git a/cps/babel.py b/cps/babel.py index 4da808bc..5a6136a5 100644 --- a/cps/babel.py +++ b/cps/babel.py @@ -9,8 +9,6 @@ log = logger.create() babel = Babel() - -@babel.localeselector def get_locale(): # if a user is logged in, use the locale from the user settings user = getattr(g, 'user', None) diff --git a/requirements.txt b/requirements.txt index ba37df7e..04941f30 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,7 +1,7 @@ APScheduler>=3.6.3,<3.10.0 werkzeug<2.1.0 Babel>=1.3,<3.0 -Flask-Babel>=0.11.1,<2.1.0 +Flask-Babel>=0.11.1,<3.1.0 Flask-Login>=0.3.2,<0.6.3 Flask-Principal>=0.3.2,<0.5.1 backports_abc>=0.4 @@ -11,10 +11,10 @@ PyPDF>=3.0.0,<3.3.0 pytz>=2016.10 requests>=2.11.1,<2.28.0 SQLAlchemy>=1.3.0,<1.5.0 -tornado>=4.1,<6.2 +tornado>=4.1,<6.3 Wand>=0.4.4,<0.7.0 unidecode>=0.04.19,<1.4.0 lxml>=3.8.0,<5.0.0 -flask-wtf>=0.14.2,<1.1.0 +flask-wtf>=0.14.2,<1.2.0 chardet>=3.0.0,<4.1.0 advocate>=1.0.0,<1.1.0