Ticket #5241: locale.diff
File locale.diff, 1.1 KB (added by , 17 years ago) |
---|
-
django/middleware/locale.py
2 2 3 3 from django.utils.cache import patch_vary_headers 4 4 from django.utils import translation 5 import new 5 6 6 7 class LocaleMiddleware(object): 7 8 """ … … 20 21 def process_response(self, request, response): 21 22 patch_vary_headers(response, ('Accept-Language',)) 22 23 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__) 24 32 return response