forked from zaclys/searxng
Merge pull request #2115 from searxng/dependabot/pip/master/flask-babel-3.0.0
Bump flask-babel from 2.0.0 to 3.0.0
This commit is contained in:
commit
28356f4284
|
@ -1,6 +1,6 @@
|
||||||
certifi==2022.12.7
|
certifi==2022.12.7
|
||||||
babel==2.11.0
|
babel==2.11.0
|
||||||
flask-babel==2.0.0
|
flask-babel==3.0.0
|
||||||
flask==2.2.2
|
flask==2.2.2
|
||||||
jinja2==3.1.2
|
jinja2==3.1.2
|
||||||
lxml==4.9.2
|
lxml==4.9.2
|
||||||
|
|
|
@ -86,7 +86,7 @@ def get_translations():
|
||||||
use_translation = flask.request.form.get('use-translation')
|
use_translation = flask.request.form.get('use-translation')
|
||||||
if use_translation in ADDITIONAL_TRANSLATIONS:
|
if use_translation in ADDITIONAL_TRANSLATIONS:
|
||||||
babel_ext = flask_babel.current_app.extensions['babel']
|
babel_ext = flask_babel.current_app.extensions['babel']
|
||||||
return Translations.load(next(babel_ext.translation_directories), use_translation)
|
return Translations.load(babel_ext.translation_directories[0], use_translation)
|
||||||
return _flask_babel_get_translations()
|
return _flask_babel_get_translations()
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -160,8 +160,6 @@ app.jinja_env.add_extension('jinja2.ext.loopcontrols') # pylint: disable=no-mem
|
||||||
app.jinja_env.filters['group_engines_in_tab'] = group_engines_in_tab # pylint: disable=no-member
|
app.jinja_env.filters['group_engines_in_tab'] = group_engines_in_tab # pylint: disable=no-member
|
||||||
app.secret_key = settings['server']['secret_key']
|
app.secret_key = settings['server']['secret_key']
|
||||||
|
|
||||||
babel = Babel(app)
|
|
||||||
|
|
||||||
timeout_text = gettext('timeout')
|
timeout_text = gettext('timeout')
|
||||||
parsing_error_text = gettext('parsing error')
|
parsing_error_text = gettext('parsing error')
|
||||||
http_protocol_error_text = gettext('HTTP protocol error')
|
http_protocol_error_text = gettext('HTTP protocol error')
|
||||||
|
@ -211,13 +209,15 @@ class ExtendedRequest(flask.Request):
|
||||||
request = typing.cast(ExtendedRequest, flask.request)
|
request = typing.cast(ExtendedRequest, flask.request)
|
||||||
|
|
||||||
|
|
||||||
@babel.localeselector
|
|
||||||
def get_locale():
|
def get_locale():
|
||||||
locale = localeselector()
|
locale = localeselector()
|
||||||
logger.debug("%s uses locale `%s`", urllib.parse.quote(request.url), locale)
|
logger.debug("%s uses locale `%s`", urllib.parse.quote(request.url), locale)
|
||||||
return locale
|
return locale
|
||||||
|
|
||||||
|
|
||||||
|
babel = Babel(app, locale_selector=get_locale)
|
||||||
|
|
||||||
|
|
||||||
def _get_browser_language(req, lang_list):
|
def _get_browser_language(req, lang_list):
|
||||||
for lang in req.headers.get("Accept-Language", "en").split(","):
|
for lang in req.headers.get("Accept-Language", "en").split(","):
|
||||||
if ';' in lang:
|
if ';' in lang:
|
||||||
|
|
Loading…
Reference in New Issue