[r22024]GrampsLocale: Add GrampsLocale attributes numeric and currency

svn: r22041
This commit is contained in:
John Ralls 2013-04-20 23:22:37 +00:00
parent f2d7e62fc0
commit 70345ef4b8
2 changed files with 32 additions and 1 deletions

View File

@ -251,6 +251,16 @@ class GrampsLocale(object):
else:
self.calendar = self.lang
if 'LC_NUMERIC' in os.environ:
self.numeric = os.environ['LC_NUMERIC']
else:
self.numeric = self.lang
if 'LC_MONETARY' in os.environ:
self.currency = os.environ['LC_MONETARY']
else:
self.currency = self.lang
def _init_from_environment(self):
def _check_locale(locale):
@ -304,6 +314,18 @@ class GrampsLocale(object):
else:
self.collation = self.lang
loc = locale.getlocale(locale.LC_NUMERIC)
if loc and loc[0]:
self.numeric = '.'.join(loc)
else:
self.numeric = self.lang
loc = locale.getlocale(locale.LC_MONETARY)
if loc and loc[0]:
self.currency = '.'.join(loc)
else:
self.currency = self.lang
def _win_bindtextdomain(self, localedomain, localedir):
"""
Help routine for loading and setting up libintl attributes
@ -343,7 +365,7 @@ class GrampsLocale(object):
else:
self._init_from_environment()
else:
self.currency = self.calendar = self.collation = self.lang
self.numeric = self.currency = self.calendar = self.collation = self.lang
if not self.lang:
self.lang = 'en_US.UTF-8'

View File

@ -130,6 +130,10 @@ def mac_setup_localization(glocale):
locale = ""
calendar = ""
currency = ""
#Note that numeric separators are encoded in AppleICUNumberSymbols,
#with [0] being the decimal separator and [1] the thousands
#separator. This obviously won't translate into a locale without
#searching the locales database for a match.
default_locale = _mac_get_gramps_defaults("AppleLocale")
if not default_locale:
return (locale, calendar, currency)
@ -281,4 +285,9 @@ def mac_setup_localization(glocale):
else:
glocale.collation = glocale.lang[:5]
if "LC_NUMERIC" in os.environ:
glocale.numeric = os.environ["LC_NUMERIC"]
else:
glocale.numeric = glocale.lang[:5]