本文整理汇总了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)
示例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()
示例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)
示例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()
示例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()
示例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()
示例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()
示例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
示例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, {})
示例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)
示例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