About Context-Specific Translations

Some English terms have multiple meanings, or the translation might differ depending on where it is used. For example, "address" could be translated to German as "Adresse" in the context of a physical location, but as "Speicheradresse" in the context of computer science. Similarly, "default" could be translated as "Standard" in the context of settings, but as "Vorgabe" in the context of programming.

In Django, you can set a context for the translations using pgettext or pgettext_lazy:

address = models.CharField(
    pgettext_lazy("Physical", "Address"), max_length=200,

Analogously you can set that in the template:

{% translate "Address" context "Physical" %}

Tips and Tricks Programming Translations Django 4.2 Django 3.2 Django 2.2