__init__.py 文件源码

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

项目:dodotable 作者: spoqa 项目源码 文件源码
def get_translations(self):
        if self.get_locale is None:
            return None
        locale = self.get_locale()
        if locale is None:
            return None
        elif not isinstance(locale, str):
            # locale might be an instance of babel.core.Locale
            locale = str(locale)
        if '_' in locale or '-' in locale:
            # If the locale has territory (e.g. 'ko_KR')
            # we can search the proper match (e.g. ko_KR) and then
            # the non-territory match (e.g. ko) as a fallback.
            locale = locale.replace('-', '_')
            locales = [locale, locale[:locale.index('_')]]
        else:
            locales = [locale]
        return gettext.translation(
            'dodotable',
            os.path.join(os.path.dirname(__file__), '..', 'locale'),
            fallback=True,
            codeset='utf-8',
            languages=locales
        )
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号