當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。