gettext.py 文件源码

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

项目:transpyler 作者: Transpyler 项目源码 文件源码
def gettext_for(lang):
    """
    Return a GNUTranslation class for the given language.

    Example:
        >>> trans = gettext_for('pt_BR')
        >>> _ = trans.gettext
        >>> _('hello world!')                                   # doctest: +SKIP
        'olá mundo!'
    """
    lang = lang.replace('-', '_')

    try:
        with open(os.path.join(L10N_PATH, lang + '.mo'), 'rb') as F:
            result = gettext.GNUTranslations(F)
    except FileNotFoundError:
        result = gettext.NullTranslations()
    return result
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号