[utils] Capture the error that mo files not found in LOCALE_DATA.ZIP
This commit is contained in:
parent
7da2b9e3bc
commit
c0450e2014
@ -2547,8 +2547,13 @@ class I18N(object):
|
|||||||
locale_data_zip = _load_exe_resource('LOCALE_DATA', 'LOCALE_DATA.ZIP')
|
locale_data_zip = _load_exe_resource('LOCALE_DATA', 'LOCALE_DATA.ZIP')
|
||||||
f = io.BytesIO(locale_data_zip)
|
f = io.BytesIO(locale_data_zip)
|
||||||
zipf = zipfile.ZipFile(f)
|
zipf = zipfile.ZipFile(f)
|
||||||
with zipf.open('share/locale/%s/LC_MESSAGES/%s.mo' % (lang, self.domain)) as mo_file:
|
try:
|
||||||
t = gettext.GNUTranslations(mo_file)
|
zinfo = zipf.getinfo('share/locale/%s/LC_MESSAGES/%s.mo' % (lang, self.domain))
|
||||||
|
except KeyError:
|
||||||
|
zinfo = None
|
||||||
|
if zinfo is not None:
|
||||||
|
with zipf.open(zinfo) as mo_file:
|
||||||
|
t = gettext.GNUTranslations(mo_file)
|
||||||
zipf.close()
|
zipf.close()
|
||||||
|
|
||||||
if t is None:
|
if t is None:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user