diff options
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/releases/1.4.txt | 8 | ||||
| -rw-r--r-- | docs/topics/i18n/internationalization.txt | 25 |
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 |
