GrampsLocale: Introduce GrampsLocale attributes currency, calendar, and collate

svn: r21274
This commit is contained in:
John Ralls 2013-02-01 22:48:57 +00:00
parent 0c2263a327
commit f238be30ef
2 changed files with 48 additions and 19 deletions

View File

@ -113,6 +113,22 @@ class GrampsLocale(object):
else: else:
self.language = ["en"] 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, def __init_first_instance(self, localedir=None, lang=None,
domain=None, language=None): domain=None, language=None):

View File

@ -228,21 +228,11 @@ def mac_setup_localization(glocale, lang, language):
# The action starts here # The action starts here
(loc, currency, calendar) = mac_get_locale() (loc, currency, calendar) = mac_get_locale()
collation = mac_get_collation()
translations = mac_language_list() translations = mac_language_list()
if "LC_COLLATE" in os.environ:
if currency and "LC_MONETARY" not in os.environ: collation = os.environ["LC_COLLATE"]
os.environ["LC_MONETARY"] = currency else:
collation = mac_get_collation()
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 not lang: if not lang:
if "LANG" in os.environ: if "LANG" in os.environ:
@ -252,12 +242,9 @@ def mac_setup_localization(glocale, lang, language):
loc = mac_resolve_locale(loc) loc = mac_resolve_locale(loc)
if loc != None: if loc != None:
lang = loc lang = loc
collation = mac_resolve_locale(collation) if not lang and collation != None:
if "LC_COLLATE" not in os.environ and collation != None:
os.environ["LC_COLLATE"] = collation
elif len(collation) > 0:
lang = mac_resolve_locale(collation) lang = mac_resolve_locale(collation)
glocale.lang = lang glocale.lang = lang
if not language or len(language) == 0: if not language or len(language) == 0:
@ -277,3 +264,29 @@ def mac_setup_localization(glocale, lang, language):
language = [collation] language = [collation]
glocale.language = language 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