Merge pull request #1452 from a-andre/locale

This commit is contained in:
Nick Hall 2023-07-13 22:29:06 +01:00
commit d858f86a18
3 changed files with 7 additions and 41 deletions

View File

@ -325,16 +325,6 @@ class GrampsLocale:
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):
@ -397,18 +387,6 @@ class GrampsLocale:
if HAVE_ICU and 'COLLATION' in os.environ:
self.collation = os.environ['COLLATION']
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
# $LANGUAGE overrides $LANG, $LC_MESSAGES
if "LANGUAGE" in os.environ:
language = [x for x in [self.check_available_translations(l)
@ -468,7 +446,7 @@ class GrampsLocale:
else:
self._init_from_environment()
else:
self.numeric = self.currency = self.calendar = self.collation = self.lang
self.calendar = self.collation = self.lang
if not self.lang:
self.lang = 'en_US.UTF-8'
@ -570,7 +548,7 @@ class GrampsLocale:
if not self.language and _first.language:
self.language = _first.language
self.numeric = self.currency = self.calendar = self.collation = self.lang
self.calendar = self.collation = self.lang
self.rtl_locale = False
if self.language[0] in _RTL_LOCALES:

View File

@ -46,9 +46,8 @@ are the names of the controls in System Preferences; the names in the
defaults system are AppleCollationOrder and AppleLocale,
respectively.)
The user can override the currency and calendar, and those values are
appended to AppleLocale and parsed below. But Gramps makes no use of
currency and sets the calendar in its own preferences, so they're
The user can override the calendar, and thise value is appended to AppleLocale
and parsed below. But Gramps sets the calendar in its own preferences, so it is
ignored.
Where the mismatch becomes a problem is in date and number
@ -56,7 +55,7 @@ formatting. POSIX specifies a locale for this, but ICU uses format
strings, and there is no good way to map those strings into one of the
available locales. Users who whan to specify particular ways of
formatting different from their base locales will have to figure out
the appropriate locale on their own and set LC_TIME and LC_NUMERIC
the appropriate locale on their own and set LC_TIME
appropriately. The "Formats" page on the Languages & Text
(International in Leopard) System Preferences pane is a good way to
quickly assess the formats in various locales.
@ -148,7 +147,6 @@ def mac_setup_localization(glocale):
def _mac_check_locale(locale_string):
locale = None
calendar = None
currency = None
div = locale_string.strip().split("@")
LOG.debug("Checking Locale %s", ' '.join(div))
locale = glocale.check_available_translations(div[0])
@ -158,10 +156,8 @@ def mac_setup_localization(glocale):
(name, value) = phrase.split("=")
if name == "calendar":
calendar = glocale.check_available_translations(value)
elif name == "currency":
currency = value
return (locale, calendar, currency)
return (locale, calendar)
def _mac_get_locale():
"""
@ -214,7 +210,6 @@ def mac_setup_localization(glocale):
_locale = None
_failure = False
glocale.calendar = None
glocale.currency = None
try:
locale.setlocale(locale.LC_ALL, '')
_locale = locale.getlocale()
@ -229,7 +224,7 @@ def mac_setup_localization(glocale):
if not glocale.lang:
LOG.debug("Setting from the environment didn't work out, checking defaults")
(glocale.lang, glocale.currency, glocale.calendar) = _mac_get_locale()
(glocale.lang, glocale.calendar) = _mac_get_locale()
glocale.coll_qualifier = None
glocale.collation = _mac_get_collation()
@ -293,8 +288,3 @@ def mac_setup_localization(glocale):
glocale.calendar = time
else:
glocale.calendar = glocale.lang[:5]
if not glocale.currency:
glocale.currency = locale.getlocale(locale.LC_MONETARY)[0] or glocale.lang
glocale.numeric = locale.getlocale(locale.LC_NUMERIC)[0] or glocale.lang

View File

@ -581,8 +581,6 @@ def run():
LOG.debug("Translating Gramps to %s", glocale.language[0])
LOG.debug("Collation Locale: %s", glocale.collation)
LOG.debug("Date/Time Locale: %s", glocale.calendar)
LOG.debug("Currency Locale: %s", glocale.currency)
LOG.debug("Number-format Locale: %s", glocale.numeric)
if 'LANG' in os.environ:
LOG.debug('Using LANG: %s' %