mirror of
https://github.com/searxng/searxng.git
synced 2025-07-12 07:49:22 +02:00
refactor engine's search language handling
Add match_language function in utils to match any user given language code with a list of engine's supported languages. Also add language_aliases dict on each engine to translate standard language codes into the custom codes used by the engine.
This commit is contained in:
parent
d1eae9359f
commit
772c048d01
42 changed files with 275 additions and 171 deletions
|
@ -96,9 +96,13 @@ class RawTextQuery(object):
|
|||
break
|
||||
|
||||
# user may set a valid, yet not selectable language
|
||||
if not self.languages and VALID_LANGUAGE_CODE.match(lang):
|
||||
self.languages.append(lang)
|
||||
parse_next = True
|
||||
if VALID_LANGUAGE_CODE.match(lang):
|
||||
lang_parts = lang.split('-')
|
||||
if len(lang_parts) > 1:
|
||||
lang = lang_parts[0].lower() + '-' + lang_parts[1].upper()
|
||||
if lang not in self.languages:
|
||||
self.languages.append(lang)
|
||||
parse_next = True
|
||||
|
||||
# this force a engine or category
|
||||
if query_part[0] == '!' or query_part[0] == '?':
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue