Commits

Yann Malet committed 7825fa2

Update the fix based on the feedback done by jezdez

  • Participants
  • Parent commits 1d1c960

Comments (0)

Files changed (1)

File multilingual_cache/utils/cache.py

     path = md5_constructor(iri_to_uri(request.path))
     cache_key = 'views.decorators.cache.cache_page.%s.%s.%s' % (
         key_prefix, path.hexdigest(), ctx.hexdigest()) 
-    if settings.USE_I18N: 
-        cache_key += ".%s" % request.LANGUAGE_CODE 
+    if settings.USE_I18N:
+        cache_key += ".%s" % translation.get_language_from_request(request)
     return cache_key 
 
 def _generate_cache_header_key(key_prefix, request):
         key_prefix = settings.CACHE_MIDDLEWARE_KEY_PREFIX
     cache_key = _generate_cache_header_key(key_prefix, request)
     if settings.USE_I18N: 
-        cache_key += ".%s" % request.LANGUAGE_CODE 
+        cache_key += ".%s" % translation.get_language_from_request(request)
     headerlist = cache.get(cache_key, None)
     if headerlist is not None:
         return _generate_cache_key(request, headerlist, key_prefix)
         cache_timeout = settings.CACHE_MIDDLEWARE_SECONDS
     cache_key = _generate_cache_header_key(key_prefix, request)
     if settings.USE_I18N: 
-        cache_key += ".%s" % request.LANGUAGE_CODE
+        cache_key += ".%s" % translation.get_language_from_request(request)
     if response.has_header('Vary'):
         headerlist = ['HTTP_'+header.upper().replace('-', '_')
                       for header in cc_delim_re.split(response['Vary'])]