summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorJulien Phalip <jphalip@gmail.com>2011-10-19 04:59:47 +0000
committerJulien Phalip <jphalip@gmail.com>2011-10-19 04:59:47 +0000
commit26698bc85123935d5926a87a45cae25efe683639 (patch)
tree6932998940436b4362a8a6c8d167aca1e647d5cb /docs
parent358e5a8031be14efe33dc62e821408c2a6a8e85a (diff)
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
Diffstat (limited to 'docs')
-rw-r--r--docs/releases/1.4.txt8
-rw-r--r--docs/topics/i18n/internationalization.txt25
2 files changed, 32 insertions, 1 deletions
diff --git a/docs/releases/1.4.txt b/docs/releases/1.4.txt
index 3e364fbe23..00acc65922 100644
--- a/docs/releases/1.4.txt
+++ b/docs/releases/1.4.txt
@@ -191,6 +191,14 @@ Additionally, it's now possible to define translatable URL patterns using
:ref:`url-internationalization` for more information about the language prefix
and how to internationalize URL patterns.
+Contextual translation support for ``{% trans %}`` and ``{% blocktrans %}``
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Django 1.3 introduced :ref:`contextual translation<contextual-markers>` support
+in Python files via the ``pgettext`` function. This is now also supported by
+the :ttag:`trans` and :ttag:`blocktrans` template tags using the new
+``context`` keyword.
+
Customizable ``SingleObjectMixin`` URLConf kwargs
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
diff --git a/docs/topics/i18n/internationalization.txt b/docs/topics/i18n/internationalization.txt
index b06c9bdfdb..c8611acff8 100644
--- a/docs/topics/i18n/internationalization.txt
+++ b/docs/topics/i18n/internationalization.txt
@@ -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