Search code examples
djangodjango-templatesdjango-i18n

Django i18n + template include tags


I need to render a translated testimonial and I use an include block for the testimonial code like so:

{% include "includes/blog/testimonial.html" with text="This is the best product I've ever used!" name="Tim Z" description="Store Manager" %}

How would I use blocktrans together with the include tag to render the translated include tag?

Thanks!!


Solution

  • If I understand correctly you want to translate the text you provide to an "include" tag. If this is correct just translate it beforehand and save the result to a variable:

    {% trans "This is the best product I've ever used!" as text %}
    {% trans "Store Manager" as description %}
    {% include "includes/blog/testimonial.html" with text=text name="Tim Z" description=description %}