Only consider the values of LC_ALL, LANG, and LANGUAGE, in that order, when choosing the default locale.

Default arguments of locale.getdefaultlocale() consider the value
of LC_CTYPE in addition to the three aforementioned all-category
variables, which under certain conditions (LC_CTYPE set, LC_ALL and
the rest of LC_FOO unset) would result in the locale set in LC_CTYPE
(which should only affect interpretation of byte sequences as
characters) spilling over to other locale categories handled by the
GrampsLocale object. The most visible effect of that spill was that
with LC_ALL, LANG, LANGUAGE and LC_MESSAGES unset but LC_CTYPE set,
Gramps would start using the wrong UI language.
This commit is contained in:
Marek Szuba 2016-01-22 08:18:11 +00:00 committed by John Ralls
parent 65442c2da8
commit 186c2bcfef

View File

@ -294,13 +294,12 @@ class GrampsLocale(object):
_failure = False
try:
locale.setlocale(locale.LC_ALL, '')
if not _check_locale(locale.getlocale()):
if not _check_locale(locale.getdefaultlocale()):
LOG.debug("Usable locale not found, localization settings ignored.");
self.lang = 'C'
self.encoding = 'ascii'
self.language = ['en']
_failure = True
if not _check_locale(locale.getdefaultlocale(envvars=('LC_ALL', 'LANG', 'LANGUAGE'))):
LOG.debug("Usable locale not found, localization settings ignored.");
self.lang = 'C'
self.encoding = 'ascii'
self.language = ['en']
_failure = True
except locale.Error as err:
LOG.debug("Locale error %s, localization settings ignored.",