Correct the plural forms for Manx (Gaelg)
authorSanthosh Thottingal <santhosh.thottingal@gmail.com>
Wed, 11 Dec 2013 06:35:43 +0000 (12:05 +0530)
committerSanthosh Thottingal <santhosh.thottingal@gmail.com>
Wed, 11 Dec 2013 06:35:43 +0000 (12:05 +0530)
Backported the plural rules from CLDR 24 as an override to CLDR 23 rules
exising in MediaWiki. The syntax for plural rules changed in CLDR 24, so
modified the syntax to fit the CLDR 23 syntax

Once we are ready with the updated parsers for CLDR 24(See bug 56931),
we should remove the override.

Since we remove the custom plural forms in MW in favor of CLDR,
the following changes comes into effect:

1. 'few' form used as 'zero' form in MW. Practially that make 'one' form used
as 'two' form and 'two' used as 'few' form.
This breaks existing gv {{PURAL}} usage as dicussed in the bug report

2. CLDR defines 'few' form as n % 100 = 0,20,40,60 but MW adds 80 also to that
list, ie  n % 100 = 0,20,40,60, 80. So with this patch, 80 is no longer considered
as 'few' plural form.

Bug: 47099
Change-Id: I46ab3dadc7fe08c1e60bbd81a1ee841e166e9608

languages/classes/LanguageGv.php [deleted file]
languages/data/plurals-mediawiki.xml
tests/phpunit/languages/LanguageGvTest.php

diff --git a/languages/classes/LanguageGv.php b/languages/classes/LanguageGv.php
deleted file mode 100644 (file)
index 23a2916..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-<?php
-/**
- * Manx (Gaelg) 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
- * @author Niklas Laxström
- * @ingroup Language
- */
-
-/**
- * Manx (Gaelg)
- *
- * @ingroup Language
- */
-class LanguageGv 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, 4 );
-
-               if ( $count > 0 && ( $count % 20 ) === 0 ) {
-                       return $forms[0];
-               } else {
-                       switch ( $count % 10 ) {
-                               case 1: return $forms[1];
-                               case 2: return $forms[2];
-                               default: return $forms[3];
-                       }
-               }
-       }
-
-}
index 70d45a3..3314793 100644 (file)
                        <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>
                </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>
        </plurals>
 </supplementalData>
index a0def62..fc58022 100644 (file)
@@ -1,20 +1,19 @@
 <?php
 /**
+ * Test for Manx (Gaelg) language
+ *
  * @author Santhosh Thottingal
- * @copyright Copyright © 2012, Santhosh Thottingal
+ * @copyright Copyright © 2013, Santhosh Thottingal
  * @file
  */
 
-/** Tests for MediaWiki languages/classes/LanguageGv.php */
 class LanguageGvTest extends LanguageClassesTestCase {
        /**
         * @dataProvider providePlural
         * @covers Language::convertPlural
         */
        public function testPlural( $result, $value ) {
-               // This is not compatible with CLDR plural rules http://unicode.org/repos/cldr-tmp/trunk/diff/supplemental/language_plural_rules.html#gv
-               // What does this mean? Is there a hard-coded override for gv somewhere? -Ryan Kaldari 2013-01-28
-               $forms = array( 'Form 1', 'Form 2', 'Form 3', 'Form 4' );
+               $forms = array( 'one', 'two', 'few', 'other' );
                $this->assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) );
        }
 
@@ -23,21 +22,23 @@ class LanguageGvTest extends LanguageClassesTestCase {
         * @covers Language::getPluralRuleType
         */
        public function testGetPluralRuleType( $result, $value ) {
-               $this->markTestSkipped( "This test won't work since convertPlural for gv doesn't seem to actually follow our plural rules." );
                $this->assertEquals( $result, $this->getLang()->getPluralRuleType( $value ) );
        }
 
        public static function providePlural() {
                return array(
-                       array( 'Form 4', 0 ),
-                       array( 'Form 2', 1 ),
-                       array( 'Form 3', 2 ),
-                       array( 'Form 4', 3 ),
-                       array( 'Form 1', 20 ),
-                       array( 'Form 2', 21 ),
-                       array( 'Form 3', 22 ),
-                       array( 'Form 4', 23 ),
-                       array( 'Form 4', 50 ),
+                       array( 'few', 0 ),
+                       array( 'one', 1 ),
+                       array( 'two', 2 ),
+                       array( 'other', 3 ),
+                       array( 'few', 20 ),
+                       array( 'one', 21 ),
+                       array( 'two', 22 ),
+                       array( 'other', 23 ),
+                       array( 'other', 50 ),
+                       array( 'few', 60 ),
+                       array( 'other', 80 ),
+                       array( 'few', 100 )
                );
        }
 }