summaryrefslogtreecommitdiff
path: root/searx/utils.py
diff options
context:
space:
mode:
authorPydo <pydo@tutanota.com>2016-10-01 10:46:18 -0400
committerPydo <pydo@tutanota.com>2016-10-01 10:46:18 -0400
commit55a5b686ed6dc0b9a6bfc45e0eaf1f70e24f2aea (patch)
tree96e953057dd3fc29681039f7ac5b282dac189ee8 /searx/utils.py
parent6f87bf2a1c76f1b94ad2119df7fb938c2307e370 (diff)
parent295fc9ce96d8cca9c6c4776a00e5fb0942eb6f4d (diff)
Merge branch 'master' of https://github.com/asciimoo/searx into feature/seedpeer-engine-integration
Resolved conflict searx/settings.yml
Diffstat (limited to 'searx/utils.py')
-rw-r--r--searx/utils.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/searx/utils.py b/searx/utils.py
index 744142e36..b3806d3fd 100644
--- a/searx/utils.py
+++ b/searx/utils.py
@@ -9,6 +9,7 @@ from HTMLParser import HTMLParser
from random import choice
from searx.version import VERSION_STRING
+from searx.languages import language_codes
from searx import settings
from searx import logger
@@ -255,3 +256,17 @@ def get_torrent_size(filesize, filesize_multiplier):
filesize = None
return filesize
+
+
+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