diff options
author | Markus Heiser <markus.heiser@darmarIT.de> | 2022-08-21 08:22:29 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-21 08:22:29 +0200 |
commit | ee3c5e7752ced3735187f54576ed49ae190fd339 (patch) | |
tree | 28459a78e969b1551abb671f6915bb13762f0aec | |
parent | 0ceb2563d233f618ae29c2568acd1bc80bcc58dc (diff) | |
parent | de1e7d12f706a4845b8941f7797ef886024a75cb (diff) | |
download | searxng-ee3c5e7752ced3735187f54576ed49ae190fd339.tar.gz searxng-ee3c5e7752ced3735187f54576ed49ae190fd339.zip |
Merge pull request #1666 from return42/harden-get_engine_locales
[fix] typo in get_engine_locale
-rw-r--r-- | searx/locales.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/searx/locales.py b/searx/locales.py index a7c037aa0..0e57c91b0 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 @@ -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) |