当前位置: 首页>>代码示例>>Python>>正文


Python Translator.locale方法代码示例

本文整理汇总了Python中nxdrive.wui.translator.Translator.locale方法的典型用法代码示例。如果您正苦于以下问题:Python Translator.locale方法的具体用法?Python Translator.locale怎么用?Python Translator.locale使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在nxdrive.wui.translator.Translator的用法示例。


在下文中一共展示了Translator.locale方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: testLoadFile

# 需要导入模块: from nxdrive.wui.translator import Translator [as 别名]
# 或者: from nxdrive.wui.translator.Translator import locale [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"))
开发者ID:Bindupriya,项目名称:nuxeo-drive,代码行数:31,代码来源:test_translator.py

示例2: testLoadExistingLanguage

# 需要导入模块: from nxdrive.wui.translator import Translator [as 别名]
# 或者: from nxdrive.wui.translator.Translator import locale [as 别名]
 def testLoadExistingLanguage(self):
     Translator(MockManager(),  self.getFolder('i18n.js'), "fr")
     # Should not fallback on en
     self.assertEqual("fr", Translator.locale())
     # Test the key fallback
     self.assertEqual("Fallback", Translator.get("FALLBACK"))
     self.assertEqual(u"Fran\xe7ais", Translator.get("LANGUAGE"))
     self.assertEqual("BOUZOUF", Translator.get("BOUZOUF"))
开发者ID:Bindupriya,项目名称:nuxeo-drive,代码行数:10,代码来源:test_translator.py

示例3: locale

# 需要导入模块: from nxdrive.wui.translator import Translator [as 别名]
# 或者: from nxdrive.wui.translator.Translator import locale [as 别名]
 def locale(self):
     try:
         return Translator.locale()
     except Exception as e:
         log.exception(e)
         return ""
开发者ID:BryanSchacht,项目名称:nuxeo-drive,代码行数:8,代码来源:dialog.py

示例4: testLoadNonExistingLanguage

# 需要导入模块: from nxdrive.wui.translator import Translator [as 别名]
# 或者: from nxdrive.wui.translator.Translator import locale [as 别名]
 def testLoadNonExistingLanguage(self):
     Translator(MockManager(),  self.getFolder('i18n.js'), "es")
     # Should fallback on en
     self.assertEqual("en", Translator.locale())
开发者ID:Bindupriya,项目名称:nuxeo-drive,代码行数:6,代码来源:test_translator.py

示例5: test_load_bad_language

# 需要导入模块: from nxdrive.wui.translator import Translator [as 别名]
# 或者: from nxdrive.wui.translator.Translator import locale [as 别名]
 def test_load_bad_language(self):
     Translator(MockManager(),  get_folder('i18n.js'), "zzzzzz")
     # Should fallback on en
     self.assertEqual("en", Translator.locale())
开发者ID:ssdi-drive,项目名称:nuxeo-drive,代码行数:6,代码来源:test_translator.py

示例6: locale

# 需要导入模块: from nxdrive.wui.translator import Translator [as 别名]
# 或者: from nxdrive.wui.translator.Translator import locale [as 别名]
 def locale(self):
     try:
         return Translator.locale()
     except RuntimeError as e:
         log.exception(repr(e))
         return ''
开发者ID:ssdi-drive,项目名称:nuxeo-drive,代码行数:8,代码来源:dialog.py


注:本文中的nxdrive.wui.translator.Translator.locale方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。