当前位置: 首页>>代码示例>>Python>>正文


Python oslo_i18n.get_available_languages方法代码示例

本文整理汇总了Python中oslo_i18n.get_available_languages方法的典型用法代码示例。如果您正苦于以下问题:Python oslo_i18n.get_available_languages方法的具体用法?Python oslo_i18n.get_available_languages怎么用?Python oslo_i18n.get_available_languages使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在oslo_i18n的用法示例。


在下文中一共展示了oslo_i18n.get_available_languages方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_extra_lang

# 需要导入模块: import oslo_i18n [as 别名]
# 或者: from oslo_i18n import get_available_languages [as 别名]
def test_extra_lang(self):
        languages = _gettextutils.get_available_languages('oslo')
        languages.append(_FAKE_LANG)
        self.useFixture(fixture.PrefixLazyTranslation(languages=languages))
        raw_id1 = 'fake msg1'
        expected_msg_en_US = ('oslo_i18n/' +
                              fixture.PrefixLazyTranslation._DEFAULT_LANG +
                              ': ' + raw_id1)
        expected_msg_en_ZZ = 'oslo_i18n/' + _FAKE_LANG + ': ' + raw_id1
        msg1 = _(raw_id1)     # noqa
        self.assertEqual(languages,
                         _gettextutils.get_available_languages('oslo_i18n'))
        self.assertEqual(languages,
                         oslo_i18n.get_available_languages('oslo_i18n'))
        self.assertEqual(expected_msg_en_US, _translate.translate(msg1))
        self.assertEqual(expected_msg_en_ZZ,
                         _translate.translate(msg1,
                                              desired_locale=_FAKE_LANG)) 
开发者ID:openstack,项目名称:oslo.i18n,代码行数:20,代码来源:test_fixture.py

示例2: test_best_match_language

# 需要导入模块: import oslo_i18n [as 别名]
# 或者: from oslo_i18n import get_available_languages [as 别名]
def test_best_match_language(self):
        # Test that we are actually invoking language negotiation by webop
        request = wsgi.Request.blank('/')
        oslo_i18n.get_available_languages = mock.MagicMock()
        oslo_i18n.get_available_languages.return_value = [
            'known-language', 'es', 'zh']
        request.headers['Accept-Language'] = 'known-language'
        language = request.best_match_language()
        self.assertEqual('known-language', language)

        # If the Accept-Leader is an unknown language, missing or empty,
        # the best match locale should be None
        request.headers['Accept-Language'] = 'unknown-language'
        language = request.best_match_language()
        self.assertIsNone(language)
        request.headers['Accept-Language'] = ''
        language = request.best_match_language()
        self.assertIsNone(language)
        request.headers.pop('Accept-Language')
        language = request.best_match_language()
        self.assertIsNone(language) 
开发者ID:openstack,项目名称:tacker,代码行数:23,代码来源:test_wsgi.py

示例3: test_default

# 需要导入模块: import oslo_i18n [as 别名]
# 或者: from oslo_i18n import get_available_languages [as 别名]
def test_default(self):

        # Turn lazy off to check that fixture turns it on
        self.useFixture(fixture.ToggleLazy(False))
        self.useFixture(fixture.PrefixLazyTranslation())
        self.assertTrue(_lazy.USE_LAZY)
        default_lang = fixture.PrefixLazyTranslation._DEFAULT_LANG
        raw_id1 = 'fake msg1'
        expected_msg = 'oslo_i18n/' + default_lang + ': ' + raw_id1
        msg1 = _(raw_id1)    # noqa
        self.assertEqual([default_lang],
                         _gettextutils.get_available_languages('oslo_i18n'))
        self.assertEqual([default_lang],
                         oslo_i18n.get_available_languages('oslo_i18n'))
        self.assertEqual(expected_msg, _translate.translate(msg1)) 
开发者ID:openstack,项目名称:oslo.i18n,代码行数:17,代码来源:test_fixture.py

示例4: test_get_available_languages

# 需要导入模块: import oslo_i18n [as 别名]
# 或者: from oslo_i18n import get_available_languages [as 别名]
def test_get_available_languages(self):
        oslo_i18n.get_available_languages('domains') 
开发者ID:openstack,项目名称:oslo.i18n,代码行数:4,代码来源:test_public_api.py

示例5: get_available_languages

# 需要导入模块: import oslo_i18n [as 别名]
# 或者: from oslo_i18n import get_available_languages [as 别名]
def get_available_languages():
    return oslo_i18n.get_available_languages(DOMAIN) 
开发者ID:openstack,项目名称:networking-sfc,代码行数:4,代码来源:_i18n.py

示例6: get_available_languages

# 需要导入模块: import oslo_i18n [as 别名]
# 或者: from oslo_i18n import get_available_languages [as 别名]
def get_available_languages():
        return oslo_i18n.get_available_languages(DOMAIN) 
开发者ID:openstack,项目名称:networking-odl,代码行数:4,代码来源:_i18n.py

示例7: get_available_languages

# 需要导入模块: import oslo_i18n [as 别名]
# 或者: from oslo_i18n import get_available_languages [as 别名]
def get_available_languages():
    return i18n.get_available_languages(DOMAIN) 
开发者ID:cloudbase,项目名称:vdi-broker,代码行数:4,代码来源:i18n.py

示例8: get_available_languages

# 需要导入模块: import oslo_i18n [as 别名]
# 或者: from oslo_i18n import get_available_languages [as 别名]
def get_available_languages():
    """
    返回当前可以提供翻译的语言列表

    #所有的语言包在 /usr/local/lib/python2.7/dist-packages/babel/locale-data/
    :return:
    """
    return oslo_i18n.get_available_languages(DOMAIN) 
开发者ID:tomoncle,项目名称:Python-notes,代码行数:10,代码来源:_i18n.py

示例9: best_match_language

# 需要导入模块: import oslo_i18n [as 别名]
# 或者: from oslo_i18n import get_available_languages [as 别名]
def best_match_language(self):
        """Determines best available locale from the Accept-Language header.

        :returns: the best language match or None if the 'Accept-Language'
                  header was not available in the request.
        """
        if not self.accept_language:
            return None
        all_languages = i18n.get_available_languages('tacker')
        return self.accept_language.best_match(all_languages) 
开发者ID:openstack,项目名称:tacker,代码行数:12,代码来源:wsgi.py

示例10: best_match_language

# 需要导入模块: import oslo_i18n [as 别名]
# 或者: from oslo_i18n import get_available_languages [as 别名]
def best_match_language(self):
        """Determine best available locale from the Accept-Language header.

        :returns: the best language match or None if the 'Accept-Language'
                  header was not available in the request.
        """
        if not self.accept_language:
            return None
        all_languages = oslo_i18n.get_available_languages('senlin')
        return self.accept_language.best_match(all_languages) 
开发者ID:openstack,项目名称:senlin,代码行数:12,代码来源:wsgi.py


注:本文中的oslo_i18n.get_available_languages方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。