From 879c48f57d8191f0797ebc0a9a62130b07d679ad Mon Sep 17 00:00:00 2001 From: John Ralls Date: Sun, 24 Feb 2013 00:55:32 +0000 Subject: [PATCH] [r21274]GrampsLocale: Introduce new GrampsLocale attributes currency, calendar, and collate svn: r21415 --- gramps/gen/utils/grampslocale.py | 16 ++++++++++ gramps/gen/utils/maclocale.py | 51 ++++++++++++++++++++------------ 2 files changed, 48 insertions(+), 19 deletions(-) diff --git a/gramps/gen/utils/grampslocale.py b/gramps/gen/utils/grampslocale.py index 4e0b2c5ce..c8b549e6d 100644 --- a/gramps/gen/utils/grampslocale.py +++ b/gramps/gen/utils/grampslocale.py @@ -113,6 +113,22 @@ class GrampsLocale(object): else: self.language = ["en"] + if "LC_MONETARY" not in os.environ: + self.currency = lang + else: + self.currency = os.environ[LC_MONETARY] + + if "LC_TIME" not in os.environ: + self.calendar = lang + else: + self.calendar = os.environ["LC_TIME"] + + if "LC_COLLATE" not in os.environ: + self.collation = lang + else: + self.collation = os.environ["LC_COLLATE"] + + def __init_first_instance(self, localedir=None, lang=None, domain=None, language=None): diff --git a/gramps/gen/utils/maclocale.py b/gramps/gen/utils/maclocale.py index a59e9fe88..0cb603c72 100644 --- a/gramps/gen/utils/maclocale.py +++ b/gramps/gen/utils/maclocale.py @@ -225,21 +225,11 @@ def mac_setup_localization(glocale, lang, language): # The action starts here (loc, currency, calendar) = mac_get_locale() - collation = mac_get_collation() translations = mac_language_list() - - if currency and "LC_MONETARY" not in os.environ: - os.environ["LC_MONETARY"] = currency - - if calendar and "LC_TIME" not in os.environ: - os.environ["LC_TIME"] = calendar - - if currency and "LC_MONETARY" not in os.environ: - os.environ["LC_MONETARY"] = currency - - - if calendar and "LC_TIME" not in os.environ: - os.environ["LC_TIME"] = calendar + if "LC_COLLATE" in os.environ: + collation = os.environ["LC_COLLATE"] + else: + collation = mac_get_collation() if not lang: if "LANG" in os.environ: @@ -249,12 +239,9 @@ def mac_setup_localization(glocale, lang, language): loc = mac_resolve_locale(loc) if loc != None: lang = loc - collation = mac_resolve_locale(collation) - if "LC_COLLATE" not in os.environ and collation != None: - os.environ["LC_COLLATE"] = collation + if not lang and collation != None: + lang = mac_resolve_locale(collation) - elif len(collation) > 0: - lang = mac_resolve_locale(collation) glocale.lang = lang if not language or len(language) == 0: @@ -274,3 +261,29 @@ def mac_setup_localization(glocale, lang, language): language = [collation] glocale.language = language + + if currency and "LC_MONETARY" not in os.environ: + glocale.currency = currency + os.environ["LC_MONETARY"] = currency + elif "LC_MONETARY" in os.environ: + glocale.currency = os.environ[LC_MONETARY] + else: + glocale.currency = lang + + if calendar and "LC_TIME" not in os.environ: + glocale.calendar = calendar + os.environ["LC_TIME"] = calendar + elif "LC_TIME" in os.environ: + glocale.calendar = os.environ["LC_TIME"] + else: + glocale.calendar = lang + + if collation and "LC_COLLATION" not in os.environ: + glocale.collation = collation + os.environ["LC_COLLATION"] = calendar + elif "LC_COLLATION" in os.environ: + glocale.collation = os.environ["LC_COLLATION"] + else: + glocale.collation = lang + +