我们从Python开源项目中,提取了以下22个代码示例,用于说明如何使用gettext._translations()。
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)
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()
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()
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()