Example #1
0
    def process_request(self, request):
        # No locale for static media
        # This avoids touching user session, which means we avoid
        # setting `Vary: Cookie` as a response header which will
        # break HTTP caching entirely.
        self.__skip_caching = request.path_info.startswith(settings.ANONYMOUS_STATIC_PREFIXES)
        if self.__skip_caching:
            return

        safe_execute(self.load_user_conf, request, _with_transaction=False)

        lang_code = request.GET.get('lang')
        # user is explicitly forcing language
        if lang_code:
            try:
                language = _trans.get_supported_language_variant(lang_code)
            except LookupError:
                super(SentryLocaleMiddleware, self).process_request(request)
            else:
                _trans.activate(language)
                request.LANGUAGE_CODE = _trans.get_language()
        else:
            super(SentryLocaleMiddleware, self).process_request(request)
Example #2
0
    def process_request(self, request):
        # No locale for static media
        # This avoids touching user session, which means we avoid
        # setting `Vary: Cookie` as a response header which will
        # break HTTP caching entirely.
        self.__skip_caching = request.path_info.startswith(settings.ANONYMOUS_STATIC_PREFIXES)
        if self.__skip_caching:
            return

        safe_execute(self.load_user_conf, request, _with_transaction=False)

        lang_code = request.GET.get('lang')
        # user is explicitly forcing language
        if lang_code:
            try:
                language = _trans.get_supported_language_variant(lang_code)
            except LookupError:
                super(SentryLocaleMiddleware, self).process_request(request)
            else:
                _trans.activate(language)
                request.LANGUAGE_CODE = _trans.get_language()
        else:
            super(SentryLocaleMiddleware, self).process_request(request)
Example #3
0
 def plural(number):
     return bool(_trans.translation(_trans.get_language()).plural(number))