Closed saveman71 closed 11 months ago
We can't merge the translations yeah. I mean, the Elixir Gettext behavior seems fine to me because the singular and plural translations are treated completely differently, so they can coexist with the same msgid
.
Is msgfmt
the only thing that fails on this in the GNU Gettext toolset? Also, do you know what GNU Gettext does when extracting in situations when this would happen? For example, I don't know how PHP's ngettext or other implementations deal with this.
@whatyouhide PHP reads the msgid
of a plural translation as well:
var_dump(gettext('item'));
[...]
string(7) "Produkt"
msgid "item"
msgid_plural "items"
msgstr[0] "Produkt"
msgstr[1] "Produkte"
Judging by this paragraph, I think that is the expected way to do things:
https://www.gnu.org/software/gettext/manual/gettext.html#Invoking-the-msguniq-Program
The msguniq program unifies duplicate translations in a translation catalog. It finds duplicate translations of the same message ID. Such duplicates are invalid input for other programs like msgfmt, msgmerge or msgcat. By default, duplicates are merged together. [...]
So I guess we should merge singular and plural into one plural message and use the msgid
of plural messages for singular calls.
Yeah I think that's a good idea. I will be out all of next week so it will be a while before I'll be able to do anything about this 🙃
Sorry I was out of office and not great at using GitHub's notification center :sweat_smile: Thanks for looking into this!
Not sure if it's a bug / how other implementations tackle that, but
msgfmt
will fail for duplicatemsgid
s:Which is expected for cases like:
However, it also fails for cases like:
Generated by this code:
I believe things should work fine if the singular form was dropped from the
po
/pot
file.Here's the repro repo: https://github.com/saveman71/elixir-gettext-duplicate-keys
Is this a bug, or an accepted behaviour and
msgfmt
is just being too noisy/plain wrong here?The issue I can see is that usually both translations aren't always used in the same context, so "merging" them could be a breaking change.
msgfmt
allowed me to remove actual duplicates, but now its output is only this case, so I can't move forward adding it as a new CI step.