Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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!!

like image 802
tzenderman Avatar asked Mar 19 '26 20:03

tzenderman


1 Answers

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 %}
like image 82
Ludwik Trammer Avatar answered Mar 22 '26 15:03

Ludwik Trammer