setlocale.py 文件源码

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

项目:zing 作者: evernote 项目源码 文件源码
def process_request(self, request):
        # Under Windows, locale names are different, setlocale() with regular
        # locale names will fail and locale.setlocale(locale.LC_ALL, '') will
        # produce side effect seems like the safest option is just not set any
        # locale at all
        if os.name == 'nt':
            return

        # FIXME: some languages like arabic don't have a language only locale
        # for no good reason. we need a function to pick default locale for
        # these
        lang = translation.to_locale(translation.get_language())
        try:
            if lang == 'tr' or lang.startswith('tr_'):
                raise ValueError("Turkish locale broken due to changed "
                                 "meaning of lower()")
            locale.setlocale(locale.LC_ALL, (lang, 'UTF-8'))
        except:
            logging.debug('Failed to set locale to %s; using Pootle default',
                          lang)
            set_pootle_locale_from_settings()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号