Code

Ticket #13014: 13014_doc.diff

File 13014_doc.diff, 1.4 KB (added by anonymous, 4 years ago)
Line 
1Index: docs/topics/cache.txt
2===================================================================
3--- docs/topics/cache.txt       (revision 12777)
4+++ docs/topics/cache.txt       (working copy)
5@@ -434,6 +434,21 @@
6 It's perfectly fine to specify more than one argument to identify the fragment.
7 Simply pass as many arguments to ``{% cache %}`` as you need.
8 
9+.. versionadded:: 1.2
10+
11+If :setting:`USE_I18N` is set to ``True`` then the generated cache keys from
12+the per-site middleware cache will include the name of the active
13+:term:`language<language code>`. This allows you to easily cache multilingual
14+sites without having to create the cache key yourself. For the ``cache``
15+template tag you could use the following code to imitate this behaviour::
16+
17+    {% load i18n %}.
18+    {% load cache %}
19+    {% get_current_language as LANGUAGE_CODE %}
20+    {% cache 60 welcome LANGUAGE_CODE %}
21+        {% trans "Welcome to example.com" %}
22+    {% endcache %}
23+
24 The cache timeout can be a template variable, as long as the template variable
25 resolves to an integer value. For example, if the template variable
26 ``my_timeout`` is set to the value ``600``, then the following two examples are
27@@ -813,4 +828,3 @@
28 runs *first* during the request phase. The ``FetchFromCacheMiddleware`` also
29 needs to run after other middleware updates the ``Vary`` header, so
30 ``FetchFromCacheMiddleware`` must be *after* any item that does so.
31-