本文整理汇总了Python中nxdrive.wui.translator.Translator.set方法的典型用法代码示例。如果您正苦于以下问题:Python Translator.set方法的具体用法?Python Translator.set怎么用?Python Translator.set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nxdrive.wui.translator.Translator
的用法示例。
在下文中一共展示了Translator.set方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testLoadFile
# 需要导入模块: from nxdrive.wui.translator import Translator [as 别名]
# 或者: from nxdrive.wui.translator.Translator import set [as 别名]
def testLoadFile(self):
manager = MockManager()
Translator(manager, self.getFolder('i18n.js'))
# Verify the call to save
self.assertTrue(manager.called)
self.assertEqual("en", Translator.locale())
manager.called = False
# Change to an existing language
Translator.set("fr")
self.assertTrue(manager.called)
self.assertEqual("fr", Translator.locale())
# Test unkown key
self.assertEqual("BOUZOUF", Translator.get("BOUZOUF"))
# Test fallback
self.assertEqual("Fallback", Translator.get("FALLBACK"))
manager.called = False
# Try to switch to bad language
self.assertRaises(Exception, Translator.set, "de")
self.assertEqual("fr", Translator.locale())
self.assertFalse(manager.called)
self.assertRaises(Exception, Translator.set, "es")
self.assertEqual("fr", Translator.locale())
# Nothing should be saved
self.assertFalse(manager.called)
# Go back to an existing one
Translator.set("en")
self.assertTrue(manager.called)
self.assertEqual("en", Translator.locale())
self.assertEqual("BOUZOUF", Translator.get("BOUZOUF"))
示例2: set_language
# 需要导入模块: from nxdrive.wui.translator import Translator [as 别名]
# 或者: from nxdrive.wui.translator.Translator import set [as 别名]
def set_language(self, locale):
try:
Translator.set(str(locale))
except Exception as e:
log.exception(e)
示例3: set_language
# 需要导入模块: from nxdrive.wui.translator import Translator [as 别名]
# 或者: from nxdrive.wui.translator.Translator import set [as 别名]
def set_language(self, locale):
try:
Translator.set(str(locale))
except RuntimeError as e:
log.exception(repr(e))