Page MenuHomePhabricator

{{PLURAL}} behaves differently in PHP vs JS for decimal numbers
Open, Needs TriagePublic


The English version of the "nbytes" message is "$1 {{PLURAL:$1|byte|bytes}}". If I pass in a fractional number of bytes (not that that makes any sense for this particular example, but in general numerical parameters might take non-integers), and this number is between 1 and 2, PHP and JS behave differently:

PHP correctly chooses the plural form:

> echo wfMessage('nbytes')->numParams(1.2);
1.2 bytes

But JS incorrectly chooses the singular form:

> mw.msg('nbytes', 1.2)
"1.2 byte"

This only happens for numbers between 1 and 2 (maybe the number is being converted to an integer before it's tested against the plural rules?). I realize that in some languages this might be correct behavior. but in English it isn't.