Code

Ticket #5603: language_cookie_name.diff

File language_cookie_name.diff, 1.7 KB (added by moe, 7 years ago)

patch: add LANGUAGE_COOKIE_NAME

Line 
1Index: django/utils/translation/trans_real.py
2===================================================================
3--- django/utils/translation/trans_real.py      (revision 6424)
4+++ django/utils/translation/trans_real.py      (working copy)
5@@ -338,7 +338,7 @@
6         if lang_code in supported and lang_code is not None and check_for_language(lang_code):
7             return lang_code
8 
9-    lang_code = request.COOKIES.get('django_language', None)
10+    lang_code = request.COOKIES.get( settings.LANGUAGE_COOKIE_NAME, None)
11     if lang_code in supported and lang_code is not None and check_for_language(lang_code):
12         return lang_code
13
14Index: django/views/i18n.py
15===================================================================
16--- django/views/i18n.py        (revision 6424)
17+++ django/views/i18n.py        (working copy)
18@@ -22,7 +22,7 @@
19         if hasattr(request, 'session'):
20             request.session['django_language'] = lang_code
21         else:
22-            response.set_cookie('django_language', lang_code)
23+            response.set_cookie(settings.LANGUAGE_COOKIE_NAME, lang_code)
24     return response
25 
26 NullSource = """
27
28Index: django/conf/global_settings.py
29===================================================================
30--- django/conf/global_settings.py      (revision 6424)
31+++ django/conf/global_settings.py      (working copy)
32@@ -90,6 +90,12 @@
33 # to load the internationalization machinery.
34 USE_I18N = True
35 
36+#
37+# Make sure that this is different to to all
38+# other cookie names (e.g. SESSION_COOKIE_NAME)
39+#
40+LANGUAGE_COOKIE_NAME = 'django_language'
41+
42 # Not-necessarily-technical managers of the site. They get broken link
43 # notifications and other various e-mails.
44 MANAGERS = ADMINS
45