Esempio n. 1
0
 def test_load_translation(self):
     # Load default translation
     i18n.get_lang(self.mo_dir, 'en_US', 'messages')
     t = cherrypy.response.i18n.trans
     l = cherrypy.response.i18n.locale
     self.assertIsInstance(t, gettext.GNUTranslations)
     self.assertEqual("en", l.language)
Esempio n. 2
0
 def test_translation_with_en_us(self):
     # Get trans
     i18n.get_lang(self.mo_dir, 'en_US', 'messages')
     t = cherrypy.response.i18n.trans
     l = cherrypy.response.i18n.locale
     self.assertIsInstance(t, gettext.GNUTranslations)
     self.assertEqual("en", l.language)
     pass
Esempio n. 3
0
 def test_load_translation_with_accept_language_unknown(self):
     # Mock a header
     cherrypy.request.headers["Accept-Language"] = "br_CA"
     # Load default translation
     i18n.get_lang(self.mo_dir, 'en_US', 'messages')
     t = cherrypy.response.i18n.trans
     l = cherrypy.response.i18n.locale
     self.assertIsInstance(t, gettext.GNUTranslations)
     self.assertEqual("en", l.language)
Esempio n. 4
0
 def test_translation_with_fr_en(self):
     # Get trans
     i18n.get_lang(self.mo_dir, 'fr', 'messages')
     t = cherrypy.response.i18n.trans
     l = cherrypy.response.i18n.locale
     self.assertIsInstance(t, gettext.GNUTranslations)
     self.assertEqual("fr", l.language)
     # Test translation object
     self.assertEqual("Modifier", t.gettext("Edit"))
     pass
Esempio n. 5
0
 def test_translation_with_en_fr(self):
     # Get trans
     i18n.get_lang(self.mo_dir, 'en', 'messages')
     t = cherrypy.response.i18n.trans
     l = cherrypy.response.i18n.locale
     self.assertIsInstance(t, gettext.GNUTranslations)
     self.assertEqual("en", l.language)
     # Test translation object
     self.assertEqual("Edit", t.gettext("Edit"))
     # Check if the translation fallback
     self.assertEqual("Invalid String", t.gettext("Invalid String"))
     pass