Ticket #5591: blocktrans_i18n_docs.diff
File blocktrans_i18n_docs.diff, 1.7 KB (added by , 16 years ago) |
---|
-
docs/i18n.txt
219 219 different syntax than in Python code. To give your template access to these 220 220 tags, put ``{% load i18n %}`` toward the top of your template. 221 221 222 The ``{% trans %}`` template tag translates a constant string or a variable223 content::222 The ``{% trans %}`` template tag translates either a constant string 223 (enclosed in single or double quotes) or variable content:: 224 224 225 225 <title>{% trans "This is the title." %}</title> 226 <title>{% trans myvar %}</title> 226 227 227 If you only want to mark a value for translation, but translate it later from a 228 variable, use the ``noop`` option:: 228 If the ``noop`` option is present, variable lookup still takes place but the 229 translation is skipped. This is useful when "stubbing out" content that will 230 require translation in the future:: 229 231 230 <title>{% trans " value" noop %}</title>232 <title>{% trans "myvar" noop %}</title> 231 233 232 It's not possible to use template variables in ``{% trans %}`` -- only constant233 strings, in single or double quotes, are allowed. If your translations require 234 variables (placeholders),use ``{% blocktrans %}``. Example::234 It's not possible to mix a template variable inside a string within 235 ``{% trans %}``. If your translations require strings with variables (placeholders), 236 use ``{% blocktrans %}``. Example:: 235 237 236 {% blocktrans %}This will have {{ value }} inside.{% endblocktrans %}238 {% blocktrans %}This string will have {{ value }} inside.{% endblocktrans %} 237 239 238 240 To translate a template expression -- say, using template filters -- you need 239 241 to bind the expression to a local variable for use within the translation