I have a django template that I want to translate a value that is variable, since it is inside a for.
The line is the following: {{item.title}} I want to translate what is inside that variable of the template.
What I did was {{{% trans 'item.title'%}}} and then in the django.po file the following:
#: templates/tittle.html:10 (line where the variable to be translated)
msgid "Tittle"
msgstr "Titulo"
#: templates/tittle.html:10
msgid "Tittle2"
msgstr "Titulo2"
And so for all the case of for. This does not work for me So I ask what I'm doing wrong, or if there is some other way to do it.
Thank you very much in advance.
Like specified in the documentation, you can specify a variable in a
{% trans .. %}
tag, by just omitting the quotes, like:It is however a bit "unsafe" in the sense that a title can probably be anything, and is therefore not per se translatable. In case there is no translation, Django will default to the original value of
item.title
.