jenkins-bot has submitted this change and it was merged. Change subject: Update plural rules for Hebrew ......................................................................
Update plural rules for Hebrew A recent CLDR update changed the plural rules for Hebrew and added a "many" form. That rule has a mistake, however - it is not supposed to include the number 10. This is reported as http://unicode.org/cldr/trac/ticket/5828 This commit updates the plural overrides for Hebrew and makes them closer to the latest CLDR, but with a fix for that rule. It also updates the tests to include support for the new rule and to make sure that the right fallbacks are used when less than four rules are supplied, because usually that is the case. It is thus a partial revert of the changes introduced in I3d72e4105f6244b0695116940e62a2ddef66eb66 . Mingle-Task: 2715 Change-Id: I1315e6900ef7a89bf246e748b786f7fc31a629c6 --- M languages/data/plurals-mediawiki.xml M tests/phpunit/languages/LanguageHeTest.php 2 files changed, 63 insertions(+), 10 deletions(-) Approvals: Siebrand: Looks good to me, approved jenkins-bot: Verified diff --git a/languages/data/plurals-mediawiki.xml b/languages/data/plurals-mediawiki.xml index 5ad6717..70d45a3 100644 --- a/languages/data/plurals-mediawiki.xml +++ b/languages/data/plurals-mediawiki.xml @@ -2,10 +2,16 @@ <!DOCTYPE supplementalData SYSTEM "../../common/dtd/ldmlSupplemental.dtd"> <supplementalData> <plurals> - <!-- What is this override for Hebrew based on? Is there a CLDR ticket for this? -Ryan Kaldari 2013-01-28 --> + <!-- + 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> <pluralRules locales="dsb hsb"> <pluralRule count="one">n mod 100 is 1</pluralRule> diff --git a/tests/phpunit/languages/LanguageHeTest.php b/tests/phpunit/languages/LanguageHeTest.php index 3fbd51e..7849349 100644 --- a/tests/phpunit/languages/LanguageHeTest.php +++ b/tests/phpunit/languages/LanguageHeTest.php @@ -7,24 +7,71 @@ /** Tests for MediaWiki languages/classes/LanguageHe.php */ class LanguageHeTest extends LanguageClassesTestCase { - /** @dataProvider providePlural */ - function testPlural( $result, $value ) { + /* + The most common usage for the plural forms is two forms, + for singular and plural. In this case, the second form + is technically dual, but in practice it's used as plural. + In some cases, usually with expressions of time, three forms + are needed - singular, dual and plural. + CLDR also specifies a fourth form for multiples of 10, + which is very rare. It also has a mistake, because + the number 10 itself is supposed to be just plural, + so currently it's overridden in MediaWiki. + */ + + /** @dataProvider provideTwoPluralForms */ + function testTwoPluralForms( $result, $value ) { + $forms = array( 'one', 'other' ); + $this->assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) ); + } + + /** @dataProvider provideThreePluralForms */ + function testThreePluralForms( $result, $value ) { $forms = array( 'one', 'two', 'other' ); $this->assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) ); } - /** @dataProvider providePlural */ + /** @dataProvider provideFourPluralForms */ + function testFourPluralForms( $result, $value ) { + $forms = array( 'one', 'two', 'many', 'other' ); + $this->assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) ); + } + + /** @dataProvider provideFourPluralForms */ function testGetPluralRuleType( $result, $value ) { $this->assertEquals( $result, $this->getLang()->getPluralRuleType( $value ) ); } - public static function providePlural() { + public static function provideTwoPluralForms() { return array ( - array( 'other', 0 ), - array( 'one', 1 ), - array( 'two', 2 ), - array( 'other', 3 ), - array( 'other', 10 ), + array( 'other', 0 ), // Zero - plural + array( 'one', 1 ), // Singular + array( 'other', 2 ), // No third form provided, use it as plural + array( 'other', 3 ), // Plural - other + array( 'other', 10 ), // No fourth form provided, use it as plural + array( 'other', 20 ), // No fourth form provided, use it as plural + ); + } + + public static function provideThreePluralForms() { + return array ( + array( 'other', 0 ), // Zero - plural + array( 'one', 1 ), // Singular + array( 'two', 2 ), // Dual + array( 'other', 3 ), // Plural - other + array( 'other', 10 ), // No fourth form provided, use it as plural + array( 'other', 20 ), // No fourth form provided, use it as plural + ); + } + + public static function provideFourPluralForms() { + return array ( + array( 'other', 0 ), // Zero - plural + array( 'one', 1 ), // Singular + array( 'two', 2 ), // Dual + array( 'other', 3 ), // Plural - other + array( 'other', 10 ), // 10 is supposed to be plural (other), not "many" + array( 'many', 20 ), // Fourth form provided - rare, but supported by CLDR ); } -- To view, visit https://gerrit.wikimedia.org/r/55033 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I1315e6900ef7a89bf246e748b786f7fc31a629c6 Gerrit-PatchSet: 4 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Amire80 <amir.ahar...@mail.huji.ac.il> Gerrit-Reviewer: Amire80 <amir.ahar...@mail.huji.ac.il> Gerrit-Reviewer: Kaldari <rkald...@wikimedia.org> Gerrit-Reviewer: Nikerabbit <niklas.laxst...@gmail.com> Gerrit-Reviewer: Santhosh <santhosh.thottin...@gmail.com> Gerrit-Reviewer: Siebrand <siebr...@wikimedia.org> Gerrit-Reviewer: jenkins-bot _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits