Ticket #5241: locale.diff

File locale.diff, 1.1 KB (added by bittor, 17 years ago)

Patch

  • django/middleware/locale.py

     
    22
    33from django.utils.cache import patch_vary_headers
    44from django.utils import translation
     5import new
    56
    67class LocaleMiddleware(object):
    78    """
     
    2021    def process_response(self, request, response):
    2122        patch_vary_headers(response, ('Accept-Language',))
    2223        response['Content-Language'] = translation.get_language()
    23         translation.deactivate()
     24        # deactivate translation on close (last step in request
     25        # handling) in order to translate iterator based responses.
     26        def locale_middleware_close(self):
     27            self.locale_middleware_original_close()
     28            translation.deactivate()
     29        response.locale_middleware_original_close = response.close
     30        response.close = new.instancemethod(locale_middleware_close,
     31                                            response, response.__class__)
    2432        return response
Back to Top