Reputation: 3262
I am facing a prob in django. The following is my code snippet :
{% if pageName != 'My page Name' %}
.....{{ then this }}
Now this works fine for English , Now when i translated my application in another language the pageName
also changed according to that language. So the above logic is not working as it is hard coded English
So i have to try to implement the logic with translated version of 'My page Name'
. But i cant use it directly in if
like :
{% if pageName != trans 'My page Name' %}
So I thought of storing the translated version in another variable and then check with that variable like :
{%blocktrans%} "My page Name" {{myvar}} {%endblocktrans%}
{% if pageName != myvar %}
But this is also not working myvar
takes the value "My page Name"
, not the translated version of it.
Any clue how to fix it. Thanks in advance.
Upvotes: 7
Views: 9182
Reputation: 680
You can use trans template tag but this way
{% trans "My page Name" as myvar %}
{% if pageName != myvar %}
...
Upvotes: 12