Bug 1533435 - Create new plural for Slavic languages (bs, hr, sr) to account for different CLDR categories than Russian r=Pike
authorFrancesco Lodolo (:flod) <flod@lodolo.net>
Thu, 07 Mar 2019 18:56:20 +0000
changeset 520887 29867c8ea3ec95630a82a43e432969391f2decda
parent 520886 f49189976e12e2f01ff80a0f8fb2389a3136aecb
child 520888 c2331373e10707aa5259eb3d8436f65c8d59c684
push id10862
push userffxbld-merge
push dateMon, 11 Mar 2019 13:01:11 +0000
treeherdermozilla-beta@a2e7f5c935da [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersPike
bugs1533435
milestone67.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1533435 - Create new plural for Slavic languages (bs, hr, sr) to account for different CLDR categories than Russian r=Pike Differential Revision: https://phabricator.services.mozilla.com/D22535
intl/locale/PluralForm.jsm
intl/locale/tests/unit/test_pluralForm.js
--- a/intl/locale/PluralForm.jsm
+++ b/intl/locale/PluralForm.jsm
@@ -70,16 +70,18 @@ var gFunctions = [
   // 15: Icelandic, Macedonian
   [2, (n) => n%10==1&&n%100!=11?0:1],
   // 16: Breton
   [5, (n) => n%10==1&&n%100!=11&&n%100!=71&&n%100!=91?0:n%10==2&&n%100!=12&&n%100!=72&&n%100!=92?1:(n%10==3||n%10==4||n%10==9)&&n%100!=13&&n%100!=14&&n%100!=19&&n%100!=73&&n%100!=74&&n%100!=79&&n%100!=93&&n%100!=94&&n%100!=99?2:n%1000000==0&&n!=0?3:4],
   // 17: Shuar
   [2, (n) => n!=0?1:0],
   // 18: Welsh
   [6, (n) => n==0?0:n==1?1:n==2?2:n==3?3:n==6?4:5],
+  // 19: Slavic languages (bs, hr, sr). Same as rule 7, but resulting in different CLDR categories
+  [3, (n) => n%10==1&&n%100!=11?0:n%10>=2&&n%10<=4&&(n%100<10||n%100>=20)?1:2],
 ];
 
 var PluralForm = {
   /**
    * Get the correct plural form of a word based on the number
    *
    * @param aNum
    *        The number to decide which plural form to use
--- a/intl/locale/tests/unit/test_pluralForm.js
+++ b/intl/locale/tests/unit/test_pluralForm.js
@@ -652,16 +652,50 @@ function run_test()
     6,6,6,6,6,6,6,6,6,6,
     6,6,6,6,6,6,6,6,6,6,
     6,6,6,6,6,6,6,6,6,6,
     6,6,6,6,6,6,6,6,6,6,
     6,6,6,6,6,6,6,6,6,6,
     6,6,6,6,6,6,6,6,6,6,
     6,6,6,6,6,6,6,6,6,6,
     6,6,6,6,6,6,6,6,6,6,
+  ], [
+    // 19: Slavic languages (bs, hr, sr) 0-9, 10-19, ..., 90-99
+    3,1,2,2,2,3,3,3,3,3,
+    3,3,3,3,3,3,3,3,3,3,
+    3,1,2,2,2,3,3,3,3,3,
+    3,1,2,2,2,3,3,3,3,3,
+    3,1,2,2,2,3,3,3,3,3,
+    3,1,2,2,2,3,3,3,3,3,
+    3,1,2,2,2,3,3,3,3,3,
+    3,1,2,2,2,3,3,3,3,3,
+    3,1,2,2,2,3,3,3,3,3,
+    3,1,2,2,2,3,3,3,3,3,
+    // 100-109, 110-119, ..., 190-199
+    3,1,2,2,2,3,3,3,3,3,
+    3,3,3,3,3,3,3,3,3,3,
+    3,1,2,2,2,3,3,3,3,3,
+    3,1,2,2,2,3,3,3,3,3,
+    3,1,2,2,2,3,3,3,3,3,
+    3,1,2,2,2,3,3,3,3,3,
+    3,1,2,2,2,3,3,3,3,3,
+    3,1,2,2,2,3,3,3,3,3,
+    3,1,2,2,2,3,3,3,3,3,
+    3,1,2,2,2,3,3,3,3,3,
+    // 200-209, 210-219, ..., 290-299
+    3,1,2,2,2,3,3,3,3,3,
+    3,3,3,3,3,3,3,3,3,3,
+    3,1,2,2,2,3,3,3,3,3,
+    3,1,2,2,2,3,3,3,3,3,
+    3,1,2,2,2,3,3,3,3,3,
+    3,1,2,2,2,3,3,3,3,3,
+    3,1,2,2,2,3,3,3,3,3,
+    3,1,2,2,2,3,3,3,3,3,
+    3,1,2,2,2,3,3,3,3,3,
+    3,1,2,2,2,3,3,3,3,3,
   ]];
 
   for (let [rule, expect] of allExpect.entries()) {
     print("\nTesting rule #" + rule);
 
     let [get, numForms] = PluralForm.makeGetter(rule);
 
     // Make sure the largest value expected matches the number of plural forms