From 3e6cb8ac1aefc5158a757b8e1be1c1b39b695b39 Mon Sep 17 00:00:00 2001 From: Santhosh Thottingal Date: Wed, 11 Dec 2013 12:05:43 +0530 Subject: [PATCH] Correct the plural forms for Manx (Gaelg) 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 | 59 ---------------------- languages/data/plurals-mediawiki.xml | 6 +++ tests/phpunit/languages/LanguageGvTest.php | 31 ++++++------ 3 files changed, 22 insertions(+), 74 deletions(-) delete mode 100644 languages/classes/LanguageGv.php diff --git a/languages/classes/LanguageGv.php b/languages/classes/LanguageGv.php deleted file mode 100644 index 23a29162d2..0000000000 --- a/languages/classes/LanguageGv.php +++ /dev/null @@ -1,59 +0,0 @@ -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]; - } - } - } - -} diff --git a/languages/data/plurals-mediawiki.xml b/languages/data/plurals-mediawiki.xml index 70d45a3c1f..3314793038 100644 --- a/languages/data/plurals-mediawiki.xml +++ b/languages/data/plurals-mediawiki.xml @@ -39,5 +39,11 @@ n mod 10 is 2 and n mod 100 is not 12 n is 0 or n mod 100 is 0 or n mod 100 in 10..19 + + + n mod 10 is 1 + n mod 10 is 2 + n mod 100 in 0,20,40,60 + diff --git a/tests/phpunit/languages/LanguageGvTest.php b/tests/phpunit/languages/LanguageGvTest.php index a0def6289c..fc58022ad2 100644 --- a/tests/phpunit/languages/LanguageGvTest.php +++ b/tests/phpunit/languages/LanguageGvTest.php @@ -1,20 +1,19 @@ 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 ) ); } } -- 2.20.1