smhg / gettext-parser

Parse and compile gettext po and mo files, nothing more, nothing less
MIT License
158 stars 43 forks source link

Support for 'empty' form of plurals #56

Closed mark-lester closed 3 years ago

mark-lester commented 3 years ago

I want to go

msgstr[0] "i dont have any things"
msgstr[1] "i have one thing "
msgstr[2] "i have {{thing_count}} things "

I will assume that if we only have the typical two msgstr, e.g.

msgstr[0] "i have one thing "
msgstr[1] "i have {{thing_count}} things "

that these are the singular and plural forms, and so to use the plural for the empty case (I call it rank) if I then compile that I will get

msgstr[0] "I have {{thing_count}} things"
msgstr[1] "i have one thing "
msgstr[2] "i have {{thing_count}} things "

This is going to potentially clash with existing translations, but using msgstr[2] for my 'empty' rank is so ugly, where as 0 == empty, 1 == singular 2 == plural is more natural and descriptive. In many, I suspect most languages, it's grammatically illegal to say "you have 0 of something". If we are going to bother factoring out the test for 1 or more than 1 and calling the relevant translation, imo we should be doing 0 also.

smhg commented 3 years ago

Correct me if I'm wrong, but it's up to you to interpret the meaning of the msgstr array (defined in the Plural-Forms header)? gettext-parser is indifferent about the order, no?

smhg commented 3 years ago

Closing as I interpret this as unrelated to gettext-parser. @mark-lester: feel free to discuss and I'll reopen.