-
Book Overview & Buying
-
Table Of Contents
Mastering Django: Core
By :
Translations in 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. As with all template tags, this tag needs to be loaded in all templates which use translations, even those templates that extend from other templates which have already loaded the i18n tag.
The {% trans %} template tag translates either a constant string (enclosed in single or double quotes) or variable content:
<title>{% trans "This is the title." %}</title>
<title>{% trans myvar %}</title>
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:
<title>{% trans "myvar" noop %}</title>
Internally, inline translations use an ugettext() call.
In case a...
Change the font size
Change margin width
Change background colour