Ticket #17443: cookie_overrides_session_lang_variations.patch
File cookie_overrides_session_lang_variations.patch, 813 bytes (added by , 13 years ago) |
---|
-
django/utils/translation/trans_real.py
def get_language_from_request(request): 367 367 global _accepted 368 368 from django.conf import settings 369 369 supported = dict(settings.LANGUAGES) 370 lang_code = None 370 371 371 372 if hasattr(request, 'session'): 372 373 lang_code = request.session.get('django_language', None) 373 374 if lang_code in supported and lang_code is not None and check_for_language(lang_code): 374 375 return lang_code 375 376 376 lang_code = request.COOKIES.get(settings.LANGUAGE_COOKIE_NAME) 377 if not lang_code: 378 lang_code = request.COOKIES.get(settings.LANGUAGE_COOKIE_NAME) 377 379 378 380 if lang_code and lang_code not in supported: 379 381 lang_code = lang_code.split('-')[0] # e.g. if fr-ca is not supported fallback to fr