Skip to content

Inconsistent plural form for Arabic #816

Description

@felipeochoa

Overview Description

The two plural catalogs babel.messages.plurals (manually maintained) and the one derived from the CLDR disagree on the formula for Arabic. Specifically, the 5th and 6th form ("many" and "other") are flipped.

Steps to Reproduce

>>> import babel, babel.messages.plurals, babel.plural
>>> print(babel.messages.plurals.get_plural('ar'))
nplurals=6; plural=(n==0 ? 0 : n==1 ? 1 : n==2 ? 2 : n%100>=3 && n%100<=10 ? 3 : n%100>=0 && n%100<=2 ? 4 : 5);
>>> print(babel.plural.to_gettext(babel.Locale('ar').plural_form))
nplurals=6; plural=((((n % 100) >= 3 && (n % 100) <= 10)) ? 3 : (((n % 100) >= 11 && (n % 100) <= 99)) ? 4 : ((n == 1)) ? 1 : ((n == 2)) ? 2 : ((n == 0)) ? 0 : 5)

Switching over to NodeJS to evaluate:

> var manual = n => n==0 ? 0 : n==1 ? 1 : n==2 ? 2 : n%100>=3 && n%100<=10 ? 3 : n%100>=0 && n%100<=2 ? 4 : 5;
> var cldr = n => ((((n % 100) >= 3 && (n % 100) <= 10)) ? 3 : (((n % 100) >= 11 && (n % 100) <= 99)) ? 4 : ((n == 1)) ? 1 : ((n == 2)) ? 2 : ((n == 0)) ? 0 : 5)
> [0, 1, 2, 3, 11, 101].map(manual)
[ 0, 1, 2, 3, 5, 4 ]
> [0, 1, 2, 3, 11, 101].map(cldr)
[ 0, 1, 2, 3, 4, 5 ]

Actual Results

The formulas are formatted differently, but they agree in the n == 0, n == 1, n == 2, and (n % 100) >= 3 && (n % 100) <= 10 cases. The two remaining cases ((n % 100) >= 11 and n%100<=2) however are flipped.

The manual form has the 101 case as index 4 (many) and the 11 case as index 5 (other). The CLDR form has them the opposite way.

Expected Results

The two formulas should match.

Additional Information

I was able to verify that the manual formula was copied from Mozilla in #431, even though it did not match the CLDR data at the time (v29 unchanged in latest). The Mozilla formula was specified in a bit of an ad-hoc way years before.

Metadata

Metadata

Assignees

No one assigned

    Type

    Fields

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions