Esempio n. 1
0
 def set_locale(self, locale=None):
     """Set the locale to `locale'."""
     if not locale:
         locale = self.default
     if locale == self.m_locale:
         return
     if locale not in self.m_locale_data.sections():
         raise LocaleError, 'Unknown locale: %s' % locale
     self.m_locale = locale
     language, territory = util.parse_locale(self.m_locale)
     self.m_language = language
     self.m_territory = territory
     self.m_languages = (self.m_locale, self.m_language)
     self.m_conventions = {}
     self.m_conventions.update(self.m_locale_data.namespace(self.m_territory))
     self.m_conventions.update(self.m_locale_data.namespace(self.m_locale))
Esempio n. 2
0
 def test_roundtrip(self):
     for name,parsed in self.data:
         assert util.create_locale(util.parse_locale(name)) == name
Esempio n. 3
0
 def test_parse(self):
     for name,parsed in self.data:
         assert util.parse_locale(name) == parsed