praekeltfoundation / jspot

Extracts gettext strings from Javascript files into pot files
BSD 3-Clause "New" or "Revised" License
12 stars 2 forks source link

Conflict when same reference for a singular & a plural #40

Closed JSteunou closed 8 years ago

JSteunou commented 8 years ago

Hi, long time no see ;)

I found a nasty behaviour when using gettext for a single word, and then ngettext for the same word. Example:

gettext.ngettext('foo', 'foos', 1);
gettext('foo');

Only the singular form appear in the messages.pot

msgid "foo"
msgstr ""

Maybe it's "normal" because we cannot have twice the same msg_id, but if we have to choose one, would it be more correct to set the plural form in the messages.pot rather than the singular?

justinvdm commented 8 years ago

@JSteunou Thanks for catching this :) I think the correct behaviour is to prefer the plural form, xgettext does that:

#: foo.py:1 foo.py:2
msgid "foo"
msgid_plural "foos"
msgstr[0] ""
msgstr[1] ""

Would you mind reviewing and giving a +1 if you are happy?

JSteunou commented 8 years ago

Nicely done, seems good to me :+1:

justinvdm commented 8 years ago

Fix released as v0.3.11