Reputation: 2552
Is there a way to set translation messages parametrically in Django? For example, when I need to traslate a message in a template, I always need to write the whole text:
<h1>{% trans "Hello World" %}</h1>
Instead, I'm wondering if there is something that allows to use variables, something similar to Ruby on Rails:
<h1><%= t :hello_world %></h1>
Upvotes: 0
Views: 257
Reputation: 4150
As stated in the trans
template tag documentation you can pass a variable in the same way you pass a string literal:
<h1>{% trans myvar %}</h1>
Of course that variable need to be available in the template context
Upvotes: 1