Is it possible to make two or more msgids matching one msgstr?
For example, both ('list.empty') and ('list.null') return "There is no any objects yet."
If I write this way in po file:
msgid "list.empty"
msgid "list.null"
msgstr "There is no any objects yet."
It just errors with "missing 'msgstr'":
However,
msgid "list.empty"
msgstr "There is no any objects yet."
msgid "list.null"
msgstr "There is no any objects yet."
Looks and works fine but stupid, because once I change one msgstr without another, they return different result.
Does anyone have any better hacks?
You are approaching gettext
in the wrong way, here is how it works:
msgid
is required for each entrymsgctxt
is optional and is used to differentiate between two msgid
records with same content that may have different translations.(msgid, msgctxt)
is the unique key for the dictionary, if msgctxt
is missing you can consider it null
.You should read the gettext documentation before implementing as it's not always straightforward.
In your case, this is how you are supposed to implement it:
msgctxt "list.empty"
msgid "There is no any objects yet."
msgctxt "list.null"
msgid "There is no any objects yet."