lmasikl
lmasikl

Reputation: 193

gettext PO files syntax

Can I make different translation in different places?

For example:

#: orders/models.py:49 templates/products_list.html:54
msgid "Order"
msgstr "Заказать"

But I want anything like this (it's not working)

#: orders/models.py:49
msgid "Order"
msgstr "Заказ"
templates/products_list.html:54
msgid "Order"
msgstr "Заказать"

Upvotes: 0

Views: 144

Answers (1)

Jörn Horstmann
Jörn Horstmann

Reputation: 34024

You can use the context parameter of the pgettext function to select different translations. In the po file this would look as follows:

#: orders/models.py:49
msgctxt models
msgid "Order"
msgstr "Заказ"

templates/products_list.html:54
msgctxt products
msgid "Order"
msgstr "Заказать"

Upvotes: 1

Related Questions