コード例 #1
0
ファイル: request.py プロジェクト: passy/glashammer-rdrei
 def _get_locale(self):
     """The locale of the incoming request.  If a locale is unsupported, the
     default english locale is used.  If the locale is assigned it will be
     stored in the session so that that language changes are persistent.
     """
     if self._locale is not None:
         return self._locale
     rv = self.session.get('locale')
     if rv is not None:
         rv = Locale.parse(rv)
         # we could trust the cookie here because it's signed, but we do not
         # because the configuration could have changed in the meantime.
         if not has_section(rv):
             rv = None
     if rv is None:
         rv = select_locale(self.accept_languages)
     self._locale = rv
     return rv
コード例 #2
0
ファイル: request.py プロジェクト: passy/glashammer-rdrei
 def _set_locale(self, locale):
     self._locale = Locale.parse(locale)
     self.__dict__.pop('translations', None)
     self.session['locale'] = str(self._locale)