As I promised at the start of the previous section, after seeing Django translations in action, we will now take a deeper look into all the steps we followed to get to this point and what each of these steps did.
The first thing that we did was load the i18n template tags library, which provides us with a variety of template tags to translate content in the template. The most important, and probably the one that you will use the most, is the trans
tag. The trans
tag accepts a string argument and, depending on the language that is active, outputs the correct translation for that string. If the translation cannot be found, the original string is output instead.
Almost any string that you write in your templates will end up being wrapped by the trans
tag and then later translated to the various languages that your web application is available in. There are certain situations in which the trans
tag is not usable. For instance, if you have to add the value of some context...