Internationalization: In template code

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.

trans template 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. ...

Get Mastering Django: Core now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.