GrampsLocale: Correct setting GrampsLocale.languages

Test only first 5 or first 2 characters of the language id against the
list of available translations.

Thanks to Tim Lyons for exposing the error.

svn: r21326
This commit is contained in:
John Ralls 2013-02-09 18:59:20 +00:00
parent fcab654305
commit c56bd35ce0
2 changed files with 5 additions and 4 deletions

View File

@ -118,11 +118,12 @@ class GrampsLocale(object):
if not language or len(language) == 0:
if "LANGUAGE" in os.environ:
avail = self.get_available_translations()
language = [l for l in os.environ["LANGUAGE"].split(":")
if l in self.get_available_translations()]
if l[:5] in avail or l[:2] in avail]
self.language = language
elif not lang == "C.UTF-8":
self.language = [lang[0:2]]
self.language = [lang]
else:
self.language = ["en"]

View File

@ -250,9 +250,9 @@ def mac_setup_localization(glocale, lang, language):
if not language or len(language) == 0:
if "LANGUAGE" in os.environ:
language = [l for l in os.environ["LANGUAGE"].split(":")
if l in available]
if l[:5] in available or l[:2] in available]
elif lang != "en_US":
language = [lang[0:2]]
language = [lang]
else:
if len(translations) > 0:
language = translations