Merge "Remove reference to deleted file"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Fri, 3 Jan 2014 12:08:15 +0000 (12:08 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Fri, 3 Jan 2014 12:08:15 +0000 (12:08 +0000)
29 files changed:
RELEASE-NOTES-1.23
includes/AutoLoader.php
includes/libs/MWMessagePack.php
includes/libs/RunningStat.php [new file with mode: 0644]
includes/profiler/RunningStat.php [deleted file]
languages/classes/LanguageBe_tarask.php
languages/classes/LanguageHr.php [deleted file]
languages/classes/LanguageRu.php
languages/classes/LanguageSr.php
languages/classes/LanguageSr_ec.php [deleted file]
languages/classes/LanguageSr_el.php [deleted file]
languages/classes/LanguageUk.php
languages/data/plurals-mediawiki.xml
languages/data/plurals.xml [changed mode: 0644->0755]
resources/mediawiki.libs/CLDRPluralRuleParser.js
tests/phpunit/includes/RunningStatTest.php [deleted file]
tests/phpunit/includes/libs/MWMessagePackTest.php
tests/phpunit/includes/libs/RunningStatTest.php [new file with mode: 0644]
tests/phpunit/languages/LanguageBe_taraskTest.php
tests/phpunit/languages/LanguageBsTest.php
tests/phpunit/languages/LanguageHrTest.php
tests/phpunit/languages/LanguageHyTest.php
tests/phpunit/languages/LanguageLvTest.php
tests/phpunit/languages/LanguageMkTest.php
tests/phpunit/languages/LanguageRuTest.php
tests/phpunit/languages/LanguageSgsTest.php
tests/phpunit/languages/LanguageShTest.php
tests/phpunit/languages/LanguageSrTest.php
tests/phpunit/languages/LanguageUkTest.php

index d6263a7..d682206 100644 (file)
@@ -84,6 +84,11 @@ production.
 * (bug 57201) SpecialRecentChangesFilters hook is now executed for feeds.
 * (bug 58640) Fixed a compatibility issue with PCRE 8.34 that caused pages
   to appear blank or with missing text.
+* (bug 56931) Updated the plural rules to CLDR 24. They are in new format
+  which is detailed in UTS 35 Rev 33. The PHP parser and evaluator as well as
+  the JavaScript evaluator were updated to support the new format. Plural rules
+  for some languages have changed, most notably Russian. Affected software
+  messages have been updated and marked for review at translatewiki.net.
 
 === Web API changes in 1.23 ===
 * (bug 54884) action=parse&prop=categories now indicates hidden and missing
index 5b99c8d..a9b0376 100644 (file)
@@ -688,6 +688,7 @@ $wgAutoloadLocalClasses = array(
        'JSToken' => 'includes/libs/jsminplus.php',
        'JSTokenizer' => 'includes/libs/jsminplus.php',
        'MWMessagePack' => 'includes/libs/MWMessagePack.php',
+       'RunningStat' => 'includes/libs/RunningStat.php',
        'ScopedCallback' => 'includes/libs/ScopedCallback.php',
        'ScopedPHPTimeout' => 'includes/libs/ScopedPHPTimeout.php',
        'XmlTypeCheck' => 'includes/libs/XmlTypeCheck.php',
@@ -831,7 +832,6 @@ $wgAutoloadLocalClasses = array(
        'ProfilerSimpleUDP' => 'includes/profiler/ProfilerSimpleUDP.php',
        'ProfilerStub' => 'includes/profiler/ProfilerStub.php',
        'ProfileSection' => 'includes/profiler/Profiler.php',
-       'RunningStat' => 'includes/profiler/RunningStat.php',
 
        # includes/rcfeed
        'RCFeedEngine' => 'includes/rcfeed/RCFeedEngine.php',
index b44635d..c61e8f8 100644 (file)
@@ -35,7 +35,7 @@
 class MWMessagePack {
 
        /** @var boolean|null Whether current system is bigendian. **/
-       public static $bigendian;
+       public static $bigendian = null;
 
        /**
         * Encode a value using MessagePack
@@ -46,6 +46,7 @@ class MWMessagePack {
         *
         * @param mixed $value
         * @return string
+        * @throws InvalidArgumentException if $value is an unsupported type or too long a string
         */
        public static function pack( $value ) {
                if ( self::$bigendian === null ) {
@@ -74,7 +75,7 @@ class MWMessagePack {
                        } elseif ( $length <= 0xFFFFFFFF ) {
                                return pack( 'CNa*', 0xDB, $length, $value );
                        }
-                       throw new LengthException( "String too long: $length (max: 4294967295)." );
+                       throw new InvalidArgumentException( __METHOD__ . ": string too long (length: $length; max: 4294967295)" );
 
                case 'integer':
                        if ( $value >= 0 ) {
@@ -113,7 +114,7 @@ class MWMessagePack {
                                }
                                if ( $value >= -0x8000 ) {
                                        // int16
-                                       $p = pack('s',$value);
+                                       $p = pack( 's', $value );
                                        return self::$bigendian
                                                ? pack( 'Ca2', 0xD1, $p )
                                                : pack( 'Ca2', 0xD1, strrev( $p ) );
@@ -135,16 +136,24 @@ class MWMessagePack {
                                                : pack( 'Ca4a4', 0xD3, strrev( $p2 ), strrev( $p1 ) );
                                }
                        }
-                       throw new LengthException( 'Invalid integer: ' . $value );
+                       throw new InvalidArgumentException( __METHOD__ . ": invalid integer '$value'" );
 
                case 'array':
-                       $associative = array_values( $value ) !== $value;
-                       $length = count( $value );
                        $buffer = '';
-
+                       $length = count( $value );
                        if ( $length > 0xFFFFFFFF ) {
-                               throw new LengthException( "Array too long: $length (max: 4294967295)." );
+                               throw new InvalidArgumentException( __METHOD__ . ": array too long (length: $length, max: 4294967295)" );
+                       }
+
+                       $index = 0;
+                       foreach ( $value as $k => $v ) {
+                               if ( $index !== $k || $index === $length ) {
+                                       break;
+                               } else {
+                                       $index++;
+                               }
                        }
+                       $associative = $index !== $length;
 
                        if ( $associative ) {
                                if ( $length < 16 ) {
@@ -173,7 +182,7 @@ class MWMessagePack {
                        return $buffer;
 
                default:
-                       throw new LengthException( 'Unsupported type: ' . gettype( $value ) );
+                       throw new InvalidArgumentException( __METHOD__ . ': unsupported type ' . gettype( $value ) );
                }
        }
 }
diff --git a/includes/libs/RunningStat.php b/includes/libs/RunningStat.php
new file mode 100644 (file)
index 0000000..dda5254
--- /dev/null
@@ -0,0 +1,176 @@
+<?php
+/**
+ * Compute running mean, variance, and extrema of a stream of numbers.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ * @file
+ * @ingroup Profiler
+ */
+
+// Needed due to PHP non-bug <https://bugs.php.net/bug.php?id=49828>.
+define( 'NEGATIVE_INF', -INF );
+
+/**
+ * Represents a running summary of a stream of numbers.
+ *
+ * RunningStat instances are accumulator-like objects that provide a set of
+ * continuously-updated summary statistics for a stream of numbers, without
+ * requiring that each value be stored. The measures it provides are the
+ * arithmetic mean, variance, standard deviation, and extrema (min and max);
+ * together they describe the central tendency and statistical dispersion of a
+ * set of values.
+ *
+ * One RunningStat instance can be merged into another; the resultant
+ * RunningStat has the state it would have had if it had accumulated each
+ * individual point. This allows data to be summarized in parallel and in
+ * stages without loss of fidelity.
+ *
+ * Based on a C++ implementation by John D. Cook:
+ *  <http://www.johndcook.com/standard_deviation.html>
+ *  <http://www.johndcook.com/skewness_kurtosis.html>
+ *
+ * The in-line documentation for this class incorporates content from the
+ * English Wikipedia articles "Variance", "Algorithms for calculating
+ * variance", and "Standard deviation".
+ *
+ * @since 1.23
+ */
+class RunningStat implements Countable {
+
+       /** @var int Number of samples. **/
+       public $n = 0;
+
+       /** @var float The first moment (or mean, or expected value). **/
+       public $m1 = 0.0;
+
+       /** @var float The second central moment (or variance). **/
+       public $m2 = 0.0;
+
+       /** @var float The least value in the the set. **/
+       public $min = INF;
+
+       /** @var float The most value in the set. **/
+       public $max = NEGATIVE_INF;
+
+       /**
+        * Count the number of accumulated values.
+        * @return int Number of values
+        */
+       public function count() {
+               return $this->n;
+       }
+
+       /**
+        * Add a number to the data set.
+        * @param int|float $x Value to add
+        */
+       public function push( $x ) {
+               $x = (float) $x;
+
+               $this->min = min( $this->min, $x );
+               $this->max = max( $this->max, $x );
+
+               $n1 = $this->n;
+               $this->n += 1;
+               $delta = $x - $this->m1;
+               $delta_n = $delta / $this->n;
+               $this->m1 += $delta_n;
+               $this->m2 += $delta * $delta_n * $n1;
+       }
+
+       /**
+        * Get the mean, or expected value.
+        *
+        * The arithmetic mean is the sum of all measurements divided by the number
+        * of observations in the data set.
+        *
+        * @return float Mean
+        */
+       public function getMean() {
+               return $this->m1;
+       }
+
+       /**
+        * Get the estimated variance.
+        *
+        * Variance measures how far a set of numbers is spread out. A small
+        * variance indicates that the data points tend to be very close to the
+        * mean (and hence to each other), while a high variance indicates that the
+        * data points are very spread out from the mean and from each other.
+        *
+        * @return float Estimated variance
+        */
+       public function getVariance() {
+               if ( $this->n === 0 ) {
+                       // The variance of the empty set is undefined.
+                       return NAN;
+               } elseif ( $this->n === 1 ) {
+                       return 0.0;
+               } else {
+                       return $this->m2 / ( $this->n - 1.0 );
+               }
+       }
+
+       /**
+        * Get the estimated stanard deviation.
+        *
+        * The standard deviation of a statistical population is the square root of
+        * its variance. It shows shows how much variation from the mean exists. In
+        * addition to expressing the variability of a population, the standard
+        * deviation is commonly used to measure confidence in statistical conclusions.
+        *
+        * @return float Estimated standard deviation
+        */
+       public function getStdDev() {
+               return sqrt( $this->getVariance() );
+       }
+
+       /**
+        * Merge another RunningStat instance into this instance.
+        *
+        * This instance then has the state it would have had if all the data had
+        * been accumulated by it alone.
+        *
+        * @param RunningStat RunningStat instance to merge into this one
+        */
+       public function merge( RunningStat $other ) {
+               // If the other RunningStat is empty, there's nothing to do.
+               if ( $other->n === 0 ) {
+                       return;
+               }
+
+               // If this RunningStat is empty, copy values from other RunningStat.
+               if ( $this->n === 0 ) {
+                       $this->n = $other->n;
+                       $this->m1 = $other->m1;
+                       $this->m2 = $other->m2;
+                       $this->min = $other->min;
+                       $this->max = $other->max;
+                       return;
+               }
+
+               $n = $this->n + $other->n;
+               $delta = $other->m1 - $this->m1;
+               $delta2 = $delta * $delta;
+
+               $this->m1 = ( ( $this->n * $this->m1 ) + ( $other->n * $other->m1 ) ) / $n;
+               $this->m2 = $this->m2 + $other->m2 + ( $delta2 * $this->n * $other->n / $n );
+               $this->min = min( $this->min, $other->min );
+               $this->max = max( $this->max, $other->max );
+               $this->n = $n;
+       }
+}
diff --git a/includes/profiler/RunningStat.php b/includes/profiler/RunningStat.php
deleted file mode 100644 (file)
index dda5254..0000000
+++ /dev/null
@@ -1,176 +0,0 @@
-<?php
-/**
- * Compute running mean, variance, and extrema of a stream of numbers.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- * @file
- * @ingroup Profiler
- */
-
-// Needed due to PHP non-bug <https://bugs.php.net/bug.php?id=49828>.
-define( 'NEGATIVE_INF', -INF );
-
-/**
- * Represents a running summary of a stream of numbers.
- *
- * RunningStat instances are accumulator-like objects that provide a set of
- * continuously-updated summary statistics for a stream of numbers, without
- * requiring that each value be stored. The measures it provides are the
- * arithmetic mean, variance, standard deviation, and extrema (min and max);
- * together they describe the central tendency and statistical dispersion of a
- * set of values.
- *
- * One RunningStat instance can be merged into another; the resultant
- * RunningStat has the state it would have had if it had accumulated each
- * individual point. This allows data to be summarized in parallel and in
- * stages without loss of fidelity.
- *
- * Based on a C++ implementation by John D. Cook:
- *  <http://www.johndcook.com/standard_deviation.html>
- *  <http://www.johndcook.com/skewness_kurtosis.html>
- *
- * The in-line documentation for this class incorporates content from the
- * English Wikipedia articles "Variance", "Algorithms for calculating
- * variance", and "Standard deviation".
- *
- * @since 1.23
- */
-class RunningStat implements Countable {
-
-       /** @var int Number of samples. **/
-       public $n = 0;
-
-       /** @var float The first moment (or mean, or expected value). **/
-       public $m1 = 0.0;
-
-       /** @var float The second central moment (or variance). **/
-       public $m2 = 0.0;
-
-       /** @var float The least value in the the set. **/
-       public $min = INF;
-
-       /** @var float The most value in the set. **/
-       public $max = NEGATIVE_INF;
-
-       /**
-        * Count the number of accumulated values.
-        * @return int Number of values
-        */
-       public function count() {
-               return $this->n;
-       }
-
-       /**
-        * Add a number to the data set.
-        * @param int|float $x Value to add
-        */
-       public function push( $x ) {
-               $x = (float) $x;
-
-               $this->min = min( $this->min, $x );
-               $this->max = max( $this->max, $x );
-
-               $n1 = $this->n;
-               $this->n += 1;
-               $delta = $x - $this->m1;
-               $delta_n = $delta / $this->n;
-               $this->m1 += $delta_n;
-               $this->m2 += $delta * $delta_n * $n1;
-       }
-
-       /**
-        * Get the mean, or expected value.
-        *
-        * The arithmetic mean is the sum of all measurements divided by the number
-        * of observations in the data set.
-        *
-        * @return float Mean
-        */
-       public function getMean() {
-               return $this->m1;
-       }
-
-       /**
-        * Get the estimated variance.
-        *
-        * Variance measures how far a set of numbers is spread out. A small
-        * variance indicates that the data points tend to be very close to the
-        * mean (and hence to each other), while a high variance indicates that the
-        * data points are very spread out from the mean and from each other.
-        *
-        * @return float Estimated variance
-        */
-       public function getVariance() {
-               if ( $this->n === 0 ) {
-                       // The variance of the empty set is undefined.
-                       return NAN;
-               } elseif ( $this->n === 1 ) {
-                       return 0.0;
-               } else {
-                       return $this->m2 / ( $this->n - 1.0 );
-               }
-       }
-
-       /**
-        * Get the estimated stanard deviation.
-        *
-        * The standard deviation of a statistical population is the square root of
-        * its variance. It shows shows how much variation from the mean exists. In
-        * addition to expressing the variability of a population, the standard
-        * deviation is commonly used to measure confidence in statistical conclusions.
-        *
-        * @return float Estimated standard deviation
-        */
-       public function getStdDev() {
-               return sqrt( $this->getVariance() );
-       }
-
-       /**
-        * Merge another RunningStat instance into this instance.
-        *
-        * This instance then has the state it would have had if all the data had
-        * been accumulated by it alone.
-        *
-        * @param RunningStat RunningStat instance to merge into this one
-        */
-       public function merge( RunningStat $other ) {
-               // If the other RunningStat is empty, there's nothing to do.
-               if ( $other->n === 0 ) {
-                       return;
-               }
-
-               // If this RunningStat is empty, copy values from other RunningStat.
-               if ( $this->n === 0 ) {
-                       $this->n = $other->n;
-                       $this->m1 = $other->m1;
-                       $this->m2 = $other->m2;
-                       $this->min = $other->min;
-                       $this->max = $other->max;
-                       return;
-               }
-
-               $n = $this->n + $other->n;
-               $delta = $other->m1 - $this->m1;
-               $delta2 = $delta * $delta;
-
-               $this->m1 = ( ( $this->n * $this->m1 ) + ( $other->n * $other->m1 ) ) / $n;
-               $this->m2 = $this->m2 + $other->m2 + ( $delta2 * $this->n * $other->n / $n );
-               $this->min = min( $this->min, $other->min );
-               $this->max = max( $this->max, $other->max );
-               $this->n = $n;
-       }
-}
index d3e78fe..05b9550 100644 (file)
  * @see http://be-x-old.wikipedia.org/wiki/Project_talk:LanguageBe_tarask.php
  */
 class LanguageBe_tarask extends Language {
-       /**
-        * Plural form transformations
-        *
-        * $wordform1 - singular form (for 1, 21, 31, 41...)
-        * $wordform2 - plural form (for 2, 3, 4, 22, 23, 24, 32, 33, 34...)
-        * $wordform3 - plural form (for 0, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 25, 26...)
-        */
-
-       /**
-        * @param $count int
-        * @param $forms array
-        *
-        * @return string
-        */
-       function convertPlural( $count, $forms ) {
-               $forms = $this->handleExplicitPluralForms( $count, $forms );
-               if ( is_string( $forms ) ) {
-                       return $forms;
-               }
-               if ( !count( $forms ) ) {
-                       return '';
-               }
-
-               // If the actual number is not mentioned in the expression, then just two forms are enough:
-               // singular for $count == 1
-               // plural   for $count != 1
-               // For example, "This user belongs to {{PLURAL:$1|one group|several groups}}."
-               if ( count( $forms ) === 2 ) {
-                       return $count == 1 ? $forms[0] : $forms[1];
-               }
-
-               // @todo FIXME: CLDR defines 4 plural forms instead of 3
-               //        http://unicode.org/repos/cldr-tmp/trunk/diff/supplemental/language_plural_rules.html
-               $forms = $this->preConvertPlural( $forms, 3 );
-
-               if ( $count > 10 && floor( ( $count % 100 ) / 10 ) == 1 ) {
-                       return $forms[2];
-               } else {
-                       switch ( $count % 10 ) {
-                               case 1: return $forms[0];
-                               case 2:
-                               case 3:
-                               case 4: return $forms[1];
-                               default: return $forms[2];
-                       }
-               }
-       }
-
        /**
         * The Belarusian language uses apostrophe sign,
         * but the characters used for this could be both U+0027 and U+2019.
diff --git a/languages/classes/LanguageHr.php b/languages/classes/LanguageHr.php
deleted file mode 100644 (file)
index 0c65ec7..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
-<?php
-/**
- * Croatian (hrvatski) specific code.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- * @file
- * @ingroup Language
- */
-
-/**
- * Croatian (hrvatski)
- *
- * @ingroup Language
- */
-class LanguageHr extends Language {
-
-       /**
-        * @param $count int
-        * @param $forms array
-        * @return string
-        */
-       function convertPlural( $count, $forms ) {
-               $forms = $this->handleExplicitPluralForms( $count, $forms );
-               if ( is_string( $forms ) ) {
-                       return $forms;
-               }
-               if ( !count( $forms ) ) {
-                       return '';
-               }
-               // @todo FIXME: CLDR defines 4 plural forms instead of 3. Plural for for decimals is missing.
-               //        http://unicode.org/repos/cldr-tmp/trunk/diff/supplemental/language_plural_rules.html
-               $forms = $this->preConvertPlural( $forms, 3 );
-
-               if ( $count > 10 && floor( ( $count % 100 ) / 10 ) == 1 ) {
-                       return $forms[2];
-               } else {
-                       switch ( $count % 10 ) {
-                               case 1: return $forms[0];
-                               case 2:
-                               case 3:
-                               case 4: return $forms[1];
-                               default: return $forms[2];
-                       }
-               }
-       }
-}
index 243a876..d3ac1d2 100644 (file)
@@ -44,8 +44,9 @@ class LanguageRu extends Language {
                        return $wgGrammarForms['ru'][$case][$word];
                }
 
-               # These rules are not perfect, but they are currently only used for Wikimedia site names so it doesn't
-               # matter if they are wrong sometimes. Just add a special case for your site name if necessary.
+               # These rules are not perfect, but they are currently only used for Wikimedia
+               # site names so it doesn't matter if they are wrong sometimes.
+               # Just add a special case for your site name if necessary.
 
                # substr doesn't support Unicode and mb_substr has issues,
                # so break it to characters using preg_match_all and then use array_slice and join
@@ -102,62 +103,6 @@ class LanguageRu extends Language {
                return $word;
        }
 
-       /**
-        * Plural form transformations
-        *
-        * $forms[0] - singular form (for 1, 21, 31, 41...)
-        * $forms[1] - paucal form (for 2, 3, 4, 22, 23, 24, 32, 33, 34...)
-        * $forms[2] - plural form (for 0, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 25, 26...)
-        *
-        * Examples:
-        *   message with number
-        *     "Сделано $1 {{PLURAL:$1|изменение|изменения|изменений}}"
-        *     ("$1 change[s] were made)
-        *   message without number
-        *     "Действие не может быть выполнено по {{PLURAL:$1|следующей причине|следующим причинам}}:"
-        *     ("The action cannot be performed for the following reason[s]")
-        * @param $count int
-        * @param $forms array
-        *
-        * @return string
-        */
-       function convertPlural( $count, $forms ) {
-               $forms = $this->handleExplicitPluralForms( $count, $forms );
-               if ( is_string( $forms ) ) {
-                       return $forms;
-               }
-               if ( !count( $forms ) ) {
-                       return '';
-               }
-
-               // If the actual number is not mentioned in the expression, then just two forms are enough:
-               // singular for $count === 1
-               // plural   for $count !== 1
-               // For example, "This user belongs to {{PLURAL:$1|one group|several groups}}."
-               if ( count( $forms ) === 2 ) {
-                       return $count === 1 ? $forms[0] : $forms[1];
-               }
-
-               // @todo FIXME: CLDR defines 4 plural forms. Form with decimals missing.
-               // See http://unicode.org/repos/cldr-tmp/trunk/diff/supplemental/language_plural_rules.html#ru
-               $forms = $this->preConvertPlural( $forms, 3 );
-
-               if ( $count > 10 && (int)floor( ( $count % 100 ) / 10 ) === 1 ) {
-                       return $forms[2];
-               }
-
-               switch ( $count % 10 ) {
-                       case 1:
-                               return $forms[0];
-                       case 2:
-                       case 3:
-                       case 4:
-                               return $forms[1];
-                       default:
-                               return $forms[2];
-               }
-       }
-
        /**
         * Four-digit number should be without group commas (spaces)
         * See manual of style at http://ru.wikipedia.org/wiki/Википедия:Оформление_статей
index 283ef22..a728c9d 100644 (file)
@@ -22,8 +22,6 @@
  */
 
 require_once __DIR__ . '/../LanguageConverter.php';
-require_once __DIR__ . '/LanguageSr_ec.php';
-require_once __DIR__ . '/LanguageSr_el.php';
 
 /**
  * There are two levels of conversion for Serbian: the script level
@@ -166,14 +164,16 @@ class SrConverter extends LanguageConverter {
                // regexp for roman numbers
                $roman = 'M{0,4}(CM|CD|D?C{0,3})(XC|XL|L?X{0,3})(IX|IV|V?I{0,3})';
 
-               $reg = '/^' . $roman . '$|^' . $roman . $breaks . '|' . $breaks . $roman . '$|' . $breaks . $roman . $breaks . '/';
+               $reg = '/^' . $roman . '$|^' . $roman . $breaks . '|' . $breaks
+                       . $roman . '$|' . $breaks . $roman . $breaks . '/';
 
                $matches = preg_split( $reg, $text, -1, PREG_SPLIT_OFFSET_CAPTURE );
 
                $m = array_shift( $matches );
                $this->loadTables();
                if ( !isset( $this->mTables[$toVariant] ) ) {
-                       throw new MWException( "Broken variant table: " . implode( ',', array_keys( $this->mTables ) ) );
+                       throw new MWException( "Broken variant table: "
+                               . implode( ',', array_keys( $this->mTables ) ) );
                }
                $ret = $this->mTables[$toVariant]->replace( $m[0] );
                $mstart = $m[1] + strlen( $m[0] );
@@ -218,7 +218,7 @@ class SrConverter extends LanguageConverter {
  *
  * @ingroup Language
  */
-class LanguageSr extends LanguageSr_ec {
+class LanguageSr extends Language {
        function __construct() {
                global $wgHooks;
 
@@ -238,44 +238,4 @@ class LanguageSr extends LanguageSr_ec {
                $this->mConverter = new SrConverter( $this, 'sr', $variants, $variantfallbacks, $flags );
                $wgHooks['PageContentSaveComplete'][] = $this->mConverter;
        }
-
-       /**
-        * @param $count int
-        * @param $forms array
-        *
-        * @return string
-        */
-       function convertPlural( $count, $forms ) {
-               $forms = $this->handleExplicitPluralForms( $count, $forms );
-               if ( is_string( $forms ) ) {
-                       return $forms;
-               }
-               if ( !count( $forms ) ) {
-                       return '';
-               }
-
-               // If the actual number is not mentioned in the expression, then just two forms are enough:
-               // singular for $count == 1
-               // plural   for $count != 1
-               // For example, "This user belongs to {{PLURAL:$1|one group|several groups}}."
-               if ( count( $forms ) === 2 ) {
-                       return $count == 1 ? $forms[0] : $forms[1];
-               }
-
-               // @todo FIXME: CLDR defines 4 plural forms. Form with decimals missing.
-               // See http://unicode.org/repos/cldr-tmp/trunk/diff/supplemental/language_plural_rules.html#ru
-               $forms = $this->preConvertPlural( $forms, 3 );
-
-               if ( $count > 10 && floor( ( $count % 100 ) / 10 ) == 1 ) {
-                       return $forms[2];
-               } else {
-                       switch ( $count % 10 ) {
-                               case 1: return $forms[0];
-                               case 2:
-                               case 3:
-                               case 4: return $forms[1];
-                               default: return $forms[2];
-                       }
-               }
-       }
 }
diff --git a/languages/classes/LanguageSr_ec.php b/languages/classes/LanguageSr_ec.php
deleted file mode 100644 (file)
index 4787856..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-<?php
-/**
- * Serbian (cyrillic script) specific code.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- * @file
- * @ingroup Language
- */
-
-/**
- * Serbian (cyrillic script)
- *
- * @ingroup Language
- */
-class LanguageSr_ec extends Language {
-
-       /**
-        * @param $count int
-        * @param $forms array
-        * @return string
-        */
-       function convertPlural( $count, $forms ) {
-               $forms = $this->handleExplicitPluralForms( $count, $forms );
-               if ( is_string( $forms ) ) {
-                       return $forms;
-               }
-               if ( !count( $forms ) ) {
-                       return '';
-               }
-               $forms = $this->preConvertPlural( $forms, 3 );
-
-               if ( $count > 10 && floor( ( $count % 100 ) / 10 ) == 1 ) {
-                       return $forms[2];
-               } else {
-                       switch ( $count % 10 ) {
-                               case 1: return $forms[0];
-                               case 2:
-                               case 3:
-                               case 4: return $forms[1];
-                               default: return $forms[2];
-                       }
-               }
-       }
-}
diff --git a/languages/classes/LanguageSr_el.php b/languages/classes/LanguageSr_el.php
deleted file mode 100644 (file)
index 3f086df..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-<?php
-/**
- * Serbian (latin script) specific code.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- * @file
- * @ingroup Language
- */
-
-/**
- * Serbian (latin script)
- *
- * @ingroup Language
- */
-class LanguageSr_el extends Language {
-
-       /**
-        * @param $count int
-        * @param $forms array
-        * @return string
-        */
-       function convertPlural( $count, $forms ) {
-               $forms = $this->handleExplicitPluralForms( $count, $forms );
-               if ( is_string( $forms ) ) {
-                       return $forms;
-               }
-               if ( !count( $forms ) ) {
-                       return '';
-               }
-               $forms = $this->preConvertPlural( $forms, 3 );
-
-               if ( $count > 10 && floor( ( $count % 100 ) / 10 ) == 1 ) {
-                       return $forms[2];
-               } else {
-                       switch ( $count % 10 ) {
-                               case 1: return $forms[0];
-                               case 2:
-                               case 3:
-                               case 4: return $forms[1];
-                               default: return $forms[2];
-                       }
-               }
-       }
-}
index aabe390..08041a9 100644 (file)
@@ -86,45 +86,6 @@ class LanguageUk extends Language {
                return $word;
        }
 
-       /**
-        * @param $count int
-        * @param $forms array
-        * @return string
-        */
-       function convertPlural( $count, $forms ) {
-               $forms = $this->handleExplicitPluralForms( $count, $forms );
-               if ( is_string( $forms ) ) {
-                       return $forms;
-               }
-               if ( !count( $forms ) ) {
-                       return '';
-               }
-
-               // If the actual number is not mentioned in the expression, then just two forms are enough:
-               // singular for $count == 1
-               // plural   for $count != 1
-               // For example, "This user belongs to {{PLURAL:$1|one group|several groups}}."
-               if ( count( $forms ) === 2 ) {
-                       return $count == 1 ? $forms[0] : $forms[1];
-               }
-
-               // @todo FIXME: CLDR defines 4 plural forms. Form for decimals is missing/
-               // See http://unicode.org/repos/cldr-tmp/trunk/diff/supplemental/language_plural_rules.html#uk
-               $forms = $this->preConvertPlural( $forms, 3 );
-
-               if ( $count > 10 && floor( ( $count % 100 ) / 10 ) == 1 ) {
-                       return $forms[2];
-               } else {
-                       switch ( $count % 10 ) {
-                               case 1: return $forms[0];
-                               case 2:
-                               case 3:
-                               case 4: return $forms[1];
-                               default: return $forms[2];
-                       }
-               }
-       }
-
        /**
         * Ukrainian numeric format is "12 345,67" but "1234,56"
         *
index 3314793..aafc393 100644 (file)
@@ -2,48 +2,44 @@
 <!DOCTYPE supplementalData SYSTEM "../../common/dtd/ldmlSupplemental.dtd">
 <supplementalData>
        <plurals>
-               <!--
-               The "one" and "two" rules are copied directly from CLDR.
-               The "many" rule overrides CLDR, because CLDR seems to have a mistake:
-               it's sometimes needed for multiples of 10, but not for 10 itself.
-               When the CLDR is fixed, this should be removed.
-               -->
-               <pluralRules locales="he">
-                       <pluralRule count="one">n is 1</pluralRule>
-                       <pluralRule count="two">n is 2</pluralRule>
-                       <pluralRule count="many">n is not 0 AND n is not 10 AND n mod 10 is 0</pluralRule>
-               </pluralRules>
+               <!-- Lower Sorbian (Dolnoserbski) and  Upper Sorbian (Hornjoserbsce). Not present in CLDR -->
                <pluralRules locales="dsb hsb">
-                       <pluralRule count="one">n mod 100 is 1</pluralRule>
-                       <pluralRule count="two">n mod 100 is 2</pluralRule>
-                       <pluralRule count="few">n mod 100 in 3..4</pluralRule>
+                       <pluralRule count="one">n % 100 = 1 @integer 1, 101, 201, 301, …</pluralRule>
+                       <pluralRule count="two">n % 100 = 2 @integer 2, 102, 202, 302, …</pluralRule>
+                       <pluralRule count="few">n % 100 = 3..4 @integer 3~4, 103~104, …</pluralRule>
+                       <pluralRule count="other"> @integer 5, 6, 7, 8, 9, 10, 105, 206, 307, …</pluralRule>
                </pluralRules>
-               <!-- Copied from "be" -->
+
+               <!-- Belarusian in Taraškievica orthography (Беларуская тарашкевіца). Copied from "be" -->
                <pluralRules locales="be-tarask">
-                       <pluralRule count="one">n mod 10 is 1 and n mod 100 is not 11</pluralRule>
-                       <pluralRule count="few">n mod 10 in 2..4 and n mod 100 not in 12..14</pluralRule>
-                       <pluralRule count="many">n mod 10 is 0 or n mod 10 in 5..9 or n mod 100 in 11..14</pluralRule>
-                       <!-- others are fractions -->
+                       <pluralRule count="one">n % 10 = 1 and n % 100 != 11 @integer 1, 21, 31, 41, 51, 61, 71, 81, 101, 1001, … @decimal 1.0, 21.0, 31.0, 41.0, 51.0, 61.0, 71.0, 81.0, 101.0, 1001.0, …</pluralRule>
+                       <pluralRule count="few">n % 10 = 2..4 and n % 100 != 12..14 @integer 2~4, 22~24, 32~34, 42~44, 52~54, 62, 102, 1002, … @decimal 2.0, 3.0, 4.0, 22.0, 23.0, 24.0, 32.0, 33.0, 102.0, 1002.0, …</pluralRule>
+                       <pluralRule count="many">n % 10 = 0 or n % 10 = 5..9 or n % 100 = 11..14 @integer 0, 5~19, 100, 1000, 10000, 100000, 1000000, … @decimal 0.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, …</pluralRule>
+                       <pluralRule count="other">   @decimal 0.1~0.9, 1.1~1.7, 10.1, 100.1, 1000.1, …</pluralRule>
                </pluralRules>
+               <!--  Old Church Slavonic (Ѩзыкъ словѣньскъ). Not present in CLDR -->
                <pluralRules locales="cu">
-                       <pluralRule count="one">n mod 10 is 1</pluralRule>
-                       <pluralRule count="two">n mod 10 is 2</pluralRule>
-                       <pluralRule count="few">n mod 10 in 3..4</pluralRule>
+                       <pluralRule count="one">n % 10 = 1 @integer 1, 11, 21, 31, …</pluralRule>
+                       <pluralRule count="two">n % 10 = 2 @integer 2, 12, 22, 32, …</pluralRule>
+                       <pluralRule count="few">n % 10 = 3..4 @integer 3~4, 13~14, 23~24, …</pluralRule>
+                       <pluralRule count="other"> @integer 5, 6, 7, 8, 9, 10, 15, 105, 206, 307, …</pluralRule>
                </pluralRules>
                <!-- Copied from "bh" -->
                <pluralRules locales="bho">
-                       <pluralRule count="one">n in 0..1</pluralRule>
+                       <pluralRule count="one">n = 0..1 @integer 0, 1 @decimal 0.0, 1.0, 0.00, 1.00, 0.000, 1.000, 0.0000, 1.0000</pluralRule>
+                       <pluralRule count="other"> @integer 2~17, 100, 1000, 10000, 100000, 1000000, … @decimal 0.1~0.9, 1.1~1.7, 10.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, …</pluralRule>
                </pluralRules>
+               <!-- Samogitian. Not present in CLDR -->
                <pluralRules locales="sgs">
-                       <pluralRule count="one">n mod 10 is 1 and n mod 100 is not 11</pluralRule>
-                       <pluralRule count="two">n mod 10 is 2 and n mod 100 is not 12</pluralRule>
-                       <pluralRule count="few">n is 0 or n mod 100 is 0 or n mod 100 in 10..19</pluralRule>
+                       <pluralRule count="one">n % 10 = 1 and n % 100 != 11 @integer 1, 21, 31, 41, 51, 61, 71, 81, 91, 101, 121, …</pluralRule>
+                       <pluralRule count="two">n % 10 = 2 and n % 100 != 12 @integer 2, 22, 32, 42, 52, 62, 72, 82, 92, 102, 122, …</pluralRule>
+                       <pluralRule count="few">n = 0 or n % 100 = 0 or n % 100 = 10..19 @integer 0, 11, 12, 13, 14, 15, 16, 17, 18, 19, 100, 111,112, …</pluralRule>
+                       <pluralRule count="other"> @integer 3, 4, 5, 6, 7, 8, 9, 20, 103, 104, …</pluralRule>
                </pluralRules>
-               <!-- Override as per https://bugzilla.wikimedia.org/show_bug.cgi?id=47099, porting from CLDR 24 -->
-               <pluralRules locales="gv">
-                       <pluralRule count="one">n mod 10 is 1</pluralRule>
-                       <pluralRule count="two">n mod 10 is 2</pluralRule>
-                       <pluralRule count="few">n mod 100 in 0,20,40,60</pluralRule>
+               <pluralRules locales="sr-el sr-ec">
+                       <pluralRule count="one">v = 0 and i % 10 = 1 and i % 100 != 11 or f % 10 = 1 and f % 100 != 11 @integer 1, 21, 31, 41, 51, 61, 71, 81, 101, 1001, … @decimal 0.1, 1.1, 2.1, 3.1, 4.1, 5.1, 6.1, 7.1, 10.1, 100.1, 1000.1, …</pluralRule>
+                       <pluralRule count="few">v = 0 and i % 10 = 2..4 and i % 100 != 12..14 or f % 10 = 2..4 and f % 100 != 12..14 @integer 2~4, 22~24, 32~34, 42~44, 52~54, 62, 102, 1002, … @decimal 0.2~0.4, 1.2~1.4, 2.2~2.4, 3.2~3.4, 4.2~4.4, 5.2, 10.2, 100.2, 1000.2, …</pluralRule>
+                       <pluralRule count="other"> @integer 0, 5~19, 100, 1000, 10000, 100000, 1000000, … @decimal 0.0, 0.5~1.0, 1.5~2.0, 2.5~2.7, 10.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, …</pluralRule>
                </pluralRules>
        </plurals>
 </supplementalData>
old mode 100644 (file)
new mode 100755 (executable)
index d5a1cfe..fd4eaf6
 <?xml version="1.0" encoding="UTF-8" ?>
 <!DOCTYPE supplementalData SYSTEM "../../common/dtd/ldmlSupplemental.dtd">
+<!--
+Copyright © 1991-2013 Unicode, Inc.
+CLDR data files are interpreted according to the LDML specification (http://unicode.org/reports/tr35/)
+For terms of use, see http://www.unicode.org/copyright.html
+-->
 <supplementalData>
-    <version number="$Revision: 8007 $"/>
-    <generation date="$Date: 2013-01-03 07:17:41 +0530 (Thu, 03 Jan 2013) $"/>
-    <plurals>
+    <version number="$Revision: 9369 $"/>
+    <generation date="$Date: 2013-09-14 01:26:08 +0530 (ശ, 14 സെപ് 2013) $"/>
+    <plurals type="cardinal">
+        <!-- For a canonicalized list, use GeneratedPluralSamples -->
         <!-- if locale is known to have no plurals, there are no rules -->
-        <pluralRules locales="az bm bo dz fa id ig ii hu ja jv ka kde kea km kn ko lo ms my sah ses sg th to tr vi wo yo zh"/>
         <pluralRules locales="ar">
-            <pluralRule count="zero">n is 0</pluralRule>
-            <pluralRule count="one">n is 1</pluralRule>
-            <pluralRule count="two">n is 2</pluralRule>
-            <pluralRule count="few">n mod 100 in 3..10</pluralRule>
-            <pluralRule count="many">n mod 100 in 11..99</pluralRule>
-        </pluralRules>
-        <pluralRules locales="he">
-            <pluralRule count="one">n is 1</pluralRule>
-            <pluralRule count="two">n is 2</pluralRule>
-            <pluralRule count="many">n is not 0 AND n mod 10 is 0</pluralRule>
-        </pluralRules>
-        <pluralRules locales="asa ast af bem bez bg bn brx ca cgg chr ckb da de dv ee el en eo es et eu fi fo fur fy gl gsw gu ha haw hy is it jgo jmc kaj kcg kk kkj kl ks ksb ku ky lb lg mas mgo ml mn mr nah nb nd ne nl nn nnh no nr ny nyn om or os pa pap ps pt rof rm rwk saq seh sn so sq ss ssy st sv sw syr ta te teo tig tk tn ts ur vo wae ve vun xh xog zu">
-            <pluralRule count="one">n is 1</pluralRule>
-        </pluralRules>
-        <pluralRules locales="ak am bh fil tl guw hi ln mg nso ti wa">
-            <pluralRule count="one">n in 0..1</pluralRule>
-        </pluralRules>
-        <pluralRules locales="ff fr kab">
-            <pluralRule count="one">n within 0..2 and n is not 2</pluralRule>
+            <pluralRule count="zero">n = 0 @integer 0 @decimal 0.0, 0.00, 0.000, 0.0000</pluralRule>
+            <pluralRule count="one">n = 1 @integer 1 @decimal 1.0, 1.00, 1.000, 1.0000</pluralRule>
+            <pluralRule count="two">n = 2 @integer 2 @decimal 2.0, 2.00, 2.000, 2.0000</pluralRule>
+            <pluralRule count="few">n % 100 = 3..10 @integer 3~10, 103~110, 1003, … @decimal 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 103.0, 1003.0, …</pluralRule>
+            <pluralRule count="many">n % 100 = 11..99 @integer 11~26, 111, 1011, … @decimal 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0, 18.0, 111.0, 1011.0, …</pluralRule>
+            <pluralRule count="other"> @integer 100~102, 200~202, 300~302, 400~402, 500~502, 600, 1000, 10000, 100000, 1000000, … @decimal 0.1~0.9, 1.1~1.7, 10.1, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, …</pluralRule>
+        </pluralRules>
+        <pluralRules locales="he iw">
+            <pluralRule count="one">i = 1 and v = 0 @integer 1</pluralRule>
+            <pluralRule count="two">i = 2 and v = 0 @integer 2</pluralRule>
+            <pluralRule count="many">v = 0 and n != 0..10 and n % 10 = 0 @integer 20, 30, 40, 50, 60, 70, 80, 90, 100, 1000, 10000, 100000, 1000000, …</pluralRule>
+            <pluralRule count="other"> @integer 0, 3~17, 101, 1001, … @decimal 0.0~1.5, 10.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, …</pluralRule>
+        </pluralRules>
+        <pluralRules locales="af asa ast az bem bez bg brx cgg chr ckb dv ee el eo es eu fo fur fy gsw ha haw hu jgo jmc ka kaj kcg kk kkj kl ks ksb ku ky lb lg mas mgo ml mn nah nb nd ne nn nnh no nr ny nyn om or os pap ps rm rof rwk saq seh sn so sq ss ssy st syr ta te teo tig tk tn tr ts uz ve vo vun wae xh xog">
+            <pluralRule count="one">n = 1 @integer 1 @decimal 1.0, 1.00, 1.000, 1.0000</pluralRule>
+            <pluralRule count="other"> @integer 0, 2~16, 100, 1000, 10000, 100000, 1000000, … @decimal 0.0~0.9, 1.1~1.6, 10.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, …</pluralRule>
+        </pluralRules>
+        <pluralRules locales="ak bh guw ln mg nso pa ti wa">
+            <pluralRule count="one">n = 0..1 @integer 0, 1 @decimal 0.0, 1.0, 0.00, 1.00, 0.000, 1.000, 0.0000, 1.0000</pluralRule>
+            <pluralRule count="other"> @integer 2~17, 100, 1000, 10000, 100000, 1000000, … @decimal 0.1~0.9, 1.1~1.7, 10.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, …</pluralRule>
+        </pluralRules>
+        <pluralRules locales="ff fr hy kab">
+            <pluralRule count="one">i = 0,1 @integer 0, 1 @decimal 0.0~1.5</pluralRule>
+            <pluralRule count="other"> @integer 2~17, 100, 1000, 10000, 100000, 1000000, … @decimal 2.0~3.5, 10.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, …</pluralRule>
         </pluralRules>
         <pluralRules locales="lv">
-            <pluralRule count="zero">n is 0</pluralRule>
-            <pluralRule count="one">n mod 10 is 1 and n mod 100 is not 11</pluralRule>
+            <pluralRule count="zero">n % 10 = 0 or n % 100 = 11..19 or v = 2 and f % 100 = 11..19 @integer 0, 10~20, 30, 40, 50, 60, 100, 1000, 10000, 100000, 1000000, … @decimal 0.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, …</pluralRule>
+            <pluralRule count="one">n % 10 = 1 and n % 100 != 11 or v = 2 and f % 10 = 1 and f % 100 != 11 or v != 2 and f % 10 = 1 @integer 1, 21, 31, 41, 51, 61, 71, 81, 101, 1001, … @decimal 0.1, 1.0, 1.1, 2.1, 3.1, 4.1, 5.1, 6.1, 7.1, 10.1, 100.1, 1000.1, …</pluralRule>
+            <pluralRule count="other"> @integer 2~9, 22~29, 102, 1002, … @decimal 0.2~0.9, 1.2~1.9, 10.2, 100.2, 1000.2, …</pluralRule>
         </pluralRules>
         <pluralRules locales="iu kw naq se sma smi smj smn sms">
-            <pluralRule count="one">n is 1</pluralRule>
-            <pluralRule count="two">n is 2</pluralRule>
-        </pluralRules>
-        <pluralRules locales="ga"> <!-- http://unicode.org/cldr/trac/ticket/3915 -->
-            <pluralRule count="one">n is 1</pluralRule>
-            <pluralRule count="two">n is 2</pluralRule>
-            <pluralRule count="few">n in 3..6</pluralRule>
-            <pluralRule count="many">n in 7..10</pluralRule>
-        </pluralRules>
-        <pluralRules locales="ro mo">
-            <pluralRule count="one">n is 1</pluralRule>
-            <pluralRule count="few">n is 0 OR n is not 1 AND n mod 100 in 1..19</pluralRule>
+            <pluralRule count="one">n = 1 @integer 1 @decimal 1.0, 1.00, 1.000, 1.0000</pluralRule>
+            <pluralRule count="two">n = 2 @integer 2 @decimal 2.0, 2.00, 2.000, 2.0000</pluralRule>
+            <pluralRule count="other"> @integer 0, 3~17, 100, 1000, 10000, 100000, 1000000, … @decimal 0.0~0.9, 1.1~1.6, 10.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, …</pluralRule>
+        </pluralRules>
+        <pluralRules locales="ga">
+            <pluralRule count="one">n = 1 @integer 1 @decimal 1.0, 1.00, 1.000, 1.0000</pluralRule>
+            <pluralRule count="two">n = 2 @integer 2 @decimal 2.0, 2.00, 2.000, 2.0000</pluralRule>
+            <pluralRule count="few">n = 3..6 @integer 3~6 @decimal 3.0, 4.0, 5.0, 6.0, 3.00, 4.00, 5.00, 6.00, 3.000, 4.000, 5.000, 6.000, 3.0000, 4.0000, 5.0000, 6.0000</pluralRule>
+            <pluralRule count="many">n = 7..10 @integer 7~10 @decimal 7.0, 8.0, 9.0, 10.0, 7.00, 8.00, 9.00, 10.00, 7.000, 8.000, 9.000, 10.000, 7.0000, 8.0000, 9.0000, 10.0000</pluralRule>
+            <pluralRule count="other"> @integer 0, 11~25, 100, 1000, 10000, 100000, 1000000, … @decimal 0.0~0.9, 1.1~1.6, 10.1, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, …</pluralRule>
+        </pluralRules>
+        <pluralRules locales="mo ro">
+            <pluralRule count="one">i = 1 and v = 0 @integer 1</pluralRule>
+            <pluralRule count="few">v != 0 or n = 0 or n != 1 and n % 100 = 1..19 @integer 0, 2~16, 101, 1001, … @decimal 0.0~1.5, 10.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, …</pluralRule>
+            <pluralRule count="other"> @integer 20~35, 100, 1000, 10000, 100000, 1000000, …</pluralRule>
         </pluralRules>
         <pluralRules locales="lt">
-            <pluralRule count="one">n mod 10 is 1 and n mod 100 not in 11..19</pluralRule>
-            <pluralRule count="few">n mod 10 in 2..9 and n mod 100 not in 11..19</pluralRule>
+            <pluralRule count="one">n % 10 = 1 and n % 100 != 11..19 @integer 1, 21, 31, 41, 51, 61, 71, 81, 101, 1001, … @decimal 1.0, 21.0, 31.0, 41.0, 51.0, 61.0, 71.0, 81.0, 101.0, 1001.0, …</pluralRule>
+            <pluralRule count="few">n % 10 = 2..9 and n % 100 != 11..19 @integer 2~9, 22~29, 102, 1002, … @decimal 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 22.0, 102.0, 1002.0, …</pluralRule>
+            <pluralRule count="many">f != 0   @decimal 0.1~0.9, 1.1~1.7, 10.1, 100.1, 1000.1, …</pluralRule>
+            <pluralRule count="other"> @integer 0, 10~20, 30, 40, 50, 60, 100, 1000, 10000, 100000, 1000000, … @decimal 0.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, …</pluralRule>
         </pluralRules>
-        <pluralRules locales="be bs hr ru sh sr uk">
-            <pluralRule count="one">n mod 10 is 1 and n mod 100 is not 11</pluralRule>
-            <pluralRule count="few">n mod 10 in 2..4 and n mod 100 not in 12..14</pluralRule>
-            <pluralRule count="many">n mod 10 is 0 or n mod 10 in 5..9 or n mod 100 in 11..14</pluralRule>
-            <!-- others are fractions -->
+        <pluralRules locales="be">
+            <pluralRule count="one">n % 10 = 1 and n % 100 != 11 @integer 1, 21, 31, 41, 51, 61, 71, 81, 101, 1001, … @decimal 1.0, 21.0, 31.0, 41.0, 51.0, 61.0, 71.0, 81.0, 101.0, 1001.0, …</pluralRule>
+            <pluralRule count="few">n % 10 = 2..4 and n % 100 != 12..14 @integer 2~4, 22~24, 32~34, 42~44, 52~54, 62, 102, 1002, … @decimal 2.0, 3.0, 4.0, 22.0, 23.0, 24.0, 32.0, 33.0, 102.0, 1002.0, …</pluralRule>
+            <pluralRule count="many">n % 10 = 0 or n % 10 = 5..9 or n % 100 = 11..14 @integer 0, 5~19, 100, 1000, 10000, 100000, 1000000, … @decimal 0.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, …</pluralRule>
+            <pluralRule count="other">   @decimal 0.1~0.9, 1.1~1.7, 10.1, 100.1, 1000.1, …</pluralRule>
         </pluralRules>
         <pluralRules locales="cs sk">
-            <pluralRule count="one">n is 1</pluralRule>
-            <pluralRule count="few">n in 2..4</pluralRule>
+            <pluralRule count="one">i = 1 and v = 0 @integer 1</pluralRule>
+            <pluralRule count="few">i = 2..4 and v = 0 @integer 2~4</pluralRule>
+            <pluralRule count="many">v != 0   @decimal 0.0~1.5, 10.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, …</pluralRule>
+            <pluralRule count="other"> @integer 0, 5~19, 100, 1000, 10000, 100000, 1000000, …</pluralRule>
         </pluralRules>
         <pluralRules locales="pl">
-            <pluralRule count="one">n is 1</pluralRule>
-            <pluralRule count="few">n mod 10 in 2..4 and n mod 100 not in 12..14</pluralRule>
-            <pluralRule count="many">n is not 1 and n mod 10 in 0..1 or n mod 10 in 5..9 or n mod 100 in 12..14</pluralRule>
-            <!-- others are fractions -->
-            <!-- and n mod 100 not in 22..24 from Tamplin -->
+            <pluralRule count="one">i = 1 and v = 0 @integer 1</pluralRule>
+            <pluralRule count="few">v = 0 and i % 10 = 2..4 and i % 100 != 12..14 @integer 2~4, 22~24, 32~34, 42~44, 52~54, 62, 102, 1002, …</pluralRule>
+            <pluralRule count="many">v = 0 and i != 1 and i % 10 = 0..1 or v = 0 and i % 10 = 5..9 or v = 0 and i % 100 = 12..14 @integer 0, 5~19, 100, 1000, 10000, 100000, 1000000, …</pluralRule>
+            <pluralRule count="other">   @decimal 0.0~1.5, 10.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, …</pluralRule>
         </pluralRules>
         <pluralRules locales="sl">
-            <pluralRule count="one">n mod 100 is 1</pluralRule>
-            <pluralRule count="two">n mod 100 is 2</pluralRule>
-            <pluralRule count="few">n mod 100 in 3..4</pluralRule>
-        </pluralRules>
-        <pluralRules locales="mt"> <!-- from Tamplin's data -->
-            <pluralRule count="one">n is 1</pluralRule>
-            <pluralRule count="few">n is 0 or n mod 100 in 2..10</pluralRule>
-            <pluralRule count="many">n mod 100 in 11..19</pluralRule>
-        </pluralRules>
-        <pluralRules locales="mk"> <!-- from Tamplin's data -->
-            <pluralRule count="one">n mod 10 is 1 and n is not 11</pluralRule>
-        </pluralRules>
-        <pluralRules locales="cy"> <!-- from http://www.saltcymru.org/wordpress/?p=99&lang=en -->
-            <pluralRule count="zero">n is 0</pluralRule>
-            <pluralRule count="one">n is 1</pluralRule>
-            <pluralRule count="two">n is 2</pluralRule>
-            <pluralRule count="few">n is 3</pluralRule>
-            <pluralRule count="many">n is 6</pluralRule>
+            <pluralRule count="one">v = 0 and i % 100 = 1 @integer 1, 101, 201, 301, 401, 501, 601, 701, 1001, …</pluralRule>
+            <pluralRule count="two">v = 0 and i % 100 = 2 @integer 2, 102, 202, 302, 402, 502, 602, 702, 1002, …</pluralRule>
+            <pluralRule count="few">v = 0 and i % 100 = 3..4 or v != 0 @integer 3, 4, 103, 104, 203, 204, 303, 304, 403, 404, 503, 504, 603, 604, 703, 704, 1003, … @decimal 0.0~1.5, 10.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, …</pluralRule>
+            <pluralRule count="other"> @integer 0, 5~19, 100, 1000, 10000, 100000, 1000000, …</pluralRule>
+        </pluralRules>
+        <pluralRules locales="mt">
+            <pluralRule count="one">n = 1 @integer 1 @decimal 1.0, 1.00, 1.000, 1.0000</pluralRule>
+            <pluralRule count="few">n = 0 or n % 100 = 2..10 @integer 0, 2~10, 102~107, 1002, … @decimal 0.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 10.0, 102.0, 1002.0, …</pluralRule>
+            <pluralRule count="many">n % 100 = 11..19 @integer 11~19, 111~117, 1011, … @decimal 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0, 18.0, 111.0, 1011.0, …</pluralRule>
+            <pluralRule count="other"> @integer 20~35, 100, 1000, 10000, 100000, 1000000, … @decimal 0.1~0.9, 1.1~1.7, 10.1, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, …</pluralRule>
+        </pluralRules>
+        <pluralRules locales="mk">
+            <pluralRule count="one">v = 0 and i % 10 = 1 or f % 10 = 1 @integer 1, 11, 21, 31, 41, 51, 61, 71, 101, 1001, … @decimal 0.1, 1.1, 2.1, 3.1, 4.1, 5.1, 6.1, 7.1, 10.1, 100.1, 1000.1, …</pluralRule>
+            <pluralRule count="other"> @integer 0, 2~10, 12~17, 100, 1000, 10000, 100000, 1000000, … @decimal 0.0, 0.2~1.0, 1.2~1.7, 10.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, …</pluralRule>
+        </pluralRules>
+        <pluralRules locales="cy">
+            <pluralRule count="zero">n = 0 @integer 0 @decimal 0.0, 0.00, 0.000, 0.0000</pluralRule>
+            <pluralRule count="one">n = 1 @integer 1 @decimal 1.0, 1.00, 1.000, 1.0000</pluralRule>
+            <pluralRule count="two">n = 2 @integer 2 @decimal 2.0, 2.00, 2.000, 2.0000</pluralRule>
+            <pluralRule count="few">n = 3 @integer 3 @decimal 3.0, 3.00, 3.000, 3.0000</pluralRule>
+            <pluralRule count="many">n = 6 @integer 6 @decimal 6.0, 6.00, 6.000, 6.0000</pluralRule>
+            <pluralRule count="other"> @integer 4, 5, 7~20, 100, 1000, 10000, 100000, 1000000, … @decimal 0.1~0.9, 1.1~1.7, 10.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, …</pluralRule>
         </pluralRules>
         <pluralRules locales="lag">
-            <pluralRule count="zero">n is 0</pluralRule>
-            <pluralRule count="one">n within 0..2 and n is not 0 and n is not 2</pluralRule>
+            <pluralRule count="zero">n = 0 @integer 0 @decimal 0.0, 0.00, 0.000, 0.0000</pluralRule>
+            <pluralRule count="one">i = 0,1 and n != 0 @integer 1 @decimal 0.1~1.6</pluralRule>
+            <pluralRule count="other"> @integer 2~17, 100, 1000, 10000, 100000, 1000000, … @decimal 2.0~3.5, 10.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, …</pluralRule>
         </pluralRules>
         <pluralRules locales="shi">
-            <pluralRule count="one">n within 0..1</pluralRule>
-            <pluralRule count="few">n in 2..10</pluralRule>
+            <pluralRule count="one">i = 0 or n = 1 @integer 0, 1 @decimal 0.0~1.0, 0.00~0.04</pluralRule>
+            <pluralRule count="few">n = 2..10 @integer 2~10 @decimal 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 2.00, 3.00, 4.00, 5.00, 6.00, 7.00, 8.00</pluralRule>
+            <pluralRule count="other"> @integer 11~26, 100, 1000, 10000, 100000, 1000000, … @decimal 1.1~1.9, 2.1~2.7, 10.1, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, …</pluralRule>
         </pluralRules>
-        <pluralRules locales="br"> <!-- from http://unicode.org/cldr/trac/ticket/2886 -->
-            <pluralRule count="one">n mod 10 is 1 and n mod 100 not in 11,71,91</pluralRule>
-            <pluralRule count="two">n mod 10 is 2 and n mod 100 not in 12,72,92</pluralRule>
-            <pluralRule count="few">n mod 10 in 3..4,9 and n mod 100 not in 10..19,70..79,90..99</pluralRule>
-            <pluralRule count="many">n is not 0 and n mod 1000000 is 0</pluralRule>
+        <pluralRules locales="br">
+            <pluralRule count="one">n % 10 = 1 and n % 100 != 11,71,91 @integer 1, 21, 31, 41, 51, 61, 81, 101, 1001, … @decimal 1.0, 21.0, 31.0, 41.0, 51.0, 61.0, 81.0, 101.0, 1001.0, …</pluralRule>
+            <pluralRule count="two">n % 10 = 2 and n % 100 != 12,72,92 @integer 2, 22, 32, 42, 52, 62, 82, 102, 1002, … @decimal 2.0, 22.0, 32.0, 42.0, 52.0, 62.0, 82.0, 102.0, 1002.0, …</pluralRule>
+            <pluralRule count="few">n % 10 = 3..4,9 and n % 100 != 10..19,70..79,90..99 @integer 3, 4, 9, 23, 24, 29, 33, 34, 39, 43, 44, 49, 103, 1003, … @decimal 3.0, 4.0, 9.0, 23.0, 24.0, 29.0, 33.0, 34.0, 103.0, 1003.0, …</pluralRule>
+            <pluralRule count="many">n != 0 and n % 1000000 = 0 @integer 1000000, … @decimal 1000000.0, 1000000.00, 1000000.000, …</pluralRule>
+            <pluralRule count="other"> @integer 0, 5~8, 10~20, 100, 1000, 10000, 100000, … @decimal 0.0~0.9, 1.1~1.6, 10.0, 100.0, 1000.0, 10000.0, 100000.0, …</pluralRule>
         </pluralRules>
         <pluralRules locales="ksh">
-            <pluralRule count="zero">n is 0</pluralRule>
-            <pluralRule count="one">n is 1</pluralRule>
+            <pluralRule count="zero">n = 0 @integer 0 @decimal 0.0, 0.00, 0.000, 0.0000</pluralRule>
+            <pluralRule count="one">n = 1 @integer 1 @decimal 1.0, 1.00, 1.000, 1.0000</pluralRule>
+            <pluralRule count="other"> @integer 2~17, 100, 1000, 10000, 100000, 1000000, … @decimal 0.1~0.9, 1.1~1.7, 10.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, …</pluralRule>
         </pluralRules>
         <pluralRules locales="tzm">
-            <pluralRule count="one">n in 0..1 or n in 11..99</pluralRule>
+            <pluralRule count="one">n = 0..1 or n = 11..99 @integer 0, 1, 11~24 @decimal 0.0, 1.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0, 18.0, 19.0, 20.0, 21.0, 22.0, 23.0, 24.0</pluralRule>
+            <pluralRule count="other"> @integer 2~10, 100~106, 1000, 10000, 100000, 1000000, … @decimal 0.1~0.9, 1.1~1.7, 10.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, …</pluralRule>
         </pluralRules>
         <pluralRules locales="gv">
-            <pluralRule count="one">n mod 10 in 1..2 or n mod 20 is 0</pluralRule>
+            <pluralRule count="one">n % 10 = 1 @integer 1, 11, 21, 31, 41, 51, 61, 71, 101, 1001, … @decimal 1.0, 11.0, 21.0, 31.0, 41.0, 51.0, 61.0, 71.0, 101.0, 1001.0, …</pluralRule>
+            <pluralRule count="two">n % 10 = 2 @integer 2, 12, 22, 32, 42, 52, 62, 72, 102, 1002, … @decimal 2.0, 12.0, 22.0, 32.0, 42.0, 52.0, 62.0, 72.0, 102.0, 1002.0, …</pluralRule>
+            <pluralRule count="few">n % 100 = 0,20,40,60 @integer 0, 20, 40, 60, 100, 120, 140, 160, 1000, 10000, 100000, 1000000, … @decimal 0.0, 20.0, 40.0, 60.0, 100.0, 120.0, 140.0, 160.0, 1000.0, 10000.0, 100000.0, 1000000.0, …</pluralRule>
+            <pluralRule count="other"> @integer 3~10, 13~19, 23, 103, 1003, … @decimal 0.1~0.9, 1.1~1.7, 10.0, 100.1, 1000.1, …</pluralRule>
         </pluralRules>
         <pluralRules locales="gd">
-            <pluralRule count="one">n in 1,11</pluralRule>
-            <pluralRule count="two">n in 2,12</pluralRule>
-            <pluralRule count="few">n in 3..10,13..19</pluralRule>
+            <pluralRule count="one">n = 1,11 @integer 1, 11 @decimal 1.0, 11.0, 1.00, 11.00, 1.000, 11.000, 1.0000</pluralRule>
+            <pluralRule count="two">n = 2,12 @integer 2, 12 @decimal 2.0, 12.0, 2.00, 12.00, 2.000, 12.000, 2.0000</pluralRule>
+            <pluralRule count="few">n = 3..10,13..19 @integer 3~10, 13~19 @decimal 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 13.0, 14.0, 15.0, 16.0, 17.0, 18.0, 19.0, 3.00</pluralRule>
+            <pluralRule count="other"> @integer 0, 20~34, 100, 1000, 10000, 100000, 1000000, … @decimal 0.0~0.9, 1.1~1.6, 10.1, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, …</pluralRule>
+        </pluralRules>
+        <pluralRules locales="bm bo dz id ig ii in ja jbo jv jw kde kea km ko lkt lo ms my nqo sah ses sg th to vi wo yo zh">
+            <pluralRule count="other"> @integer 0~15, 100, 1000, 10000, 100000, 1000000, … @decimal 0.0~1.5, 10.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, …</pluralRule>
+        </pluralRules>
+        <pluralRules locales="fil tl">
+            <pluralRule count="one">i = 0..1 and v = 0 @integer 0, 1</pluralRule>
+            <pluralRule count="other"> @integer 2~17, 100, 1000, 10000, 100000, 1000000, … @decimal 0.0~1.5, 10.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, …</pluralRule>
+        </pluralRules>
+        <pluralRules locales="ca de en et fi gl it ji nl sv sw ur yi">
+            <pluralRule count="one">i = 1 and v = 0 @integer 1</pluralRule>
+            <pluralRule count="other"> @integer 0, 2~16, 100, 1000, 10000, 100000, 1000000, … @decimal 0.0~1.5, 10.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, …</pluralRule>
+        </pluralRules>
+        <pluralRules locales="pt">
+            <pluralRule count="one">i = 1 and v = 0 or i = 0 and t = 1 @integer 1 @decimal 0.1, 0.01, 0.10, 0.001, 0.010, 0.100, 0.0001, 0.0010, 0.0100, 0.1000</pluralRule>
+            <pluralRule count="other"> @integer 0, 2~16, 100, 1000, 10000, 100000, 1000000, … @decimal 0.0, 0.2~1.6, 10.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, …</pluralRule>
+        </pluralRules>
+        <pluralRules locales="da">
+            <pluralRule count="one">n = 1 or t != 0 and i = 0,1 @integer 1 @decimal 0.1~1.6</pluralRule>
+            <pluralRule count="other"> @integer 0, 2~16, 100, 1000, 10000, 100000, 1000000, … @decimal 0.0, 2.0~3.4, 10.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, …</pluralRule>
+        </pluralRules>
+        <pluralRules locales="pt_PT">
+            <pluralRule count="one">n = 1 and v = 0 @integer 1</pluralRule>
+            <pluralRule count="other"> @integer 0, 2~16, 100, 1000, 10000, 100000, 1000000, … @decimal 0.0~1.5, 10.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, …</pluralRule>
+        </pluralRules>
+        <pluralRules locales="am bn fa gu hi kn mr zu">
+            <pluralRule count="one">i = 0 or n = 1 @integer 0, 1 @decimal 0.0~1.0, 0.00~0.04</pluralRule>
+            <pluralRule count="other"> @integer 2~17, 100, 1000, 10000, 100000, 1000000, … @decimal 1.1~2.6, 10.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, …</pluralRule>
+        </pluralRules>
+        <pluralRules locales="is">
+            <pluralRule count="one">t = 0 and i % 10 = 1 and i % 100 != 11 or t != 0 @integer 1, 21, 31, 41, 51, 61, 71, 81, 101, 1001, … @decimal 0.1~1.6, 10.1, 100.1, 1000.1, …</pluralRule>
+            <pluralRule count="other"> @integer 0, 2~16, 100, 1000, 10000, 100000, 1000000, … @decimal 0.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 10.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, …</pluralRule>
+        </pluralRules>
+        <pluralRules locales="si">
+            <pluralRule count="one">n = 0,1 or i = 0 and f = 1 @integer 0, 1 @decimal 0.0, 0.1, 1.0, 0.00, 0.01, 1.00, 0.000, 0.001, 1.000, 0.0000, 0.0001, 1.0000</pluralRule>
+            <pluralRule count="other"> @integer 2~17, 100, 1000, 10000, 100000, 1000000, … @decimal 0.2~0.9, 1.1~1.8, 10.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, …</pluralRule>
+        </pluralRules>
+        <pluralRules locales="bs hr sh sr">
+            <pluralRule count="one">v = 0 and i % 10 = 1 and i % 100 != 11 or f % 10 = 1 and f % 100 != 11 @integer 1, 21, 31, 41, 51, 61, 71, 81, 101, 1001, … @decimal 0.1, 1.1, 2.1, 3.1, 4.1, 5.1, 6.1, 7.1, 10.1, 100.1, 1000.1, …</pluralRule>
+            <pluralRule count="few">v = 0 and i % 10 = 2..4 and i % 100 != 12..14 or f % 10 = 2..4 and f % 100 != 12..14 @integer 2~4, 22~24, 32~34, 42~44, 52~54, 62, 102, 1002, … @decimal 0.2~0.4, 1.2~1.4, 2.2~2.4, 3.2~3.4, 4.2~4.4, 5.2, 10.2, 100.2, 1000.2, …</pluralRule>
+            <pluralRule count="other"> @integer 0, 5~19, 100, 1000, 10000, 100000, 1000000, … @decimal 0.0, 0.5~1.0, 1.5~2.0, 2.5~2.7, 10.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, …</pluralRule>
+        </pluralRules>
+        <pluralRules locales="ru">
+            <pluralRule count="one">v = 0 and i % 10 = 1 and i % 100 != 11 @integer 1, 21, 31, 41, 51, 61, 71, 81, 101, 1001, …</pluralRule>
+            <pluralRule count="many">v = 0 and i % 10 = 0 or v = 0 and i % 10 = 5..9 or v = 0 and i % 100 = 11..14 @integer 0, 5~19, 100, 1000, 10000, 100000, 1000000, …</pluralRule>
+            <pluralRule count="other"> @integer 2~4, 22~24, 32~34, 42~44, 52~54, 62, 102, 1002, … @decimal 0.0~1.5, 10.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, …</pluralRule>
+        </pluralRules>
+        <pluralRules locales="uk">
+            <pluralRule count="one">v = 0 and i % 10 = 1 and i % 100 != 11 @integer 1, 21, 31, 41, 51, 61, 71, 81, 101, 1001, …</pluralRule>
+            <pluralRule count="few">v = 0 and i % 10 = 2..4 and i % 100 != 12..14 @integer 2~4, 22~24, 32~34, 42~44, 52~54, 62, 102, 1002, …</pluralRule>
+            <pluralRule count="many">v = 0 and i % 10 = 0 or v = 0 and i % 10 = 5..9 or v = 0 and i % 100 = 11..14 @integer 0, 5~19, 100, 1000, 10000, 100000, 1000000, …</pluralRule>
+            <pluralRule count="other">   @decimal 0.0~1.5, 10.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, …</pluralRule>
         </pluralRules>
     </plurals>
 </supplementalData>
index 441bc91..3def37c 100644 (file)
@@ -1,7 +1,7 @@
-/* This is cldrpluralparser 1.0, ported to MediaWiki ResourceLoader */
+/* This is CLDRPluralRuleParser v1.1, ported to MediaWiki ResourceLoader */
 
 /**
-* cldrpluralparser.js
+* CLDRPluralRuleParser.js
 * A parser engine for CLDR plural rules.
 *
 * Copyright 2012 GPLV3+, Santhosh Thottingal
 * @author Amir Aharoni
 */
 
+( function ( mw ) {
 /**
  * Evaluates a plural rule in CLDR syntax for a number
- * @param rule
- * @param number
- * @return true|false|null
+ * @param {string} rule
+ * @param {integer} number
+ * @return {boolean} true if evaluation passed, false if evaluation failed.
  */
-( function( mw ) {
 
 function pluralRuleParser(rule, number) {
        /*
        Syntax: see http://unicode.org/reports/tr35/#Language_Plural_Rules
        -----------------------------------------------------------------
-
        condition     = and_condition ('or' and_condition)*
+               ('@integer' samples)?
+               ('@decimal' samples)?
        and_condition = relation ('and' relation)*
-       relation      = is_relation | in_relation | within_relation | 'n' <EOL>
+       relation      = is_relation | in_relation | within_relation
        is_relation   = expr 'is' ('not')? value
-       in_relation   = expr ('not')? 'in' range_list
+       in_relation   = expr (('not')? 'in' | '=' | '!=') range_list
        within_relation = expr ('not')? 'within' range_list
-       expr          = 'n' ('mod' value)?
+       expr          = operand (('mod' | '%') value)?
+       operand       = 'n' | 'i' | 'f' | 't' | 'v' | 'w'
        range_list    = (range | value) (',' range_list)*
        value         = digit+
        digit         = 0|1|2|3|4|5|6|7|8|9
        range         = value'..'value
-
+       samples       = sampleRange (',' sampleRange)* (',' ('…'|'...'))?
+       sampleRange   = decimalValue '~' decimalValue
+       decimalValue  = value ('.' value)?
        */
+
+       // we don't evaluate the samples section of the rule. Ignore it.
+       rule = rule.split('@')[0].trim();
+
+       if (!rule.length) {
+               // empty rule or 'other' rule.
+               return true;
+       }
        // Indicates current position in the rule as we parse through it.
        // Shared among all parsing functions below.
-       var pos = 0;
-
-       var whitespace = makeRegexParser(/^\s+/);
-       var digits = makeRegexParser(/^\d+/);
-
-       var _n_ = makeStringParser('n');
-       var _is_ = makeStringParser('is');
-       var _mod_ = makeStringParser('mod');
-       var _not_ = makeStringParser('not');
-       var _in_ = makeStringParser('in');
-       var _within_ = makeStringParser('within');
-       var _range_ = makeStringParser('..');
-       var _comma_ = makeStringParser(',');
-       var _or_ = makeStringParser('or');
-       var _and_ = makeStringParser('and');
+       var pos = 0,
+               operand,
+               expression,
+               relation,
+               result,
+               whitespace = makeRegexParser(/^\s+/),
+               value = makeRegexParser(/^\d+/),
+               _n_ = makeStringParser('n'),
+               _i_ = makeStringParser('i'),
+               _f_ = makeStringParser('f'),
+               _t_ = makeStringParser('t'),
+               _v_ = makeStringParser('v'),
+               _w_ = makeStringParser('w'),
+               _is_ = makeStringParser('is'),
+               _isnot_ = makeStringParser('is not'),
+               _isnot_sign_ = makeStringParser('!='),
+               _equal_ = makeStringParser('='),
+               _mod_ = makeStringParser('mod'),
+               _percent_ = makeStringParser('%'),
+               _not_ = makeStringParser('not'),
+               _in_ = makeStringParser('in'),
+               _within_ = makeStringParser('within'),
+               _range_ = makeStringParser('..'),
+               _comma_ = makeStringParser(','),
+               _or_ = makeStringParser('or'),
+               _and_ = makeStringParser('and');
 
        function debug() {
-               /* console.log.apply(console, arguments);*/
+               // console.log.apply(console, arguments);
        }
 
        debug('pluralRuleParser', rule, number);
 
        // Try parsers until one works, if none work return null
+
        function choice(parserSyntax) {
-               return function () {
+               return function() {
                        for (var i = 0; i < parserSyntax.length; i++) {
                                var result = parserSyntax[i]();
                                if (result !== null) {
@@ -79,6 +103,7 @@ function pluralRuleParser(rule, number) {
        // Try several parserSyntax-es in a row.
        // All must succeed; otherwise, return null.
        // This is the only eager one.
+
        function sequence(parserSyntax) {
                var originalPos = pos;
                var result = [];
@@ -95,8 +120,9 @@ function pluralRuleParser(rule, number) {
 
        // Run the same parser over and over until it fails.
        // Must succeed a minimum of n times; otherwise, return null.
+
        function nOrMore(n, p) {
-               return function () {
+               return function() {
                        var originalPos = pos;
                        var result = [];
                        var parsed = p();
@@ -113,21 +139,21 @@ function pluralRuleParser(rule, number) {
        }
 
        // Helpers -- just make parserSyntax out of simpler JS builtin types
-
        function makeStringParser(s) {
                var len = s.length;
-               return function () {
+               return function() {
                        var result = null;
                        if (rule.substr(pos, len) === s) {
                                result = s;
                                pos += len;
                        }
+
                        return result;
                };
        }
 
        function makeRegexParser(regex) {
-               return function () {
+               return function() {
                        var matches = rule.substr(pos).match(regex);
                        if (matches === null) {
                                return null;
@@ -137,62 +163,166 @@ function pluralRuleParser(rule, number) {
                };
        }
 
+       /*
+        * integer digits of n.
+        */
+       function i() {
+               var result = _i_();
+               if (result === null) {
+                       debug(' -- failed i', parseInt(number, 10));
+                       return result;
+               }
+               result = parseInt(number, 10);
+               debug(' -- passed i ', result);
+               return result;
+       }
+
+       /*
+        * absolute value of the source number (integer and decimals).
+        */
        function n() {
                var result = _n_();
                if (result === null) {
-                       debug(" -- failed n");
+                       debug(' -- failed n ', number);
                        return result;
                }
-               result = parseInt(number, 10);
-               debug(" -- passed n ", result);
+               result = parseFloat(number, 10);
+               debug(' -- passed n ', result);
+               return result;
+       }
+
+       /*
+        * visible fractional digits in n, with trailing zeros.
+        */
+       function f() {
+               var result = _f_();
+               if (result === null) {
+                       debug(' -- failed f ', number);
+                       return result;
+               }
+               result = (number + '.').split('.')[1] || 0;
+               debug(' -- passed f ', result);
+               return result;
+       }
+
+       /*
+        * visible fractional digits in n, without trailing zeros.
+        */
+       function t() {
+               var result = _t_();
+               if (result === null) {
+                       debug(' -- failed t ', number);
+                       return result;
+               }
+               result = (number + '.').split('.')[1].replace(/0$/, '') || 0;
+               debug(' -- passed t ', result);
+               return result;
+       }
+
+       /*
+        * number of visible fraction digits in n, with trailing zeros.
+        */
+       function v() {
+               var result = _v_();
+               if (result === null) {
+                       debug(' -- failed v ', number);
+                       return result;
+               }
+               result = (number + '.').split('.')[1].length || 0;
+               debug(' -- passed v ', result);
+               return result;
+       }
+
+       /*
+        * number of visible fraction digits in n, without trailing zeros.
+        */
+       function w() {
+               var result = _w_();
+               if (result === null) {
+                       debug(' -- failed w ', number);
+                       return result;
+               }
+               result = (number + '.').split('.')[1].replace(/0$/, '').length || 0;
+               debug(' -- passed w ', result);
                return result;
        }
 
-       var expression = choice([mod, n]);
+       // operand       = 'n' | 'i' | 'f' | 't' | 'v' | 'w'
+       operand = choice([n, i, f, t, v, w]);
+
+       // expr          = operand (('mod' | '%') value)?
+       expression = choice([mod, operand]);
 
        function mod() {
-               var result = sequence([n, whitespace, _mod_, whitespace, digits]);
+               var result = sequence([operand, whitespace, choice([_mod_, _percent_]), whitespace, value]);
                if (result === null) {
-                       debug(" -- failed mod");
+                       debug(' -- failed mod');
                        return null;
                }
-               debug(" -- passed mod");
+               debug(' -- passed ' + parseInt(result[0], 10) + ' ' + result[2] + ' ' + parseInt(result[4], 10));
                return parseInt(result[0], 10) % parseInt(result[4], 10);
        }
 
        function not() {
                var result = sequence([whitespace, _not_]);
                if (result === null) {
-                       debug(" -- failed not");
+                       debug(' -- failed not');
                        return null;
-               } else {
-                       return result[1];
                }
+
+               return result[1];
        }
 
+       // is_relation   = expr 'is' ('not')? value
        function is() {
-               var result = sequence([expression, whitespace, _is_, nOrMore(0, not), whitespace, digits]);
+               var result = sequence([expression, whitespace, choice([_is_]), whitespace, value]);
                if (result !== null) {
-                       debug(" -- passed is");
-                       if (result[3][0] === 'not') {
-                               return result[0] !== parseInt(result[5], 10);
-                       } else {
-                               return result[0] === parseInt(result[5], 10);
+                       debug(' -- passed is : ' + result[0] + ' == ' + parseInt(result[4], 10));
+                       return result[0] === parseInt(result[4], 10);
+               }
+               debug(' -- failed is');
+               return null;
+       }
+
+       // is_relation   = expr 'is' ('not')? value
+       function isnot() {
+               var result = sequence([expression, whitespace, choice([_isnot_, _isnot_sign_]), whitespace, value]);
+               if (result !== null) {
+                       debug(' -- passed isnot: ' + result[0] + ' != ' + parseInt(result[4], 10));
+                       return result[0] !== parseInt(result[4], 10);
+               }
+               debug(' -- failed isnot');
+               return null;
+       }
+
+       function not_in() {
+               var result = sequence([expression, whitespace, _isnot_sign_, whitespace, rangeList]);
+               if (result !== null) {
+                       debug(' -- passed not_in: ' + result[0] + ' != ' + result[4]);
+                       var range_list = result[4];
+                       for (var i = 0; i < range_list.length; i++) {
+                               if (parseInt(range_list[i], 10) === parseInt(result[0], 10)) {
+                                       return false;
+                               }
                        }
+                       return true;
                }
-               debug(" -- failed is");
+               debug(' -- failed not_in');
                return null;
        }
 
+       // range_list    = (range | value) (',' range_list)*
        function rangeList() {
-               // range_list    = (range | value) (',' range_list)*
-               var result = sequence([choice([range, digits]), nOrMore(0, rangeTail)]);
+               var result = sequence([choice([range, value]), nOrMore(0, rangeTail)]);
                var resultList = [];
                if (result !== null) {
-                       resultList = resultList.concat(result[0], result[1][0]);
+                       resultList = resultList.concat(result[0]);
+                       if (result[1][0]) {
+                               resultList = resultList.concat(result[1][0]);
+                       }
                        return resultList;
                }
-               debug(" -- failed rangeList");
+               debug(' -- failed rangeList');
                return null;
        }
 
@@ -202,111 +332,141 @@ function pluralRuleParser(rule, number) {
                if (result !== null) {
                        return result[1];
                }
-               debug(" -- failed rangeTail");
+               debug(' -- failed rangeTail');
                return null;
        }
 
+       // range         = value'..'value
+
        function range() {
                var i;
-               var result = sequence([digits, _range_, digits]);
+               var result = sequence([value, _range_, value]);
                if (result !== null) {
-                       debug(" -- passed range");
+                       debug(' -- passed range');
                        var array = [];
                        var left = parseInt(result[0], 10);
                        var right = parseInt(result[2], 10);
-                       for ( i = left; i <= right; i++) {
+                       for (i = left; i <= right; i++) {
                                array.push(i);
                        }
                        return array;
                }
-               debug(" -- failed range");
+               debug(' -- failed range');
                return null;
        }
 
        function _in() {
                // in_relation   = expr ('not')? 'in' range_list
-               var result = sequence([expression, nOrMore(0, not), whitespace, _in_, whitespace, rangeList]);
+               var result = sequence([expression, nOrMore(0, not), whitespace, choice([_in_, _equal_]), whitespace, rangeList]);
                if (result !== null) {
-                       debug(" -- passed _in");
+                       debug(' -- passed _in:' + result);
                        var range_list = result[5];
                        for (var i = 0; i < range_list.length; i++) {
-                               if (parseInt(range_list[i], 10) === result[0]) {
+                               if (parseInt(range_list[i], 10) === parseInt(result[0], 10)) {
                                        return (result[1][0] !== 'not');
                                }
                        }
                        return (result[1][0] === 'not');
                }
-               debug(" -- failed _in ");
+               debug(' -- failed _in ');
                return null;
        }
 
+       /*
+        * The difference between in and within is that in only includes integers in the specified range,
+        * while within includes all values.
+        */
+
        function within() {
-               var result = sequence([expression, whitespace, _within_, whitespace, rangeList]);
+               // within_relation = expr ('not')? 'within' range_list
+               var result = sequence([expression, nOrMore(0, not), whitespace, _within_, whitespace, rangeList]);
                if (result !== null) {
-                       debug(" -- passed within ");
-                       var range_list = result[4];
-                       return (parseInt( range_list[0],10 )<= result[0] && result[0] <= parseInt( range_list[1], 10));
+                       debug(' -- passed within');
+                       var range_list = result[5];
+                       if ((result[0] >= parseInt(range_list[0], 10)) &&
+                               (result[0] < parseInt(range_list[range_list.length - 1], 10))) {
+                               return (result[1][0] !== 'not');
+                       }
+                       return (result[1][0] === 'not');
                }
-               debug(" -- failed within ");
+               debug(' -- failed within ');
                return null;
        }
 
+       // relation      = is_relation | in_relation | within_relation
+       relation = choice([is, not_in, isnot, _in, within]);
 
-       var relation = choice([is, _in, within]);
-
+       // and_condition = relation ('and' relation)*
        function and() {
-               var result = sequence([relation, whitespace, _and_, whitespace, condition]);
+               var result = sequence([relation, nOrMore(0, andTail)]);
                if (result) {
-                       debug(" -- passed and");
-                       return result[0] && result[4];
+                       if (!result[0]) {
+                               return false;
+                       }
+                       for (var i = 0; i < result[1].length; i++) {
+                               if (!result[1][i]) {
+                                       return false;
+                               }
+                       }
+                       return true;
                }
-               debug(" -- failed and");
+               debug(' -- failed and');
                return null;
        }
 
-       function or() {
-               var result = sequence([relation, whitespace, _or_, whitespace, condition]);
-               if (result) {
-                       debug(" -- passed or");
-                       return result[0] || result[4];
+       // ('and' relation)*
+       function andTail() {
+               var result = sequence([whitespace, _and_, whitespace, relation]);
+               if (result !== null) {
+                       debug(' -- passed andTail' + result);
+                       return result[3];
                }
-               debug(" -- failed or");
+               debug(' -- failed andTail');
                return null;
-       }
 
-       var condition = choice([and, or, relation]);
+       }
+       //  ('or' and_condition)*
+       function orTail() {
+               var result = sequence([whitespace, _or_, whitespace, and]);
+               if (result !== null) {
+                       debug(' -- passed orTail: ' + result[3]);
+                       return result[3];
+               }
+               debug(' -- failed orTail');
+               return null;
 
-       function isInt(n) {
-               return parseFloat(n) % 1 === 0;
        }
 
+       // condition     = and_condition ('or' and_condition)*
+       function condition() {
+               var result = sequence([and, nOrMore(0, orTail)]);
+               if (result) {
+                       for (var i = 0; i < result[1].length; i++) {
+                               if (result[1][i]) {
+                                       return true;
+                               }
+                       }
+                       return result[0];
 
-       function start() {
-               if (!isInt(number)) {
-                       return false;
                }
-               var result = condition();
-               return result;
+               return false;
        }
 
-
-       var result = start();
-
+       result = condition();
        /*
         * For success, the pos must have gotten to the end of the rule
         * and returned a non-null.
         * n.b. This is part of language infrastructure, so we do not throw an internationalizable message.
         */
-       if (result === null || pos !== rule.length) {
-               // throw new Error("Parse error at position " + pos.toString() + " in input: " + rule + " result is " + result);
+       if (result === null) {
+               throw new Error('Parse error at position ' + pos.toString() + ' for rule: ' + rule);
        }
 
-       return result;
-}
+       if (pos !== rule.length) {
+               debug('Warning: Rule not parsed completely. Parser stopped at ' + rule.substr(0, pos) + ' for rule: ' + rule);
+       }
 
-/* For module loaders, e.g. NodeJS, NPM */
-if (typeof module !== 'undefined' && module.exports) {
-       module.exports = pluralRuleParser;
+       return result;
 }
 
 /* pluralRuleParser ends here */
diff --git a/tests/phpunit/includes/RunningStatTest.php b/tests/phpunit/includes/RunningStatTest.php
deleted file mode 100644 (file)
index e24c088..0000000
+++ /dev/null
@@ -1,81 +0,0 @@
-<?php
-/**
- * PHP Unit tests for RunningStat class.
- * @covers RunningStat
- */
-class RunningStatTest extends MediaWikiTestCase {
-
-       public $points = array(
-               49.7168, 74.3804,  7.0115, 96.5769, 34.9458,
-               36.9947, 33.8926, 89.0774, 23.7745, 73.5154,
-               86.1322, 53.2124, 16.2046, 73.5130, 10.4209,
-               42.7299, 49.3330, 47.0215, 34.9950, 18.2914,
-       );
-
-       /**
-        * Verify that the statistical moments and extrema computed by RunningStat
-        * match expected values.
-        * @covers RunningStat::push
-        * @covers RunningStat::count
-        * @covers RunningStat::getMean
-        * @covers RunningStat::getVariance
-        * @covers RunningStat::getStdDev
-        */
-       public function testRunningStatAccuracy() {
-               $rstat = new RunningStat();
-               foreach( $this->points as $point ) {
-                       $rstat->push( $point );
-               }
-
-               $mean = array_sum( $this->points ) / count( $this->points );
-               $variance = array_sum( array_map( function ( $x ) use ( $mean ) {
-                       return pow( $mean - $x, 2 );
-               }, $this->points ) ) / ( count( $rstat ) - 1 );
-               $stddev = sqrt( $variance );
-               $min = min( $this->points );
-               $max = max( $this->points );
-
-               $this->assertEquals( count( $rstat ), count( $this->points ) );
-               $this->assertEquals( $rstat->min, min( $this->points ) );
-               $this->assertEquals( $rstat->max, max( $this->points ) );
-               $this->assertEquals( $rstat->getMean(), $mean );
-               $this->assertEquals( $rstat->getVariance(), $variance );
-               $this->assertEquals( $rstat->getStdDev(), $stddev );
-       }
-
-       /**
-        * When one RunningStat instance is merged into another, the state of the
-        * target RunningInstance should have the state that it would have had if
-        * all the data had been accumulated by it alone.
-        * @covers RunningStat::merge
-        * @covers RunningStat::count
-        */
-       public function testRunningStatMerge() {
-               $expected = new RunningStat();
-
-               foreach( $this->points as $point ) {
-                       $expected->push( $point );
-               }
-
-               // Split the data into two sets
-               $sets = array_chunk( $this->points, floor( count( $this->points ) / 2 ) );
-
-               // Accumulate the first half into one RunningStat object
-               $first = new RunningStat();
-               foreach( $sets[0] as $point ) {
-                       $first->push( $point );
-               }
-
-               // Accumulate the second half into another RunningStat object
-               $second = new RunningStat();
-               foreach( $sets[1] as $point ) {
-                       $second->push( $point );
-               }
-
-               // Merge the second RunningStat object into the first
-               $first->merge( $second );
-
-               $this->assertEquals( count( $first ), count( $this->points ) );
-               $this->assertEquals( $first, $expected );
-       }
-}
index de5848d..b99ef86 100644 (file)
@@ -5,68 +5,66 @@
  */
 class MWMessagePackTest extends MediaWikiTestCase {
 
-       /* @var array Array of test cases, keyed by type. Each type is an array of
-        * (value, expected encoding as hex string). The expected values were
-        * generated using <https://github.com/onlinecity/msgpack-php>, which
-        * includes a serialization function.
+       /**
+        * Provides test cases for MWMessagePackTest::testMessagePack
+        *
+        * Returns an array of test cases. Each case is an array of (type, value,
+        * expected encoding as hex string). The expected values were generated
+        * using <https://github.com/msgpack/msgpack-php>, which includes a
+        * serialization function.
         */
-       public $data = array(
-               'integer' => array(
-                       array(  0, '00' ),
-                       array(  1, '01' ),
-                       array(  5, '05' ),
-                       array(  -1, 'ff' ),
-                       array(  -2, 'fe' ),
-                       array(  35, '23' ),
-                       array(  -35, 'd0dd' ),
-                       array(  128, 'cc80' ),
-                       array(  -128, 'd080' ),
-                       array(  1000, 'cd03e8' ),
-                       array(  -1000, 'd1fc18' ),
-                       array(  100000, 'ce000186a0' ),
-                       array(  -100000, 'd2fffe7960' ),
-                       array(  10000000000, 'cf00000002540be400' ),
-                       array(  -10000000000, 'd3fffffffdabf41c00' ),
-                       array(  -223372036854775807, 'd3fce66c50e2840001' ),
-                       array(  -9223372036854775807, 'd38000000000000001' ),
-               ),
-               'NULL' => array(
-                       array( null, 'c0' ),
-               ),
-               'boolean' => array(
-                       array( true, 'c3' ),
-                       array( false, 'c2' ),
-               ),
-               'double' => array(
-                       array(  0.1, 'cb3fb999999999999a' ),
-                       array(  1.1, 'cb3ff199999999999a' ),
-                       array(  123.456, 'cb405edd2f1a9fbe77' ),
-               ),
-               'string' => array(
-                       array(  '', 'a0' ),
-                       array( 'foobar', 'a6666f6f626172' ),
+       public function provider() {
+               return array(
+                       array( 'nil', null, 'c0' ),
+                       array( 'bool', true, 'c3' ),
+                       array( 'bool', false, 'c2' ),
+                       array( 'positive fixnum', 0, '00' ),
+                       array( 'positive fixnum', 1, '01' ),
+                       array( 'positive fixnum', 5, '05' ),
+                       array( 'positive fixnum', 35, '23' ),
+                       array( 'uint 8', 128, 'cc80' ),
+                       array( 'uint 16', 1000, 'cd03e8' ),
+                       array( 'uint 32', 100000, 'ce000186a0' ),
+                       array( 'uint 64', 10000000000, 'cf00000002540be400' ),
+                       array( 'negative fixnum', -1, 'ff' ),
+                       array( 'negative fixnum', -2, 'fe' ),
+                       array( 'int 8', -128, 'd080' ),
+                       array( 'int 8', -35, 'd0dd' ),
+                       array( 'int 16', -1000, 'd1fc18' ),
+                       array( 'int 32', -100000, 'd2fffe7960' ),
+                       array( 'int 64', -10000000000, 'd3fffffffdabf41c00' ),
+                       array( 'int 64', -223372036854775807, 'd3fce66c50e2840001' ),
+                       array( 'int 64', -9223372036854775807, 'd38000000000000001' ),
+                       array( 'double', 0.1, 'cb3fb999999999999a' ),
+                       array( 'double', 1.1, 'cb3ff199999999999a' ),
+                       array( 'double', 123.456, 'cb405edd2f1a9fbe77' ),
+                       array( 'fix raw', '', 'a0' ),
+                       array( 'fix raw', 'foobar', 'a6666f6f626172' ),
                        array(
+                               'raw 16',
                                'Lorem ipsum dolor sit amet amet.',
                                'da00204c6f72656d20697073756d20646f6c6f722073697420616d657420616d65742e'
                        ),
-               ),
-               'array' => array(
-                       array( array( 'abc', 'def', 'ghi' ), '93a3616263a3646566a3676869' ),
-                       array( array( 'one' => 1, 'two' => 2 ), '82a36f6e6501a374776f02' ),
-               ),
-       );
+                       array(
+                               'fix array',
+                               array( 'abc', 'def', 'ghi' ),
+                               '93a3616263a3646566a3676869'
+                       ),
+                       array(
+                               'fix map',
+                               array( 'one' => 1, 'two' => 2 ),
+                               '82a36f6e6501a374776f02'
+                       ),
+               );
+       }
 
        /**
         * Verify that values are serialized correctly.
         * @covers MWMessagePack::pack
+        * @dataProvider provider
         */
-       public function testMessagePack() {
-               foreach( $this->data as $type => $cases ) {
-                       foreach( $cases as $case ) {
-                               list( $value, $expected ) = $case;
-                               $actual = bin2hex( MWMessagePack::pack( $value ) );
-                               $this->assertEquals( $actual, $expected, $type );
-                       }
-               }
+       public function testPack( $type, $value, $expected ) {
+               $actual = bin2hex( MWMessagePack::pack( $value ) );
+               $this->assertEquals( $actual, $expected, $type );
        }
 }
diff --git a/tests/phpunit/includes/libs/RunningStatTest.php b/tests/phpunit/includes/libs/RunningStatTest.php
new file mode 100644 (file)
index 0000000..e24c088
--- /dev/null
@@ -0,0 +1,81 @@
+<?php
+/**
+ * PHP Unit tests for RunningStat class.
+ * @covers RunningStat
+ */
+class RunningStatTest extends MediaWikiTestCase {
+
+       public $points = array(
+               49.7168, 74.3804,  7.0115, 96.5769, 34.9458,
+               36.9947, 33.8926, 89.0774, 23.7745, 73.5154,
+               86.1322, 53.2124, 16.2046, 73.5130, 10.4209,
+               42.7299, 49.3330, 47.0215, 34.9950, 18.2914,
+       );
+
+       /**
+        * Verify that the statistical moments and extrema computed by RunningStat
+        * match expected values.
+        * @covers RunningStat::push
+        * @covers RunningStat::count
+        * @covers RunningStat::getMean
+        * @covers RunningStat::getVariance
+        * @covers RunningStat::getStdDev
+        */
+       public function testRunningStatAccuracy() {
+               $rstat = new RunningStat();
+               foreach( $this->points as $point ) {
+                       $rstat->push( $point );
+               }
+
+               $mean = array_sum( $this->points ) / count( $this->points );
+               $variance = array_sum( array_map( function ( $x ) use ( $mean ) {
+                       return pow( $mean - $x, 2 );
+               }, $this->points ) ) / ( count( $rstat ) - 1 );
+               $stddev = sqrt( $variance );
+               $min = min( $this->points );
+               $max = max( $this->points );
+
+               $this->assertEquals( count( $rstat ), count( $this->points ) );
+               $this->assertEquals( $rstat->min, min( $this->points ) );
+               $this->assertEquals( $rstat->max, max( $this->points ) );
+               $this->assertEquals( $rstat->getMean(), $mean );
+               $this->assertEquals( $rstat->getVariance(), $variance );
+               $this->assertEquals( $rstat->getStdDev(), $stddev );
+       }
+
+       /**
+        * When one RunningStat instance is merged into another, the state of the
+        * target RunningInstance should have the state that it would have had if
+        * all the data had been accumulated by it alone.
+        * @covers RunningStat::merge
+        * @covers RunningStat::count
+        */
+       public function testRunningStatMerge() {
+               $expected = new RunningStat();
+
+               foreach( $this->points as $point ) {
+                       $expected->push( $point );
+               }
+
+               // Split the data into two sets
+               $sets = array_chunk( $this->points, floor( count( $this->points ) / 2 ) );
+
+               // Accumulate the first half into one RunningStat object
+               $first = new RunningStat();
+               foreach( $sets[0] as $point ) {
+                       $first->push( $point );
+               }
+
+               // Accumulate the second half into another RunningStat object
+               $second = new RunningStat();
+               foreach( $sets[1] as $point ) {
+                       $second->push( $point );
+               }
+
+               // Merge the second RunningStat object into the first
+               $first->merge( $second );
+
+               $this->assertEquals( count( $first ), count( $this->points ) );
+               $this->assertEquals( $first, $expected );
+       }
+}
index 97a17ec..dbdb588 100644 (file)
@@ -79,13 +79,13 @@ class LanguageBe_taraskTest extends LanguageClassesTestCase {
         * @covers Language::convertPlural
         */
        public function testPluralTwoForms( $result, $value ) {
-               $forms = array( 'one', 'other', '0=one' );
+               $forms = array( '1=one', 'other' );
                $this->assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) );
        }
 
        public static function providePluralTwoForms() {
                return array(
-                       array( 'one', 0 ),
+                       array( 'other', 0 ),
                        array( 'one', 1 ),
                        array( 'other', 11 ),
                        array( 'other', 91 ),
index fb965b8..7aca2ab 100644 (file)
@@ -5,14 +5,14 @@
  * @file
  */
 
-/** Tests for MediaWiki languages/LanguageBs.php */
+/** Tests for Croatian (hrvatski) */
 class LanguageBsTest extends LanguageClassesTestCase {
        /**
         * @dataProvider providePlural
         * @covers Language::convertPlural
         */
        public function testPlural( $result, $value ) {
-               $forms = array( 'one', 'few', 'many', 'other' );
+               $forms = array( 'one', 'few', 'other' );
                $this->assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) );
        }
 
@@ -26,17 +26,17 @@ class LanguageBsTest extends LanguageClassesTestCase {
 
        public static function providePlural() {
                return array(
-                       array( 'many', 0 ),
+                       array( 'other', 0 ),
                        array( 'one', 1 ),
                        array( 'few', 2 ),
                        array( 'few', 4 ),
-                       array( 'many', 5 ),
-                       array( 'many', 11 ),
-                       array( 'many', 20 ),
+                       array( 'other', 5 ),
+                       array( 'other', 11 ),
+                       array( 'other', 20 ),
                        array( 'one', 21 ),
                        array( 'few', 24 ),
-                       array( 'many', 25 ),
-                       array( 'many', 200 ),
+                       array( 'other', 25 ),
+                       array( 'other', 200 ),
                );
        }
 }
index 6ce4aff..644c525 100644 (file)
@@ -12,7 +12,7 @@ class LanguageHrTest extends LanguageClassesTestCase {
         * @covers Language::convertPlural
         */
        public function testPlural( $result, $value ) {
-               $forms = array( 'one', 'few', 'many', 'other' );
+               $forms = array( 'one', 'few', 'other' );
                $this->assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) );
        }
 
@@ -26,17 +26,17 @@ class LanguageHrTest extends LanguageClassesTestCase {
 
        public static function providePlural() {
                return array(
-                       array( 'many', 0 ),
+                       array( 'other', 0 ),
                        array( 'one', 1 ),
                        array( 'few', 2 ),
                        array( 'few', 4 ),
-                       array( 'many', 5 ),
-                       array( 'many', 11 ),
-                       array( 'many', 20 ),
+                       array( 'other', 5 ),
+                       array( 'other', 11 ),
+                       array( 'other', 20 ),
                        array( 'one', 21 ),
                        array( 'few', 24 ),
-                       array( 'many', 25 ),
-                       array( 'many', 200 ),
+                       array( 'other', 25 ),
+                       array( 'other', 200 ),
                );
        }
 }
index 896522b..92e0ef9 100644 (file)
@@ -5,7 +5,7 @@
  * @file
  */
 
-/** Tests for MediaWiki languages/LanguageHy.php */
+/** Tests for Armenian (Հայերեն) */
 class LanguageHyTest extends LanguageClassesTestCase {
        /**
         * @dataProvider providePlural
@@ -21,13 +21,12 @@ class LanguageHyTest extends LanguageClassesTestCase {
         * @covers Language::getPluralRuleType
         */
        public function testGetPluralRuleType( $result, $value ) {
-               // This fails for 0, but I'm not sure why. Some voodoo going on here.
                $this->assertEquals( $result, $this->getLang()->getPluralRuleType( $value ) );
        }
 
        public static function providePlural() {
                return array(
-                       array( 'other', 0 ),
+                       array( 'one', 0 ),
                        array( 'one', 1 ),
                        array( 'other', 2 ),
                        array( 'other', 200 ),
index c4d8a6f..7120cfe 100644 (file)
@@ -5,7 +5,7 @@
  * @file
  */
 
-/** Tests for MediaWiki languages/classes/LanguageLv.php */
+/** Tests for Latvian */
 class LanguageLvTest extends LanguageClassesTestCase {
        /**
         * @dataProvider providePlural
@@ -28,13 +28,17 @@ class LanguageLvTest extends LanguageClassesTestCase {
                return array(
                        array( 'zero', 0 ),
                        array( 'one', 1 ),
-                       array( 'other', 11 ),
+                       array( 'zero', 11 ),
                        array( 'one', 21 ),
-                       array( 'other', 411 ),
+                       array( 'zero', 411 ),
+                       array( 'other', 2 ),
+                       array( 'other', 9 ),
+                       array( 'zero', 12 ),
                        array( 'other', 12.345 ),
-                       array( 'other', 20 ),
+                       array( 'zero', 20 ),
+                       array( 'other', 22 ),
                        array( 'one', 31 ),
-                       array( 'other', 200 ),
+                       array( 'zero', 200 ),
                );
        }
 }
index 7d47b37..ed15526 100644 (file)
@@ -5,7 +5,7 @@
  * @file
  */
 
-/** Tests for MediaWiki languages/classes/LanguageMk.php */
+/** Tests for македонски/Macedonian */
 class LanguageMkTest extends LanguageClassesTestCase {
        /**
         * @dataProvider providePlural
@@ -28,7 +28,7 @@ class LanguageMkTest extends LanguageClassesTestCase {
                return array(
                        array( 'other', 0 ),
                        array( 'one', 1 ),
-                       array( 'other', 11 ),
+                       array( 'one', 11 ),
                        array( 'one', 21 ),
                        array( 'one', 411 ),
                        array( 'other', 12.345 ),
index 56f8490..e17c708 100644 (file)
@@ -13,7 +13,7 @@ class LanguageRuTest extends LanguageClassesTestCase {
         * @covers Language::convertPlural
         */
        public function testPlural( $result, $value ) {
-               $forms = array( 'one', 'few', 'many', 'other' );
+               $forms = array( 'one', 'many', 'other' );
                $this->assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) );
        }
 
@@ -22,9 +22,9 @@ class LanguageRuTest extends LanguageClassesTestCase {
         * @covers Language::convertPlural
         */
        public function testExplicitPlural() {
-               $forms = array( 'one', 'few', 'many', 'other', '12=dozen' );
+               $forms = array( 'one','many', 'other', '12=dozen' );
                $this->assertEquals( 'dozen', $this->getLang()->convertPlural( 12, $forms ) );
-               $forms = array( 'one', 'few', 'many', '100=hundred', 'other', '12=dozen' );
+               $forms = array( 'one', 'many', '100=hundred', 'other', '12=dozen' );
                $this->assertEquals( 'hundred', $this->getLang()->convertPlural( 100, $forms ) );
        }
 
@@ -42,10 +42,10 @@ class LanguageRuTest extends LanguageClassesTestCase {
                        array( 'many', 11 ),
                        array( 'one', 91 ),
                        array( 'one', 121 ),
-                       array( 'few', 2 ),
-                       array( 'few', 3 ),
-                       array( 'few', 4 ),
-                       array( 'few', 334 ),
+                       array( 'other', 2 ),
+                       array( 'other', 3 ),
+                       array( 'other', 4 ),
+                       array( 'other', 334 ),
                        array( 'many', 5 ),
                        array( 'many', 15 ),
                        array( 'many', 120 ),
@@ -57,7 +57,7 @@ class LanguageRuTest extends LanguageClassesTestCase {
         * @covers Language::convertPlural
         */
        public function testPluralTwoForms( $result, $value ) {
-               $forms = array( 'one', 'other' );
+               $forms = array( '1=one', 'other' );
                $this->assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) );
        }
 
index bf6a14b..fa49a4d 100644 (file)
@@ -5,7 +5,7 @@
  * @file
  */
 
-/** Tests for MediaWiki languages/classes/LanguageSgs.php */
+/** Tests for Samogitian */
 class LanguageSgsTest extends LanguageClassesTestCase {
        /**
         * @dataProvider providePluralAllForms
index 6d2e25a..1b39087 100644 (file)
@@ -5,14 +5,14 @@
  * @file
  */
 
-/** Tests for MediaWiki languages/classes/LanguageSh.php */
+/** Tests for  srpskohrvatski / српскохрватски / Serbocroatian */
 class LanguageShTest extends LanguageClassesTestCase {
        /**
         * @dataProvider providePlural
         * @covers Language::convertPlural
         */
        public function testPlural( $result, $value ) {
-               $forms = array( 'one', 'few', 'many', 'other' );
+               $forms = array( 'one', 'few', 'other' );
                $this->assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) );
        }
 
@@ -26,17 +26,17 @@ class LanguageShTest extends LanguageClassesTestCase {
 
        public static function providePlural() {
                return array(
-                       array( 'many', 0 ),
+                       array( 'other', 0 ),
                        array( 'one', 1 ),
                        array( 'few', 2 ),
                        array( 'few', 4 ),
-                       array( 'many', 5 ),
-                       array( 'many', 10 ),
-                       array( 'many', 11 ),
-                       array( 'many', 12 ),
+                       array( 'other', 5 ),
+                       array( 'other', 10 ),
+                       array( 'other', 11 ),
+                       array( 'other', 12 ),
                        array( 'one', 101 ),
                        array( 'few', 102 ),
-                       array( 'many', 111 ),
+                       array( 'other', 111 ),
                );
        }
 }
index f551248..8d35f36 100644 (file)
@@ -130,7 +130,7 @@ class LanguageSrTest extends LanguageClassesTestCase {
         * @covers Language::convertPlural
         */
        public function testPlural( $result, $value ) {
-               $forms = array( 'one', 'few', 'many', 'other' );
+               $forms = array( 'one', 'few', 'other' );
                $this->assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) );
        }
 
@@ -145,16 +145,16 @@ class LanguageSrTest extends LanguageClassesTestCase {
        public static function providePlural() {
                return array(
                        array( 'one', 1 ),
-                       array( 'many', 11 ),
+                       array( 'other', 11 ),
                        array( 'one', 91 ),
                        array( 'one', 121 ),
                        array( 'few', 2 ),
                        array( 'few', 3 ),
                        array( 'few', 4 ),
                        array( 'few', 334 ),
-                       array( 'many', 5 ),
-                       array( 'many', 15 ),
-                       array( 'many', 120 ),
+                       array( 'other', 5 ),
+                       array( 'other', 15 ),
+                       array( 'other', 120 ),
                );
        }
 
@@ -171,8 +171,9 @@ class LanguageSrTest extends LanguageClassesTestCase {
                return array(
                        array( 'one', 1 ),
                        array( 'other', 11 ),
-                       array( 'other', 91 ),
-                       array( 'other', 121 ),
+                       array( 'other', 4 ),
+                       array( 'one', 91 ),
+                       array( 'one', 121 ),
                );
        }
 
index 1d81bc5..9051bcf 100644 (file)
@@ -6,7 +6,7 @@
  * @file
  */
 
-/** Tests for MediaWiki languages/classes/LanguageUk.php */
+/** Tests for Ukrainian */
 class LanguageUkTest extends LanguageClassesTestCase {
        /**
         * @dataProvider providePlural
@@ -57,7 +57,7 @@ class LanguageUkTest extends LanguageClassesTestCase {
         * @covers Language::convertPlural
         */
        public function testPluralTwoForms( $result, $value ) {
-               $forms = array( 'one', 'other' );
+               $forms = array( '1=one', 'other' );
                $this->assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) );
        }