mirror of
https://github.com/searxng/searxng.git
synced 2024-11-18 08:51:06 +00:00
[fix] engine startpage: fetch_traits() / if lang name unknown by babel
Workflow "Update data - update_engine_traits.py" fails last night [1]. This issue has already been reported by @allendema [2]. [1] https://github.com/searxng/searxng/actions/runs/9278028691/job/25528337485#step:6:168 [2] https://github.com/searxng/searxng/pull/3504/files#r1613559565 Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
This commit is contained in:
parent
8713aa6c4b
commit
a20dfbbcbd
1 changed files with 8 additions and 5 deletions
|
@ -78,6 +78,7 @@ Startpage's category (for Web-search, News, Videos, ..) is set by
|
|||
yet implemented.
|
||||
|
||||
"""
|
||||
# pylint: disable=too-many-statements
|
||||
|
||||
from typing import TYPE_CHECKING
|
||||
from collections import OrderedDict
|
||||
|
@ -88,7 +89,7 @@ from datetime import datetime, timedelta
|
|||
|
||||
import dateutil.parser
|
||||
import lxml.html
|
||||
import babel
|
||||
import babel.localedata
|
||||
|
||||
from searx.utils import extract_text, eval_xpath, gen_useragent
|
||||
from searx.network import get # see https://github.com/searxng/searxng/issues/762
|
||||
|
@ -439,10 +440,12 @@ def fetch_traits(engine_traits: EngineTraits):
|
|||
|
||||
# get the native name of every language known by babel
|
||||
|
||||
for lang_code in filter(
|
||||
lambda lang_code: lang_code.find('_') == -1, babel.localedata.locale_identifiers() # type: ignore
|
||||
):
|
||||
native_name = babel.Locale(lang_code).get_language_name().lower() # type: ignore
|
||||
for lang_code in filter(lambda lang_code: lang_code.find('_') == -1, babel.localedata.locale_identifiers()):
|
||||
native_name = babel.Locale(lang_code).get_language_name()
|
||||
if not native_name:
|
||||
print(f"ERROR: language name of startpage's language {lang_code} is unknown by babel")
|
||||
continue
|
||||
native_name = native_name.lower()
|
||||
# add native name exactly as it is
|
||||
catalog_engine2code[native_name] = lang_code
|
||||
|
||||
|
|
Loading…
Reference in a new issue