mirror of
https://github.com/ejwa/gitinspector.git
synced 2024-11-16 00:28:25 +01:00
gitinspector now tries to get around any invalid locale.
Whenever a locale is found that is simply wrong; gitinspector will try to get the default strings from gettext and try to execute.
This commit is contained in:
parent
f030147206
commit
cd1c1f0c65
1 changed files with 16 additions and 12 deletions
|
@ -24,19 +24,23 @@ import locale
|
|||
import os
|
||||
|
||||
def init():
|
||||
locale.setlocale(locale.LC_ALL, '')
|
||||
lang = locale.getlocale()
|
||||
|
||||
#Fix for non-POSIX-compliant systems (Windows et al.).
|
||||
if os.getenv('LANG') is None:
|
||||
lang, _ = locale.getdefaultlocale()
|
||||
os.environ['LANG'] = lang
|
||||
|
||||
filename = "translations/messages_%s.mo" % lang[0][0:2]
|
||||
|
||||
try:
|
||||
translation = gettext.GNUTranslations(open( filename, "rb" ) )
|
||||
except IOError:
|
||||
locale.setlocale(locale.LC_ALL, "")
|
||||
except locale.Error:
|
||||
translation = gettext.NullTranslations()
|
||||
else:
|
||||
lang = locale.getlocale()
|
||||
|
||||
#Fix for non-POSIX-compliant systems (Windows et al.).
|
||||
if os.getenv('LANG') is None:
|
||||
lang = locale.getdefaultlocale()
|
||||
os.environ['LANG'] = lang[0]
|
||||
|
||||
filename = "translations/messages_%s.mo" % lang[0][0:2]
|
||||
|
||||
try:
|
||||
translation = gettext.GNUTranslations(open( filename, "rb" ) )
|
||||
except IOError:
|
||||
translation = gettext.NullTranslations()
|
||||
|
||||
translation.install(True)
|
||||
|
|
Loading…
Reference in a new issue