Ramblin Wreck
Ramblin Wreck

Reputation: 67

Why is Japanese considered not to have plural?

Why is Japanese declared as having Plural-Forms: nplurals=1; plural=0; - i.e. there is no difference between singular and plural?

While it is true that the word for the singular and plural forms of a noun (let's say 'pencil') is the same (both are 'enpitsu'), aren't the phrases 'this pencil' and 'these pencils' different? The singular is 'Kono enpitsu', and the plural is 'Korera no enpitsu'. (Right?)

So why shouldn't I be able to do (in PHP):

ngettext('This pencil','These pencils', $n);

Even if I modify the .po file manually to the following:

msgid "This pencil"
msgid_plural "These pencils"
msgstr[0] "この鉛筆"
msgstr[1] "これらの鉛筆"

when I open the file with Poedit, it doesn't recognize the plural!

Thanks!

Upvotes: 0

Views: 194

Answers (2)

Guido Flohr
Guido Flohr

Reputation: 2340

Feel free to change the plural header in the Japanese PO file if you really run into that issue. But that will probably not happen.

Turkish and Hungarian seem to behave the same as Japanese in that respect and their respective language teams have decided to use nplurals = 2; plural=(n != 1) as the default Plural-Forms. But I cannot find any example where msgstr[0] and msgstr[1] really differ for these languages and that shows that the question you are asking is probably an academic one.

The gettext framework is not meant for translating literature. In German - and maybe more languages - for instance, it is recommended to write out small numbers (zero to twelve) and use digits only for larger numbers. But should German then be considered to have 14 plural forms for the purpose of ngettext()?

Keep in mind, too, that ngettext() can only translate simple expressions like "one file deleted"/"%d files deleted". You cannot use it for expressions like "%d files and %d directories deleted".

Also, this piece of code would be incorrect:

ngettext("One file deleted.  You can find it in the recycle bin.",
         "%d files deleted.  You can find them in the recycle bin.",
         number_of_files);

That would produce nonsense for number_of_files == 0, regardless of the language. You could fix that by changing the Plural-Forms of all of your PO files, including English, making sure that n == 0 always has a distinct plural form, and then put this into the PO file:

msgid "One file deleted.  You can find it in the recycle bin."
msgid_plural "%d files deleted.  You can find them in the recycle bin."
msgstr[0] "No file deleted."
msgstr[1] "One file deleted.  You can find it in the recycle bin."
msgstr[2] "%d files deleted.  You can find them in the recycle bin."

That would work. But should you do that? No. You should just work around the problem in the code, not in the PO file. And if your translator for Japanese complains that they have to distinguish between "この鉛筆" and "これらの鉛筆", it is probably easier to find a workaround in your code instead of changing the PO header.

And while you are implementing the workaround, it is quite likely that you see that you also have to handle the case n == 0 specially. That's why the decision of the Japanese language team about their default Plural-Forms expression is probably appropriate for the vast majority of cases.

Upvotes: 0

Václav Slavík
Václav Slavík

Reputation: 6650

So why shouldn't I be able to do (in PHP)

Because that's not what gettext plural forms are for. They are for strings that contain a number, e.g. ("%d pencil", "%d pencils"). That's why the ngettext function has an integer argument — the value to be inserted into the string.

Upvotes: 2

Related Questions