def _setup_locale():
""" Setting up localization
:return: translation method
"""
try:
locale_file = Config.get('xpopup', 'locale_file')
except:
from os.path import abspath, dirname, join
locale_file = join(dirname(abspath(__file__)), 'xpopup.mo')
try:
with open(locale_file, "rb") as f:
xpopup_locale = gettext.GNUTranslations(f)
Logger.info('Localization file loaded (%s).' % locale_file)
except Exception as e:
Logger.warning('%s: %s. Switch to the defaults.' %
(e.__class__.__name__, str(e)))
xpopup_locale = gettext.NullTranslations()
if PY2:
return xpopup_locale.ugettext
else:
return xpopup_locale.gettext
评论列表
文章目录