Example #1
0
 def test_load_translation_with_accept_language_unknown(self):
     # Mock a header
     cherrypy.request.headers["Accept-Language"] = "br_CA"
     # Load default translation
     t = i18n.get_translation()
     self.assertTrue(isinstance(t, gettext.GNUTranslations))
     self.assertEqual("en", t._lang)
Example #2
0
 def test_load_translation_with_accept_language_unknown(self):
     # Mock a header
     cherrypy.request.headers["Accept-Language"] = "br_CA"
     # Load default translation
     t = i18n.get_translation()
     self.assertTrue(isinstance(t, gettext.GNUTranslations))
     self.assertEqual("en", t._lang)
Example #3
0
def _get_translation(domain):
    """
    Used in templates to load a different translation domain.
    """
    t = i18n.get_translation(domain)
    t.ugettext = _make_new_gettext(t.ugettext)
    t.ungettext = _make_new_ngettext(t.ungettext)
    return t
Example #4
0
def _get_translation(domain):
    """
    Used in templates to load a different translation domain.
    """
    t = i18n.get_translation(domain)
    t.ugettext = _make_new_gettext(t.ugettext)
    t.ungettext = _make_new_ngettext(t.ungettext)
    return t
Example #5
0
 def test_load_translation(self):
     # Load default translation
     t = i18n.get_translation()
     self.assertTrue(isinstance(t, gettext.GNUTranslations))
     self.assertEqual("en", t._lang)
Example #6
0
 def test_load_translation(self):
     # Load default translation
     t = i18n.get_translation()
     self.assertTrue(isinstance(t, gettext.GNUTranslations))
     self.assertEqual("en", t._lang)