From 400523c7f3d7aad33babd350409fbaea8d36f21b Mon Sep 17 00:00:00 2001 From: John Ralls Date: Sun, 24 Feb 2013 01:49:15 +0000 Subject: [PATCH] [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 --- gramps/gen/utils/grampslocale.py | 5 +++-- gramps/gen/utils/maclocale.py | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/gramps/gen/utils/grampslocale.py b/gramps/gen/utils/grampslocale.py index 87c3f1ade..e980da79c 100644 --- a/gramps/gen/utils/grampslocale.py +++ b/gramps/gen/utils/grampslocale.py @@ -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"] diff --git a/gramps/gen/utils/maclocale.py b/gramps/gen/utils/maclocale.py index 0cb603c72..171a52d11 100644 --- a/gramps/gen/utils/maclocale.py +++ b/gramps/gen/utils/maclocale.py @@ -247,9 +247,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