summaryrefslogtreecommitdiff
path: root/searx
diff options
context:
space:
mode:
authorNoémi Ványi <sitbackandwait@gmail.com>2020-04-15 23:24:12 +0200
committerNoémi Ványi <sitbackandwait@gmail.com>2020-04-17 23:39:48 +0200
commitba7c8d7b960c3a3f288db162a51b76a2a935a605 (patch)
tree20c815730573318b6bd6b2092faa77a308537970 /searx
parent826ef3d00959f22a57224fa5e69fb088583f0072 (diff)
downloadsearxng-ba7c8d7b960c3a3f288db162a51b76a2a935a605.tar.gz
searxng-ba7c8d7b960c3a3f288db162a51b76a2a935a605.zip
[fix] remove usage of request context where not available
Diffstat (limited to 'searx')
-rwxr-xr-xsearx/webapp.py11
1 files changed, 5 insertions, 6 deletions
diff --git a/searx/webapp.py b/searx/webapp.py
index c910230ab..9d76d8441 100755
--- a/searx/webapp.py
+++ b/searx/webapp.py
@@ -56,6 +56,7 @@ from flask import (
from babel.support import Translations
import flask_babel
from flask_babel import Babel, gettext, format_date, format_decimal
+from flask.ctx import has_request_context
from flask.json import jsonify
from searx import brand
from searx import settings, searx_dir, searx_debug
@@ -165,13 +166,11 @@ _flask_babel_get_translations = flask_babel.get_translations
# monkey patch for flask_babel.get_translations
def _get_translations():
- translation_locale = request.form.get('use-translation')
- if translation_locale:
+ if has_request_context() and request.form.get('use-translation') == 'oc':
babel_ext = flask_babel.current_app.extensions['babel']
- translation = Translations.load(next(babel_ext.translation_directories), 'oc')
- else:
- translation = _flask_babel_get_translations()
- return translation
+ return Translations.load(next(babel_ext.translation_directories), 'oc')
+
+ return _flask_babel_get_translations()
flask_babel.get_translations = _get_translations