summaryrefslogtreecommitdiff
path: root/searx/locales.py
diff options
context:
space:
mode:
Diffstat (limited to 'searx/locales.py')
-rw-r--r--searx/locales.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/searx/locales.py b/searx/locales.py
index 3d14fe6e8..e3c8a89e5 100644
--- a/searx/locales.py
+++ b/searx/locales.py
@@ -35,13 +35,14 @@ from babel.support import Translations
import babel.languages
import babel.core
import flask_babel
-import flask
from flask.ctx import has_request_context
+
from searx import (
data,
logger,
searx_dir,
)
+from searx.extended_types import sxng_request
logger = logger.getChild('locales')
@@ -85,13 +86,13 @@ Kong."""
def localeselector():
locale = 'en'
if has_request_context():
- value = flask.request.preferences.get_value('locale')
+ value = sxng_request.preferences.get_value('locale')
if value:
locale = value
# first, set the language that is not supported by babel
if locale in ADDITIONAL_TRANSLATIONS:
- flask.request.form['use-translation'] = locale
+ sxng_request.form['use-translation'] = locale
# second, map locale to a value python-babel supports
locale = LOCALE_BEST_MATCH.get(locale, locale)
@@ -109,7 +110,7 @@ def localeselector():
def get_translations():
"""Monkey patch of :py:obj:`flask_babel.get_translations`"""
if has_request_context():
- use_translation = flask.request.form.get('use-translation')
+ use_translation = sxng_request.form.get('use-translation')
if use_translation in ADDITIONAL_TRANSLATIONS:
babel_ext = flask_babel.current_app.extensions['babel']
return Translations.load(babel_ext.translation_directories[0], use_translation)