mirror of
https://github.com/ejwa/gitinspector.git
synced 2025-01-03 11:22:15 +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
|
import os
|
||||||
|
|
||||||
def init():
|
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:
|
try:
|
||||||
translation = gettext.GNUTranslations(open( filename, "rb" ) )
|
locale.setlocale(locale.LC_ALL, "")
|
||||||
except IOError:
|
except locale.Error:
|
||||||
translation = gettext.NullTranslations()
|
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)
|
translation.install(True)
|
||||||
|
|
Loading…
Reference in a new issue