Вопрос

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