瀏覽代碼

[enh] language selection from query

asciimoo 11 年之前
父節點
當前提交
a641971a6f
共有 1 個檔案被更改,包括 6 行新增1 行删除
  1. 6
    1
      searx/search.py

+ 6
- 1
searx/search.py 查看文件

77
     def parse_query(self):
77
     def parse_query(self):
78
         query_parts = self.query.split()
78
         query_parts = self.query.split()
79
         modified = False
79
         modified = False
80
-        if query_parts[0].startswith('!'):
80
+        if query_parts[0].startswith(':'):
81
+            lang = query_parts[0][1:]
82
+            if lang in (x[0] for x in language_codes):
83
+                self.lang = lang
84
+                modified = True
85
+        elif query_parts[0].startswith('!'):
81
             prefix = query_parts[0][1:].replace('_', ' ')
86
             prefix = query_parts[0][1:].replace('_', ' ')
82
             if prefix in engine_shortcuts\
87
             if prefix in engine_shortcuts\
83
                and not engine_shortcuts[prefix] in self.blocked_engines:
88
                and not engine_shortcuts[prefix] in self.blocked_engines: