Ticket #12794: cooki18n.patch
File cooki18n.patch, 3.0 KB (added by , 13 years ago) |
---|
-
django/views/i18n.py
29 29 if request.method == 'POST': 30 30 lang_code = request.POST.get('language', None) 31 31 if lang_code and check_for_language(lang_code): 32 if hasattr(request, 'session'):32 if False and hasattr(request, 'session'): 33 33 request.session['django_language'] = lang_code 34 34 else: 35 35 response.set_cookie(settings.LANGUAGE_COOKIE_NAME, lang_code) -
django/utils/translation/trans_real.py
375 375 if lang_code is not None: 376 376 return lang_code 377 377 378 if hasattr(request, 'session'):378 if False and hasattr(request, 'session'): 379 379 lang_code = request.session.get('django_language', None) 380 380 if lang_code in supported and lang_code is not None and check_for_language(lang_code): 381 381 return lang_code -
django/middleware/locale.py
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.core.urlresolvers import get_resolver, LocaleRegexURLResolver 4 5 from django.http import HttpResponseRedirect 5 6 from django.utils.cache import patch_vary_headers … … 32 33 patch_vary_headers(response, ('Accept-Language',)) 33 34 if 'Content-Language' not in response: 34 35 response['Content-Language'] = language 36 if not response.cookies.has_key(settings.LANGUAGE_COOKIE_NAME): 37 response.set_cookie(settings.LANGUAGE_COOKIE_NAME, 38 language) 35 39 return response 36 40 37 41 def is_language_prefix_patterns_used(self): -
tests/regressiontests/views/tests/i18n.py
19 19 post_data = dict(language=lang_code, next='/views/') 20 20 response = self.client.post('/views/i18n/setlang/', data=post_data) 21 21 self.assertRedirects(response, 'http://testserver/views/') 22 self.assertEqual(self.client.session['django_language'], lang_code) 22 if False: 23 self.assertEqual(self.client.session['django_language'], 24 lang_code) 25 else: 26 self.assertEqual \ 27 (response.cookies[settings.LANGUAGE_COOKIE_NAME].value, 28 lang_code) 23 29 24 30 def test_jsi18n(self): 25 31 """The javascript_catalog can be deployed with language settings"""