packages/searxng: revert flask-babel 2.0.0 -> 3.0.0 bump
This commit is contained in:
parent
30e92d89c8
commit
858384b0a7
3 changed files with 109 additions and 0 deletions
|
@ -11,6 +11,11 @@ toPythonModule (buildPythonApplication rec {
|
|||
|
||||
src = npins.mkSource pins.searxng;
|
||||
|
||||
patches = [
|
||||
# wait for https://github.com/NixOS/nixpkgs/pull/211654
|
||||
./revert-flask-babel-3.0.0.patch
|
||||
];
|
||||
|
||||
postPatch = ''
|
||||
sed -i \
|
||||
-e 's/==.*$//' \
|
||||
|
|
55
packages/web-apps/searxng/fp
Normal file
55
packages/web-apps/searxng/fp
Normal file
|
@ -0,0 +1,55 @@
|
|||
diff --git a/requirements.txt b/requirements.txt
|
||||
index 2de33f4baa..947a88433f 100644
|
||||
--- a/requirements.txt
|
||||
+++ b/requirements.txt
|
||||
@@ -1,6 +1,6 @@
|
||||
certifi==2022.12.7
|
||||
babel==2.11.0
|
||||
-flask-babel==2.0.0
|
||||
+flask-babel==3.0.0
|
||||
flask==2.2.2
|
||||
jinja2==3.1.2
|
||||
lxml==4.9.2
|
||||
diff --git a/searx/locales.py b/searx/locales.py
|
||||
index 8547e7fa7b..9e06bf39d4 100644
|
||||
--- a/searx/locales.py
|
||||
+++ b/searx/locales.py
|
||||
@@ -86,7 +86,7 @@ def get_translations():
|
||||
use_translation = flask.request.form.get('use-translation')
|
||||
if use_translation in ADDITIONAL_TRANSLATIONS:
|
||||
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()
|
||||
|
||||
|
||||
diff --git a/searx/webapp.py b/searx/webapp.py
|
||||
index d4206ca16b..d9ca3941cd 100755
|
||||
--- a/searx/webapp.py
|
||||
+++ b/searx/webapp.py
|
||||
@@ -160,8 +160,6 @@
|
||||
app.jinja_env.filters['group_engines_in_tab'] = group_engines_in_tab # pylint: disable=no-member
|
||||
app.secret_key = settings['server']['secret_key']
|
||||
|
||||
-babel = Babel(app)
|
||||
-
|
||||
timeout_text = gettext('timeout')
|
||||
parsing_error_text = gettext('parsing error')
|
||||
http_protocol_error_text = gettext('HTTP protocol error')
|
||||
@@ -211,13 +209,15 @@ class ExtendedRequest(flask.Request):
|
||||
request = typing.cast(ExtendedRequest, flask.request)
|
||||
|
||||
|
||||
-@babel.localeselector
|
||||
def get_locale():
|
||||
locale = localeselector()
|
||||
logger.debug("%s uses locale `%s`", urllib.parse.quote(request.url), locale)
|
||||
return locale
|
||||
|
||||
|
||||
+babel = Babel(app, locale_selector=get_locale)
|
||||
+
|
||||
+
|
||||
def _get_browser_language(req, lang_list):
|
||||
for lang in req.headers.get("Accept-Language", "en").split(","):
|
||||
if ';' in lang:
|
49
packages/web-apps/searxng/revert-flask-babel-3.0.0.patch
Normal file
49
packages/web-apps/searxng/revert-flask-babel-3.0.0.patch
Normal file
|
@ -0,0 +1,49 @@
|
|||
--- b/requirements.txt
|
||||
+++ a/requirements.txt
|
||||
@@ -1,6 +1,6 @@
|
||||
certifi==2022.12.7
|
||||
babel==2.11.0
|
||||
+flask-babel==2.0.0
|
||||
-flask-babel==3.0.0
|
||||
flask==2.2.2
|
||||
jinja2==3.1.2
|
||||
lxml==4.9.2
|
||||
--- b/searx/locales.py
|
||||
+++ a/searx/locales.py
|
||||
@@ -86,7 +86,7 @@
|
||||
use_translation = flask.request.form.get('use-translation')
|
||||
if use_translation in ADDITIONAL_TRANSLATIONS:
|
||||
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()
|
||||
|
||||
|
||||
--- b/searx/webapp.py
|
||||
+++ a/searx/webapp.py
|
||||
@@ -160,6 +160,8 @@
|
||||
app.jinja_env.filters['group_engines_in_tab'] = group_engines_in_tab # pylint: disable=no-member
|
||||
app.secret_key = settings['server']['secret_key']
|
||||
|
||||
+babel = Babel(app)
|
||||
+
|
||||
timeout_text = gettext('timeout')
|
||||
parsing_error_text = gettext('parsing error')
|
||||
http_protocol_error_text = gettext('HTTP protocol error')
|
||||
@@ -209,15 +211,13 @@
|
||||
request = typing.cast(ExtendedRequest, flask.request)
|
||||
|
||||
|
||||
+@babel.localeselector
|
||||
def get_locale():
|
||||
locale = localeselector()
|
||||
logger.debug("%s uses locale `%s`", urllib.parse.quote(request.url), locale)
|
||||
return locale
|
||||
|
||||
|
||||
-babel = Babel(app, locale_selector=get_locale)
|
||||
-
|
||||
-
|
||||
def _get_browser_language(req, lang_list):
|
||||
for lang in req.headers.get("Accept-Language", "en").split(","):
|
||||
if ';' in lang:
|
Loading…
Reference in a new issue