summaryrefslogtreecommitdiff
path: root/searx/engines/translated.py
diff options
context:
space:
mode:
authorpotato <mail@crazypotato.tk>2016-09-06 16:43:48 +0200
committerpotato <mail@crazypotato.tk>2016-09-06 16:43:48 +0200
commit983415bc38937a637e9b2aae191f2e087765800b (patch)
tree30a166d7cd791f4d38d961b43f35f9daeca0d2f2 /searx/engines/translated.py
parentb7d578ae8041658fe6f088eb337f42238c25e2f5 (diff)
downloadsearxng-983415bc38937a637e9b2aae191f2e087765800b.tar.gz
searxng-983415bc38937a637e9b2aae191f2e087765800b.zip
[enh] is_valid_lang moved to utils
Diffstat (limited to 'searx/engines/translated.py')
-rw-r--r--searx/engines/translated.py16
1 files changed, 1 insertions, 15 deletions
diff --git a/searx/engines/translated.py b/searx/engines/translated.py
index 1b75e4f4e..3a077ae8e 100644
--- a/searx/engines/translated.py
+++ b/searx/engines/translated.py
@@ -13,7 +13,7 @@ from urlparse import urljoin
from lxml import html
from cgi import escape
from searx.engines.xpath import extract_text
-from searx.languages import language_codes
+from searx.utils import is_valid_lang
categories = ['general']
url = 'http://api.mymemory.translated.net/get?q={query}' \
@@ -25,20 +25,6 @@ parser_re = re.compile(u'.*?([a-z]+)-([a-z]+) (.{2,})$', re.I)
api_key = ''
-def is_valid_lang(lang):
- is_abbr = (len(lang) == 2)
- if is_abbr:
- for l in language_codes:
- if l[0][:2] == lang.lower():
- return (True, l[0][:2], l[1].lower())
- return False
- else:
- for l in language_codes:
- if l[1].lower() == lang.lower():
- return (True, l[0][:2], l[1].lower())
- return False
-
-
def request(query, params):
m = parser_re.match(unicode(query, 'utf8'))
if not m: