Ticket #17443: cookie_overrides_session_lang_variations.patch

File cookie_overrides_session_lang_variations.patch, 813 bytes (added by sdistefano, 12 years ago)
  • django/utils/translation/trans_real.py

    def get_language_from_request(request):  
    367367    global _accepted
    368368    from django.conf import settings
    369369    supported = dict(settings.LANGUAGES)
     370    lang_code = None
    370371
    371372    if hasattr(request, 'session'):
    372373        lang_code = request.session.get('django_language', None)
    373374        if lang_code in supported and lang_code is not None and check_for_language(lang_code):
    374375            return lang_code
    375376
    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)
    377379
    378380    if lang_code and lang_code not in supported:
    379381        lang_code = lang_code.split('-')[0] # e.g. if fr-ca is not supported fallback to fr
Back to Top