[r21326] 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: r21423
This commit is contained in:
John Ralls 2013-02-24 01:49:15 +00:00
parent 0bbbc76852
commit 400523c7f3
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 not language or len(language) == 0:
if "LANGUAGE" in os.environ: if "LANGUAGE" in os.environ:
avail = self.get_available_translations()
language = [l for l in os.environ["LANGUAGE"].split(":") 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 self.language = language
elif not lang == "C.UTF-8": elif not lang == "C.UTF-8":
self.language = [lang[0:2]] self.language = [lang]
else: else:
self.language = ["en"] self.language = ["en"]

View File

@ -247,9 +247,9 @@ def mac_setup_localization(glocale, lang, language):
if not language or len(language) == 0: if not language or len(language) == 0:
if "LANGUAGE" in os.environ: if "LANGUAGE" in os.environ:
language = [l for l in os.environ["LANGUAGE"].split(":") 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": elif lang != "en_US":
language = [lang[0:2]] language = [lang]
else: else:
if len(translations) > 0: if len(translations) > 0:
language = translations language = translations