Better error message when failing to load translations

This commit is contained in:
Kovid Goyal 2019-06-11 16:32:35 +05:30
parent 21fbec2820
commit 000bb4c89e
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -137,7 +137,12 @@ def get_single_translator(mpath, which='messages'):
from zipfile import ZipFile
with ZipFile(P('localization/locales.zip', allow_user_override=False), 'r') as zf:
buf = io.BytesIO(zf.read(mpath + '/%s.mo' % which))
try:
return GNUTranslations(buf)
except Exception as e:
import traceback
traceback.print_exc()
raise ValueError('Failed to load translations for: {} with error: {}'.format(mpath, e))
def get_iso639_translator(lang):