From f964a6e4723df9bbf9d22f0fbde3222f513b00e2 Mon Sep 17 00:00:00 2001 From: Jacob Kaplan-Moss Date: Mon, 25 Aug 2008 19:28:41 +0000 Subject: [PATCH] Fixed #5591: corrected info about variables in `trans` tag. Thanks, idangazit. git-svn-id: http://code.djangoproject.com/svn/django/trunk@8551 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- docs/topics/i18n.txt | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/docs/topics/i18n.txt b/docs/topics/i18n.txt index 5103cb873c..daf65d0909 100644 --- a/docs/topics/i18n.txt +++ b/docs/topics/i18n.txt @@ -219,21 +219,23 @@ Translations in :ref:`Django templates ` uses two template tags and a slightly different syntax than in Python code. To give your template access to these tags, put ``{% load i18n %}`` toward the top of your template. -The ``{% trans %}`` template tag translates a constant string or a variable -content:: +The ``{% trans %}`` template tag translates either a constant string +(enclosed in single or double quotes) or variable content:: {% trans "This is the title." %} + {% trans myvar %} -If you only want to mark a value for translation, but translate it later from a -variable, use the ``noop`` option:: +If the ``noop`` option is present, variable lookup still takes place but the +translation is skipped. This is useful when "stubbing out" content that will +require translation in the future:: - {% trans "value" noop %} + {% trans "myvar" noop %} -It's not possible to use template variables in ``{% trans %}`` -- only constant -strings, in single or double quotes, are allowed. If your translations require -variables (placeholders), use ``{% blocktrans %}``. Example:: +It's not possible to mix a template variable inside a string within +``{% trans %}``. If your translations require strings with variables (placeholders), +use ``{% blocktrans %}``. Example:: - {% blocktrans %}This will have {{ value }} inside.{% endblocktrans %} + {% blocktrans %}This string will have {{ value }} inside.{% endblocktrans %} To translate a template expression -- say, using template filters -- you need to bind the expression to a local variable for use within the translation