浏览代码

[enh] gettext in self ip plugin

Adam Tauber 10 年前
父节点
当前提交
13ea0a20ae
共有 1 个文件被更改,包括 6 次插入2 次删除
  1. 6
    2
      searx/plugins/self_ip.py

+ 6
- 2
searx/plugins/self_ip.py 查看文件

1
-
1
+from flask.ext.babel import gettext
2
 name = "Self IP"
2
 name = "Self IP"
3
-description = "Display your source IP address"
3
+description = gettext('Display your source IP address if the query expression is "ip"')
4
 default_on = True
4
 default_on = True
5
 
5
 
6
 
6
 
7
+# attach callback to the pre search hook
8
+#  request: flask request object
9
+#  ctx: the whole local context of the pre search hook
7
 def pre_search(request, ctx):
10
 def pre_search(request, ctx):
8
     if ctx['search'].query == 'ip':
11
     if ctx['search'].query == 'ip':
9
         x_forwarded_for = request.headers.getlist("X-Forwarded-For")
12
         x_forwarded_for = request.headers.getlist("X-Forwarded-For")
13
             ip = request.remote_addr
16
             ip = request.remote_addr
14
         ctx['search'].answers.clear()
17
         ctx['search'].answers.clear()
15
         ctx['search'].answers.add(ip)
18
         ctx['search'].answers.add(ip)
19
+        # return False prevents exeecution of the original block
16
         return False
20
         return False
17
     return True
21
     return True