fix ox.iso language lookup
This commit is contained in:
parent
3f15161bed
commit
9edf30085e
1 changed files with 23 additions and 20 deletions
|
@ -192,6 +192,7 @@ _iso639_languages = [
|
|||
]
|
||||
|
||||
def codeToLang(code):
|
||||
if code:
|
||||
code = code.lower()
|
||||
if len(code) == 2:
|
||||
for l in _iso639_languages:
|
||||
|
@ -204,6 +205,7 @@ def codeToLang(code):
|
|||
return None
|
||||
|
||||
def langTo3Code(lang):
|
||||
if lang:
|
||||
lang = langEnglishName(lang)
|
||||
if lang:
|
||||
lang=lang.lower()
|
||||
|
@ -213,6 +215,7 @@ def langTo3Code(lang):
|
|||
return None
|
||||
|
||||
def langTo2Code(lang):
|
||||
if lang:
|
||||
lang = langEnglishName(lang)
|
||||
if lang:
|
||||
lang=lang.lower()
|
||||
|
@ -230,7 +233,7 @@ def langCode3To2(code):
|
|||
def langEnglishName(lang):
|
||||
lang = lang.lower()
|
||||
for l in _iso639_languages:
|
||||
if l[1].lower() == lang:
|
||||
if l[1].lower() == lang or l[0].lower() == lang:
|
||||
return l[0]
|
||||
return None
|
||||
|
||||
|
|
Loading…
Reference in a new issue