[r22033]GrampsLocale: Init_from_environment: Change precedence

LC_MESSAGES takes precedence over LC_CTYPE for setting self.lang
$LANGUAGES overrides $LANG, $LC_FOO for setting translations

svn: r22050
This commit is contained in:
John Ralls 2013-04-20 23:23:36 +00:00
parent badaa407f6
commit c6f926188a

View File

@ -276,8 +276,8 @@ class GrampsLocale(object):
try: try:
locale.setlocale(locale.LC_ALL, '') locale.setlocale(locale.LC_ALL, '')
if not _check_locale(locale.getlocale()): if not _check_locale(locale.getlocale(locale.LC_MESSAGES)):
if not _check_locale(locale.getlocale(locale.LC_MESSAGES)): if not _check_locale(locale.getlocale()):
if not _check_locale(locale.getdefaultlocale()): if not _check_locale(locale.getdefaultlocale()):
self.lang = 'C' self.lang = 'C'
self.encoding = 'ascii' self.encoding = 'ascii'
@ -291,12 +291,16 @@ class GrampsLocale(object):
self.language = ['en'] self.language = ['en']
# $LANGUAGE overrides $LANG, $LC_MESSAGES # $LANGUAGE overrides $LANG, $LC_MESSAGES
if not self.lang.startswith('C.') and "LANGUAGE" in os.environ: if "LANGUAGE" in os.environ:
language = [x for x in [self.check_available_translations(l) language = [x for x in [self.check_available_translations(l)
for l in os.environ["LANGUAGE"].split(":")] for l in os.environ["LANGUAGE"].split(":")]
if x] if x]
if language: if language:
self.language = language self.language = language
if not self.lang.startswith(self.language[0]):
LOG.debug("Overiding locale setting %s with LANGUAGE setting %s", self.lang, self.language[0])
self.lang = locale.normalize(self.language[0])
self.encoding = self.lang.split('.')[1]
if HAVE_ICU: if HAVE_ICU:
self.calendar = locale.getlocale(locale.LC_TIME)[0] or self.lang[:5] self.calendar = locale.getlocale(locale.LC_TIME)[0] or self.lang[:5]