diff options
author | Alexandre Flament <alex@al-f.net> | 2021-10-21 10:41:57 +0200 |
---|---|---|
committer | Alexandre Flament <alex@al-f.net> | 2021-10-26 10:27:05 +0200 |
commit | 60db344cc0715eab4d03dad5629f4c47954c466c (patch) | |
tree | ed933547df3bc250d1cac558cb37be0f6b9ba93a /searx/query.py | |
parent | dfdf71bf08d48332a30ff982dcc8b4ac499d9c8d (diff) | |
download | searxng-60db344cc0715eab4d03dad5629f4c47954c466c.tar.gz searxng-60db344cc0715eab4d03dad5629f4c47954c466c.zip |
[enh] reduce the available language list
close #406
settings['search']['languages'] contains the languages codes and 'all'
Diffstat (limited to 'searx/query.py')
-rw-r--r-- | searx/query.py | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/searx/query.py b/searx/query.py index 2e6a2aa4c..7f252e93f 100644 --- a/searx/query.py +++ b/searx/query.py @@ -3,6 +3,7 @@ from abc import abstractmethod, ABC import re +from searx import settings from searx.languages import language_codes from searx.engines import categories, engines, engine_shortcuts from searx.external_bang import get_bang_definition_and_autocomplete @@ -120,11 +121,17 @@ class LanguageParser(QueryPartParser): def _autocomplete(self, value): if not value: # show some example queries - for lang in [":en", ":en_us", ":english", ":united_kingdom"]: - self.raw_text_query.autocomplete_list.append(lang) + if len(settings['search']['languages']) < 10: + for lang in settings['search']['languages']: + self.raw_text_query.autocomplete_list.append(':' + lang) + else: + for lang in [":en", ":en_us", ":english", ":united_kingdom"]: + self.raw_text_query.autocomplete_list.append(lang) return for lc in language_codes: + if lc[0] not in settings['search']['languages']: + continue lang_id, lang_name, country, english_name = map(str.lower, lc) # check if query starts with language-id |