Question

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 %}
Was it helpful?

Solution

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 %}

OTHER TIPS

{% blocktrans context "month name" %}May{% endblocktrans %}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top