From 22f6b39ad07f2ee8331df6a9d731417ea258276f Mon Sep 17 00:00:00 2001 From: j Date: Mon, 2 Jun 2008 15:04:56 +0200 Subject: [PATCH] dont fail if no name exists --- oxutils/lang.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/oxutils/lang.py b/oxutils/lang.py index 249f7f3..10d0637 100644 --- a/oxutils/lang.py +++ b/oxutils/lang.py @@ -191,7 +191,7 @@ _iso639_languages = [ ("Zulu", "", "zu", "zul"), ] -def langFromCode(code): +def codeToLang(code): code = code.lower() if len(code) == 2: for l in _iso639_languages: @@ -204,24 +204,28 @@ def langFromCode(code): return None def langTo3Code(lang): - lang = englishName(lang).lower() + lang = englishName(lang) + if lang: + lang=lang.lower() for l in _iso639_languages: if l[0].lower() == lang: return l[3] return None def langTo2Code(lang): - lang = englishName(lang).lower() + lang = englishName(lang) + if lang: + lang=lang.lower() for l in _iso639_languages: if l[0].lower() == lang: return l[2] return None def langCode2To3(code): - langTo3Code(langFromCode(code)) + langTo3Code(codeToLang(code)) def langCode3To2(code): - langTo2Code(langFromCode(code)) + langTo2Code(codeToLang(code)) def englishName(lang): lang = lang.lower()