tools.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:garden.xpopup 作者: kivy-garden 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号