praekeltfoundation / jspot

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

When singular key === plural key #26

Closed JSteunou closed 10 years ago

JSteunou commented 10 years ago

I have a weird case with a ngettext call where singular key equals the plural key. Sounds bizarre, but I figured some other languages could handle it whereas it's writing the same in english.

But jspot write only singular key in the .pot. As if it handles this as simple call to gettext.

What do you think about that? Does my use case make sence? Is it a bug, or strict gettext appliance, or just no thoughs about it before?

justinvdm commented 10 years ago

Hmm, weird. If I'm understanding the issue, I can't seem to reproduce it. When I extract this:

gettext.ngettext('foo', 'foo', 2);

I get this in the .pot file:

msgid "foo"
msgid_plural "foo"
msgstr[0] ""
msgstr[1] ""

Could you show me the case you found where the plural wasn't put in the .pot file?

JSteunou commented 10 years ago

er, could be Handlebars related... will check on that tomorrow.

JSteunou commented 10 years ago

Ok find out. It's not Handlebars related.

It happens when you have a first call to gettext with a single singular sentence, then a ngettext call with a singular + plural key but the singular is the same than the singular in the previous call to gettext.

justinvdm commented 10 years ago

Ah right :) this is because each translation in .po files is indexed by the singular (I'm guessing that's the reason for the 'id' in msgid). For this reason, gettext-parser needs us to use the singulars as the property names in the data object we pass to it.

This is an issue in the way .po files expect translations to be specified, don't think there's much we can do about this :/

Closing the ticket for now.

JSteunou commented 10 years ago

That's what I though. No big deal, I spotted that with a wrong use of gettext.

I had a simple gettext instead of a gettext.ngettext, and another gettext.ngettext with the same sentence in another file. I did lose some hair before getting why my second use of gettext did not create singular + plural entry.

justinvdm commented 10 years ago

Ya, it does suck a bit :/ let me know if you find a way around this issue with .po files.