Ticket #5591: i18n_r8520_after_docsrefactor.patch
File i18n_r8520_after_docsrefactor.patch, 1.7 KB (added by , 16 years ago) |
---|
-
i18n.txt
219 219 tags and a slightly different syntax than in Python code. To give your template 220 220 access to these 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