如何用 Django 翻译变量?
How to translate a variable with django?
我有一个变量 my_variable
,它只能是两个值("Swedish" 或 "English")之一。那为什么我不能这样做 {% trans "{{ my_variable|capfirst }}" %}
?应该怎么做?我想翻译变量,但结果不正确。
{%blocktrans%} This is the title: {{myvar}} {%endblocktrans%}
或
<title>{% trans myvar %}</title>
django translate variable content in template
Just use the {% blocktrans %}
tag to include variable for translation.For more detailesFollow this link with search blocktrans keyword.
{% blocktrans with amount=article.price %}
That will cost $ {{ amount }}.
{% endblocktrans %}
It may help you.Thank you.
我有一个变量 my_variable
,它只能是两个值("Swedish" 或 "English")之一。那为什么我不能这样做 {% trans "{{ my_variable|capfirst }}" %}
?应该怎么做?我想翻译变量,但结果不正确。
{%blocktrans%} This is the title: {{myvar}} {%endblocktrans%}
或
<title>{% trans myvar %}</title>
django translate variable content in template
Just use the
{% blocktrans %}
tag to include variable for translation.For more detailesFollow this link with search blocktrans keyword.
{% blocktrans with amount=article.price %}
That will cost $ {{ amount }}.
{% endblocktrans %}
It may help you.Thank you.