Reputation: 433
I have the following code:
<ul>
{% for item in array %}
<li>{{ item }}</li>
{% endfor %}
</ul>
I want to translate the item
variable, I've tried using the trans
tag like this:
<ul>
{% for item in array %}
<li>{% trans item %}</li>
{% endfor %}
</ul>
But Django complains with a syntax error stating that it was expecting an empty
or an endfor
Upvotes: 1
Views: 1279
Reputation: 47846
You need to add {% load i18n %}
at the top of your template to use the trans
tag.
From the docs on internationalization:
To give your template access to these tags, put
{% load i18n %}
toward the top of your template.
Upvotes: 1