예제 #1
0
 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
0
 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"))
예제 #3
0
 def set_language(self, locale):
     try:
         Translator.set(str(locale))
     except Exception as e:
         log.exception(e)
예제 #4
0
 def set_language(self, locale):
     try:
         Translator.set(str(locale))
     except Exception as e:
         log.exception(e)
예제 #5
0
 def set_language(self, locale):
     try:
         Translator.set(str(locale))
     except RuntimeError as e:
         log.exception(repr(e))
예제 #6
0
 def set_language(self, locale):
     try:
         Translator.set(str(locale))
     except RuntimeError as e:
         log.exception(repr(e))