Documentation of Django says Contextual markers are also supported by the trans and blocktrans template tags. but it not explained how to do it?

Can you help marking translation context since I have some words with several meanings.

In Python I can do in such way:

pgettext("month name", "May")
pgettext("verb", "May")

How to specify translation context in Django template?

{% blocktrans %}May{% endblocktrans %}
有帮助吗?

解决方案

It is explained at the very end of their specific paragraphs:

https://docs.djangoproject.com/en/dev/topics/i18n/translation/#trans-template-tag

{% trans %} also supports contextual markers using the context keyword:

{% trans "May" context "month name" %}

https://docs.djangoproject.com/en/dev/topics/i18n/translation/#blocktrans-template-tag

{% blocktrans %} also supports contextual markers using the context keyword:

{% blocktrans with name=user.username context "greeting" %}Hi {{ name }}{% endblocktrans %}

其他提示

{% blocktrans context "month name" %}May{% endblocktrans %}
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top