summaryrefslogtreecommitdiff
path: root/searx/query.py
diff options
context:
space:
mode:
authormarc <a01200356@itesm.mx>2016-08-05 23:34:56 -0500
committermarc <a01200356@itesm.mx>2016-12-13 19:32:00 -0600
commit149802c56926bf48520c98932c4c36b8152b3d2d (patch)
treef450a584a785c31a1c118be29b3039f779a0cb70 /searx/query.py
parente58949b76fac7aa93341523ff0e2f35e0a03e057 (diff)
downloadsearxng-149802c56926bf48520c98932c4c36b8152b3d2d.tar.gz
searxng-149802c56926bf48520c98932c4c36b8152b3d2d.zip
[enh] add supported_languages on engines and auto-generate languages.py
Diffstat (limited to 'searx/query.py')
-rw-r--r--searx/query.py11
1 files changed, 7 insertions, 4 deletions
diff --git a/searx/query.py b/searx/query.py
index b8afba6ed..dcef1924d 100644
--- a/searx/query.py
+++ b/searx/query.py
@@ -71,21 +71,24 @@ class RawTextQuery(object):
# check if any language-code is equal with
# declared language-codes
for lc in language_codes:
- lang_id, lang_name, country = map(str.lower, lc)
+ lang_id, lang_name, country, english_name = map(unicode.lower, lc)
# if correct language-code is found
# set it as new search-language
if lang == lang_id\
or lang_id.startswith(lang)\
or lang == lang_name\
+ or lang == english_name\
or lang.replace('_', ' ') == country:
parse_next = True
- self.languages.append(lang)
- break
+ self.languages.append(lang_id)
+ # to ensure best match (first match is not necessarily the best one)
+ if lang == lang_id:
+ break
# this force a engine or category
if query_part[0] == '!' or query_part[0] == '?':
- prefix = query_part[1:].replace('_', ' ')
+ prefix = query_part[1:].replace('-', ' ')
# check if prefix is equal with engine shortcut
if prefix in engine_shortcuts: