Translate Strings in Templates
A snippet showing how to translate template text using {% trans %}.
<!-- templates/home.html -->
{% load i18n %}
<h1>{% trans "Welcome" %}</h1>
<p>{% trans "This site supports multiple languages." %}</p>
{# Variable substitution #}
<p>{% trans "Hello %(name)s!" %} {% comment %}use with blocktrans for variables{% endcomment %}</p>
Explanation:
-
Load the
i18nlibrary:{% load i18n %}.
- Category Internationalization (i18n)
- Total Views 392
- Last Modified 10 June, 2026
- Tags #i18n #translation #templates #gettext
Previous snippet
Mark Strings for Translation
Next snippet