From ac7776663b801414f7a4e96c49eeab3ca92c659d Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Sun, 14 Aug 2022 14:35:09 +0200 Subject: [PATCH 1/2] [fix] typo in get_engine_locale Due to a typo in get_engine_locale, a language selection like `!qw :de siemens` did not work. Signed-off-by: Markus Heiser --- searx/locales.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/searx/locales.py b/searx/locales.py index a7c037aa0..b7c0badd9 100644 --- a/searx/locales.py +++ b/searx/locales.py @@ -217,7 +217,7 @@ def get_engine_locale(searxng_locale, engine_locales, default=None): locale = babel.Locale.parse(searxng_locale, sep='-') except babel.core.UnknownLocaleError: try: - locale = babel.Locale.parse(searxng_locale.split('-')[1]) + locale = babel.Locale.parse(searxng_locale.split('-')[0]) except babel.core.UnknownLocaleError: return default From de1e7d12f706a4845b8941f7797ef886024a75cb Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Sun, 14 Aug 2022 15:45:07 +0200 Subject: [PATCH 2/2] [fix] get_engine_locale: better approximation of 'en' is 'en-US' Compared to `en-EN` the better approximation of 'en' is 'en-US'. Signed-off-by: Markus Heiser --- searx/locales.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/searx/locales.py b/searx/locales.py index b7c0badd9..0e57c91b0 100644 --- a/searx/locales.py +++ b/searx/locales.py @@ -252,8 +252,12 @@ def get_engine_locale(searxng_locale, engine_locales, default=None): terr_lang_dict[territory] = langs.get(searxng_lang) # first: check fr-FR, de-DE .. is supported by the engine + # exception: 'en' --> 'en-US' territory = locale.language.upper() + if territory == 'EN': + territory = 'US' + if terr_lang_dict.get(territory): searxng_locale = locale.language + '-' + territory engine_locale = engine_locales.get(searxng_locale)