summaryrefslogtreecommitdiff
path: root/searx/search.py
diff options
context:
space:
mode:
authorasciimoo <asciimoo@gmail.com>2014-02-09 11:12:58 +0100
committerasciimoo <asciimoo@gmail.com>2014-02-09 11:12:58 +0100
commit7c031a3ea6393e520a04ed56d6f6e1d6b0fcf76b (patch)
treeb81378361b24319bf3eef3bea97075767ac76412 /searx/search.py
parentd11a873d4012b2aaa710b8aa4a3300de4c01c324 (diff)
downloadsearxng-7c031a3ea6393e520a04ed56d6f6e1d6b0fcf76b.tar.gz
searxng-7c031a3ea6393e520a04ed56d6f6e1d6b0fcf76b.zip
[enh] better search language selection from query
Diffstat (limited to 'searx/search.py')
-rw-r--r--searx/search.py15
1 files changed, 12 insertions, 3 deletions
diff --git a/searx/search.py b/searx/search.py
index 09ec14f05..79a82f0b1 100644
--- a/searx/search.py
+++ b/searx/search.py
@@ -79,11 +79,20 @@ class Search(object):
modified = False
if query_parts[0].startswith(':'):
lang = query_parts[0][1:]
- if lang in (x[0] for x in language_codes):
- self.lang = lang
- modified = True
+
+ for lc in language_codes:
+ lang_id, lang_name, country = map(str.lower, lc)
+ if lang == lang_id\
+ or lang_id.startswith(lang)\
+ or lang == lang_name\
+ or lang == country:
+ self.lang = lang
+ modified = True
+ break
+
elif query_parts[0].startswith('!'):
prefix = query_parts[0][1:].replace('_', ' ')
+
if prefix in engine_shortcuts\
and not engine_shortcuts[prefix] in self.blocked_engines:
modified = True