diff --git a/django/middleware/locale.py b/django/middleware/locale.py
index b5e4949..626fd4f 100644
a
|
b
|
|
1 | 1 | "this is the locale selecting middleware that will look at accept headers" |
2 | 2 | |
| 3 | from django.conf import settings |
3 | 4 | from django.utils.cache import patch_vary_headers |
4 | 5 | from django.utils import translation |
5 | 6 | |
… |
… |
class LocaleMiddleware(object):
|
18 | 19 | request.LANGUAGE_CODE = translation.get_language() |
19 | 20 | |
20 | 21 | def process_response(self, request, response): |
| 22 | if hasattr(request, 'session'): |
| 23 | if not request.session.has_key('django_language'): |
| 24 | request.session['django_language'] = translation.get_language() |
| 25 | else: |
| 26 | # sessions are not used |
| 27 | if not response.cookies.has_key(settings.LANGUAGE_COOKIE_NAME): |
| 28 | response.set_cookie(settings.LANGUAGE_COOKIE_NAME, translation.get_language()) |
| 29 | |
21 | 30 | patch_vary_headers(response, ('Accept-Language',)) |
22 | 31 | if 'Content-Language' not in response: |
23 | 32 | response['Content-Language'] = translation.get_language() |