l10n: avoid using Android plurals for complex sentences
Description
The Android quantity strings doesn't work in the way many people expect it to be. It makes use of Unicode CLDR Language Plural Rules which focuses on the quantity text next to a number, rather than a whole sentence. Thus, Chinese doesn't have "plural forms" (i.e. 1 day, 2 day, 3 day)
We're used to the Gettext plurals where each language team can define their own plural rules. With customized rules we can use "this"/"these" in the Chinese translation, accurately expressing their original meaning in English.
However, Android didn't implement this with quantity strings and discourage its use on singular form.
Although historically called "quantity strings" (and still called that in API), quantity strings should only be used for plurals. It would be a mistake to use quantity strings to implement something like Gmail's "Inbox" versus "Inbox (12)" when there are unread messages, for example. It might seem convenient to use quantity strings instead of an
if
statement, but it's important to note that some languages (such as Chinese) don't make these grammatical distinctions at all, so you'll always get theother
string.The selection of which string to use is made solely based on grammatical necessity. In English, a string for
zero
is ignored even if the quantity is 0, because 0 isn't grammatically different from 2, or any other number except 1 ("zero books", "one book", "two books", and so on). Conversely, in Korean only theother
string is ever used.
Currently, all plurals
in the XML are in the [number] [quantity text] format, except duplication_two_options_secondary
:
<plurals name="duplication_two_options_secondary">
<item quantity="one">This item is already in this playlist.</item>
<item quantity="other">These items are already in this playlist.</item>
</plurals>
getQuantityString()
doesn't allow <item quantity="one">
for Chinese, per CLDR. The CLDR maintainers insist that "The Chinese languages do not have the notion of plural."
So, we can't distinguish "this"/"these" in our translation. Although we managed to finish this entry by just saying "item", we can't guarantee other English expressions to come and be translated as expected/designed.
According to CLDR, languages affected are:
bm bo dz hnj id ig ii in ja jbo jv jw kde kea km ko lkt lo ms my nqo osa root sah ses sg su th to tpi vi wo yo yue zh
Expected behavior
Sentences with "this"/"these" singular/plural forms be written with if code.
Other existing entries like "%d results found
" are okay, at least for Chinese.
See also:
- Stack Overflow: Plural definition is ignored for zero quantity
- android.icu.text.PluralRules (Android 7.0+, not suitable for VLC)
- Plural Forms (Gettext-style)