airbnb / polyglot.js

Give your JavaScript the ability to speak many languages.
http://airbnb.github.io/polyglot.js
BSD 2-Clause "Simplified" License
3.71k stars 208 forks source link

Chinese starts using plural at 2 #180

Closed SoSolife closed 4 months ago

SoSolife commented 1 year ago

Chinese has pluralization though the noun may not change to nouns like 1个人 and 2个人 that one person and two persons in English. I get the problem in this which uses smart_count to sum because the code return 0 in all values.

SoSolife commented 1 year ago

Thanks! Could you also provide test cases that would fail without this change, ideally in all of the affected languages?

Like Project navidrome, the Chinese translation file in Line 346 would judge the value that returns 0 or 1 to select which value to print.

Here is the test which selects two items but shows singular. 2023-03-17_164236 2023-03-17_164259

ljharb commented 4 months ago

I think the better way to handle this is something like count === 1 ? t('single') : t('multiple') in your site, as opposed to in this library, since the pluralization here is meant to only be in a grammatical sense.