summaryrefslogtreecommitdiff
path: root/searx/query.py
diff options
context:
space:
mode:
authorAdam Tauber <asciimoo@gmail.com>2016-12-28 20:09:57 +0100
committerGitHub <noreply@github.com>2016-12-28 20:09:57 +0100
commit9743bde25ef2ce6b765b8192aafcdc0a15739b17 (patch)
tree00fd6b0b14773c0e20425d4a6478d67f244d64ed /searx/query.py
parentea034fafa994227ea89662710901e73cb901e28c (diff)
parent8bff42f049dcac77559beaf2932a47921feb1d49 (diff)
Merge pull request #748 from a01200356/languages
[mod] Allow users to search in most engine supported languages
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: