GrampsLocale: Win32: Clean up extraneous conditions, don't set self.language prematurely
svn: r22036
This commit is contained in:
parent
a2e17b7b4a
commit
2054c0ad46
@ -180,49 +180,49 @@ class GrampsLocale(object):
|
|||||||
localizations.
|
localizations.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if not (hasattr(self, 'lang') and self.lang):
|
if 'LANG' in os.environ:
|
||||||
self.lang = None
|
(lang, loc) = _check_mswin_locale(os.environ['LANG'])
|
||||||
if 'LANG' in os.environ:
|
if loc:
|
||||||
(lang, loc) = _check_mswin_locale(os.environ['LANG'])
|
locale.setlocale(locale.LC_ALL, '.'.join(loc))
|
||||||
if loc:
|
self.lang = lang
|
||||||
locale.setlocale(locale.LC_ALL, '.'.join(loc))
|
self.encoding = loc[1]
|
||||||
|
else:
|
||||||
|
LOG.debug("%%LANG%% value %s not usable", os.environ['LANG'])
|
||||||
|
if not self.lang:
|
||||||
|
locale.setlocale(locale.LC_ALL, '')
|
||||||
|
(lang, encoding) = locale.getlocale()
|
||||||
|
loc = _check_mswin_locale_reverse(lang)
|
||||||
|
if loc:
|
||||||
|
self.lang = loc[0]
|
||||||
|
self.encoding = loc[1]
|
||||||
|
else:
|
||||||
|
(lang, loc) = _check_mswin_locale(lang)
|
||||||
|
if lang:
|
||||||
self.lang = lang
|
self.lang = lang
|
||||||
self.language = [self.lang]
|
|
||||||
self.encoding = loc[1]
|
|
||||||
|
|
||||||
if not self.lang:
|
|
||||||
locale.setlocale(locale.LC_ALL, '')
|
|
||||||
(lang, encoding) = locale.getlocale()
|
|
||||||
loc = _check_mswin_locale_reverse(lang)
|
|
||||||
if loc:
|
|
||||||
self.lang = loc[0]
|
|
||||||
self.languages = [loc[0]]
|
|
||||||
self.encoding = loc[1]
|
self.encoding = loc[1]
|
||||||
else:
|
else:
|
||||||
(lang, loc) = _check_mswin_locale(lang)
|
LOG.debug("No usable locale found in environment")
|
||||||
if lang:
|
|
||||||
self.lang = lang
|
|
||||||
self.language = [self.lang]
|
|
||||||
self.encoding = loc[1]
|
|
||||||
|
|
||||||
if not self.lang:
|
if not self.lang:
|
||||||
self.lang = 'C'
|
self.lang = 'C'
|
||||||
self.language = ['en']
|
self.encoding = 'cp1252'
|
||||||
self.encoding = 'cp1252'
|
|
||||||
|
|
||||||
if not (hasattr(self, 'language') and self.language):
|
|
||||||
if 'LC_MESSAGES' in os.environ:
|
|
||||||
lang = self.check_available_translations(os.environ['LC_MESSAGES'])
|
|
||||||
if lang:
|
|
||||||
self.language = [lang]
|
|
||||||
if 'LANGUAGE' in os.environ:
|
|
||||||
language = [x for x in [self.check_available_translations(l)
|
|
||||||
for l in os.environ["LANGUAGE"].split(":")]
|
|
||||||
if x]
|
|
||||||
|
|
||||||
|
if 'LC_MESSAGES' in os.environ:
|
||||||
|
lang = self.check_available_translations(os.environ['LC_MESSAGES'])
|
||||||
|
if lang:
|
||||||
|
self.language = [lang]
|
||||||
|
else:
|
||||||
|
LOG.debug("No translation for %%LC_MESSAGES%% locale")
|
||||||
|
if 'LANGUAGE' in os.environ:
|
||||||
|
language = [x for x in [self.check_available_translations(l)
|
||||||
|
for l in os.environ["LANGUAGE"].split(":")]
|
||||||
|
if x]
|
||||||
|
if language:
|
||||||
self.language = language
|
self.language = language
|
||||||
if not (hasattr(self, 'language') and self.language):
|
else:
|
||||||
self.language = [self.lang]
|
LOG.debug("No languages with translations found in %%LANGUAGES%%")
|
||||||
|
if not self.language:
|
||||||
|
self.language = [self.lang[:5]]
|
||||||
|
|
||||||
if 'LC_COLLATE' in os.environ:
|
if 'LC_COLLATE' in os.environ:
|
||||||
coll = os.environ['LC_COLLATE']
|
coll = os.environ['LC_COLLATE']
|
||||||
|
Loading…
Reference in New Issue
Block a user