The first thing that we want to do is translate all the static content on our site. This includes all the headlines, links, and form labels that you have seen in the preceding three screens. To translate strings that are used in templates, Django provides us with a trans
template tag. Let's take a look at how to use it first in a simple context, and then I'll go into the details of how it works. This is a slightly long section as we will do a lot of things here that make up the foundation of the translation feature of Django.
Tip
Don't be alarmed if you don't understand something. Just keep following the instructions. I'll go into a lot of depth about each step, but first I want to show you exactly how translations are done.
Open up main/templates/movies_list.html
, and replace Movies List
in the h2
tag with the following:
{% trans "Movies List" %}
Add the following load
tag to the second line of the file, right after the extends
tag:
{% load i18n %}
That's all the...