From 186c2bcfef1b58c51ba0670130cd4ec076d599fe Mon Sep 17 00:00:00 2001 From: Marek Szuba Date: Fri, 22 Jan 2016 08:18:11 +0000 Subject: [PATCH] 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. --- gramps/gen/utils/grampslocale.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/gramps/gen/utils/grampslocale.py b/gramps/gen/utils/grampslocale.py index f8ab285b9..508b7f8da 100644 --- a/gramps/gen/utils/grampslocale.py +++ b/gramps/gen/utils/grampslocale.py @@ -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.",