当前位置: 首页>>代码示例>>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;未经允许,请勿转载。