當前位置: 首頁>>代碼示例>>Python>>正文


Python gettext._translations方法代碼示例

本文整理匯總了Python中gettext._translations方法的典型用法代碼示例。如果您正苦於以下問題:Python gettext._translations方法的具體用法?Python gettext._translations怎麽用?Python gettext._translations使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在gettext的用法示例。


在下文中一共展示了gettext._translations方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_cache

# 需要導入模塊: import gettext [as 別名]
# 或者: from gettext import _translations [as 別名]
def test_cache(self):
        self.localedir = os.curdir
        self.mofile = MOFILE

        self.assertEqual(len(gettext._translations), 0)

        t = gettext.translation('gettext', self.localedir)

        self.assertEqual(len(gettext._translations), 1)

        t = gettext.translation('gettext', self.localedir,
                                class_=DummyGNUTranslations)

        self.assertEqual(len(gettext._translations), 2)
        self.assertEqual(t.__class__, DummyGNUTranslations)

        # Calling it again doesn't add to the cache

        t = gettext.translation('gettext', self.localedir,
                                class_=DummyGNUTranslations)

        self.assertEqual(len(gettext._translations), 2)
        self.assertEqual(t.__class__, DummyGNUTranslations) 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:25,代碼來源:test_gettext.py

示例2: setUp

# 需要導入模塊: import gettext [as 別名]
# 或者: from gettext import _translations [as 別名]
def setUp(self):
        if not os.path.isdir(LOCALEDIR):
            os.makedirs(LOCALEDIR)
        with open(MOFILE, 'wb') as fp:
            fp.write(base64.decodebytes(GNU_MO_DATA))
        with open(MOFILE_BAD_MAJOR_VERSION, 'wb') as fp:
            fp.write(base64.decodebytes(GNU_MO_DATA_BAD_MAJOR_VERSION))
        with open(MOFILE_BAD_MINOR_VERSION, 'wb') as fp:
            fp.write(base64.decodebytes(GNU_MO_DATA_BAD_MINOR_VERSION))
        with open(UMOFILE, 'wb') as fp:
            fp.write(base64.decodebytes(UMO_DATA))
        with open(MMOFILE, 'wb') as fp:
            fp.write(base64.decodebytes(MMO_DATA))
        self.env = support.EnvironmentVarGuard()
        self.env['LANGUAGE'] = 'xx'
        gettext._translations.clear() 
開發者ID:Microvellum,項目名稱:Fluid-Designer,代碼行數:18,代碼來源:test_gettext.py

示例3: reload

# 需要導入模塊: import gettext [as 別名]
# 或者: from gettext import _translations [as 別名]
def reload(self):
		backup_cards = self.all_primary_cards
		backup_languages = self.languages
		for l in self.languages.keys():
			self.languages[l]['db'].close()
		self.languages = dict()
		try:
			for l in backup_languages.keys():
				self.add(l, backup_languages[l]['short'], backup_languages[l]['path'])
			gettext._translations = dict()
			self.set_primary_language(self.primary_language)
			return True
		except LanguageError as e:
			self.languages = backup_languages
			self.all_primary_cards = backup_cards
			return str(e) 
開發者ID:tspivey,項目名稱:yugioh-game,代碼行數:18,代碼來源:language_handler.py

示例4: reset_translations

# 需要導入模塊: import gettext [as 別名]
# 或者: from gettext import _translations [as 別名]
def reset_translations():
    import gettext
    from django.utils.translation import trans_real
    gettext._translations = {}
    trans_real._translations = {}
    trans_real._default = None
    trans_real._active = threading.local() 
開發者ID:lanbing510,項目名稱:GTDWeb,代碼行數:9,代碼來源:autoreload.py

示例5: setUp

# 需要導入模塊: import gettext [as 別名]
# 或者: from gettext import _translations [as 別名]
def setUp(self):
        if not os.path.isdir(LOCALEDIR):
            os.makedirs(LOCALEDIR)
        with open(MOFILE, 'wb') as fp:
            fp.write(base64.decodestring(GNU_MO_DATA))
        with open(UMOFILE, 'wb') as fp:
            fp.write(base64.decodestring(UMO_DATA))
        with open(MMOFILE, 'wb') as fp:
            fp.write(base64.decodestring(MMO_DATA))

        self.env = test_support.EnvironmentVarGuard()
        self.env['LANGUAGE'] = 'xx'
        gettext._translations.clear() 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:15,代碼來源:test_gettext.py

示例6: setUp

# 需要導入模塊: import gettext [as 別名]
# 或者: from gettext import _translations [as 別名]
def setUp(self):
        if not os.path.isdir(LOCALEDIR):
            os.makedirs(LOCALEDIR)
        with open(MOFILE, 'wb') as fp:
            fp.write(base64.decodebytes(GNU_MO_DATA))
        with open(UMOFILE, 'wb') as fp:
            fp.write(base64.decodebytes(UMO_DATA))
        with open(MMOFILE, 'wb') as fp:
            fp.write(base64.decodebytes(MMO_DATA))
        self.env = support.EnvironmentVarGuard()
        self.env['LANGUAGE'] = 'xx'
        gettext._translations.clear() 
開發者ID:IronLanguages,項目名稱:ironpython3,代碼行數:14,代碼來源:test_gettext.py

示例7: setUp

# 需要導入模塊: import gettext [as 別名]
# 或者: from gettext import _translations [as 別名]
def setUp(self):
        self.gettext_translations = gettext._translations.copy()
        self.trans_real_translations = trans_real._translations.copy() 
開發者ID:nesdis,項目名稱:djongo,代碼行數:5,代碼來源:test_autoreload.py

示例8: tearDown

# 需要導入模塊: import gettext [as 別名]
# 或者: from gettext import _translations [as 別名]
def tearDown(self):
        gettext._translations = self.gettext_translations
        trans_real._translations = self.trans_real_translations 
開發者ID:nesdis,項目名稱:djongo,代碼行數:5,代碼來源:test_autoreload.py

示例9: test_resets_gettext

# 需要導入模塊: import gettext [as 別名]
# 或者: from gettext import _translations [as 別名]
def test_resets_gettext(self):
        gettext._translations = {'foo': 'bar'}
        autoreload.reset_translations()
        self.assertEqual(gettext._translations, {}) 
開發者ID:nesdis,項目名稱:djongo,代碼行數:6,代碼來源:test_autoreload.py

示例10: test_resets_trans_real

# 需要導入模塊: import gettext [as 別名]
# 或者: from gettext import _translations [as 別名]
def test_resets_trans_real(self):
        trans_real._translations = {'foo': 'bar'}
        trans_real._default = 1
        trans_real._active = False
        autoreload.reset_translations()
        self.assertEqual(trans_real._translations, {})
        self.assertIsNone(trans_real._default)
        self.assertIsInstance(trans_real._active, _thread._local) 
開發者ID:nesdis,項目名稱:djongo,代碼行數:10,代碼來源:test_autoreload.py

示例11: setUp

# 需要導入模塊: import gettext [as 別名]
# 或者: from gettext import _translations [as 別名]
def setUp(self):
        super().setUp()
        gettext_module._translations = {}  # flush cache or test will be useless 
開發者ID:nesdis,項目名稱:djongo,代碼行數:5,代碼來源:test_compilation.py


注:本文中的gettext._translations方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。