Compare commits

..

3 Commits

Author SHA1 Message Date
Markus Heiser ee3c5e7752
Merge pull request #1666 from return42/harden-get_engine_locales
[fix] typo in get_engine_locale
2022-08-21 08:22:29 +02:00
Markus Heiser de1e7d12f7 [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 <markus.heiser@darmarit.de>
2022-08-14 15:45:07 +02:00
Markus Heiser ac7776663b [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 <markus.heiser@darmarit.de>
2022-08-14 14:35:09 +02:00
1 changed files with 5 additions and 1 deletions

View File

@ -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)