MCPcopy
hub / github.com/django/django / _i18n_cache_key_suffix

Function _i18n_cache_key_suffix

django/utils/cache.py:339–348  ·  view source on GitHub ↗

If necessary, add the current locale or time zone to the cache key.

(request, cache_key)

Source from the content-addressed store, hash-verified

337
338
339def _i18n_cache_key_suffix(request, cache_key):
340 """If necessary, add the current locale or time zone to the cache key."""
341 if settings.USE_I18N:
342 # first check if LocaleMiddleware or another middleware added
343 # LANGUAGE_CODE to request, then fall back to the active language
344 # which in turn can also fall back to settings.LANGUAGE_CODE
345 cache_key += ".%s" % getattr(request, "LANGUAGE_CODE", get_language())
346 if settings.USE_TZ:
347 cache_key += ".%s" % get_current_timezone_name()
348 return cache_key
349
350
351def _generate_cache_key(request, method, headerlist, key_prefix):

Callers 2

_generate_cache_keyFunction · 0.85

Calls 2

get_languageFunction · 0.90

Tested by

no test coverage detected