Fixed #21695 -- Added asvar option to blocktrans.

Thanks Bojan Mihelac for the initial patch.
This commit is contained in:
Matthew Somerville 2015-06-12 13:51:28 +01:00 committed by Tim Graham
parent b35b43dff8
commit 839edcebb3
4 changed files with 80 additions and 5 deletions

View file

@ -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: