diff options
| author | Matthew Somerville <matthew-github@dracos.co.uk> | 2015-06-12 13:51:28 +0100 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2015-07-01 10:03:00 -0400 |
| commit | 839edcebb39f55acf163266f1ce1f0dc537de95b (patch) | |
| tree | afca4d9d29d470d54673e87e8147f48a3d0c8d33 /docs | |
| parent | b35b43dff81d46e930ffa1e05eb50968b8557102 (diff) | |
Fixed #21695 -- Added asvar option to blocktrans.
Thanks Bojan Mihelac for the initial patch.
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/releases/1.9.txt | 3 | ||||
| -rw-r--r-- | docs/topics/i18n/translation.txt | 20 |
2 files changed, 21 insertions, 2 deletions
diff --git a/docs/releases/1.9.txt b/docs/releases/1.9.txt index 9f2dd6ccd1..b80d14f985 100644 --- a/docs/releases/1.9.txt +++ b/docs/releases/1.9.txt @@ -332,6 +332,9 @@ Internationalization project and it will find all the app message files that were created by :djadmin:`makemessages`. +* :ttag:`blocktrans` supports assigning its output to a variable using + ``asvar``. + Management Commands ^^^^^^^^^^^^^^^^^^^ diff --git a/docs/topics/i18n/translation.txt b/docs/topics/i18n/translation.txt index 1ab2dae273..e19ee1220b 100644 --- a/docs/topics/i18n/translation.txt +++ b/docs/topics/i18n/translation.txt @@ -580,8 +580,9 @@ use the following syntax:: <title>{{ the_title }}</title> <meta name="description" content="{{ the_title }}"> -In practice you'll use this to get strings that are used in multiple places -or should be used as arguments for other template tags or filters:: +In practice you'll use this to get a string you can use in multiple places in a +template or so you can use the output as an argument for other template tags or +filters:: {% trans "starting point" as start %} {% trans "end point" as end %} @@ -682,6 +683,21 @@ be retrieved (and stored) beforehand:: This is a URL: {{ the_url }} {% endblocktrans %} +If you'd like to retrieve a translated string without displaying it, you can +use the following syntax:: + + {% blocktrans asvar the_title %}The title is {{ title }}.{% endblocktrans %} + <title>{{ the_title }}</title> + <meta name="description" content="{{ the_title }}"> + +In practice you'll use this to get a string you can use in multiple places in a +template or so you can use the output as an argument for other template tags or +filters. + +.. versionchanged:: 1.9 + + The ``asvar`` syntax was added. + ``{% blocktrans %}`` also supports :ref:`contextual markers<contextual-markers>` using the ``context`` keyword: |
