Fixed #14806 -- Added support for contextual translations to the trans and blocktrans template tags. Thanks to jtiai for the report.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@17015 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Julien Phalip 2011-10-19 04:59:47 +00:00
parent 358e5a8031
commit 26698bc851
10 changed files with 324 additions and 22 deletions

View file

@ -266,6 +266,11 @@ will appear in the .po file as:
msgid "May"
msgstr ""
.. versionadded:: 1.4
Contextual markers are also supported by the :ttag:`trans` and
:ttag:`blocktrans` template tags.
.. _lazy-translations:
Lazy translation
@ -453,7 +458,7 @@ It's not possible to mix a template variable inside a string within ``{% trans
%}``. If your translations require strings with variables (placeholders), use
``{% blocktrans %}`` instead.
.. versionchanged:: 1.4
.. versionadded:: 1.4
If you'd like to retrieve a translated string without displaying it, you can
use the following syntax::
@ -479,6 +484,15 @@ or should be used as arguments for other template tags or filters::
{% endfor %}
</p>
.. versionadded:: 1.4
``{% trans %}`` also supports :ref:`contextual markers<contextual-markers>`
using the ``context`` keyword:
.. code-block:: html+django
{% trans "May" context "month name" %}
.. templatetag:: blocktrans
``blocktrans`` template tag
@ -560,6 +574,15 @@ be retrieved (and stored) beforehand::
This is a URL: {{ the_url }}
{% endblocktrans %}
.. versionadded:: 1.4
``{% blocktrans %}`` also supports :ref:`contextual
markers<contextual-markers>` using the ``context`` keyword:
.. code-block:: html+django
{% blocktrans with name=user.username context "greeting" %}Hi {{ name }}{% endblocktrans %}
.. _template-translation-vars:
Other tags