Code

Ticket #7072: 7072_i18n_context_processor_fix.diff

File 7072_i18n_context_processor_fix.diff, 729 bytes (added by akaihola, 6 years ago)

patch for retrieving active language from get_language() instead of request.LANGUAGE_CODE in the i18n context processor

Line 
1Index: django/core/context_processors.py
2===================================================================
3--- django/core/context_processors.py   (revision 7438)
4+++ django/core/context_processors.py   (working copy)
5@@ -40,12 +40,9 @@
6 def i18n(request):
7     context_extras = {}
8     context_extras['LANGUAGES'] = settings.LANGUAGES
9-    if hasattr(request, 'LANGUAGE_CODE'):
10-        context_extras['LANGUAGE_CODE'] = request.LANGUAGE_CODE
11-    else:
12-        context_extras['LANGUAGE_CODE'] = settings.LANGUAGE_CODE
13 
14     from django.utils import translation
15+    context_extras['LANGUAGE_CODE'] = translation.get_language()
16     context_extras['LANGUAGE_BIDI'] = translation.get_language_bidi()
17 
18     return context_extras