Move plural rules of Samogitian(sgs) to plurals-mediawiki.xml
authorSanthosh Thottingal <santhosh.thottingal@gmail.com>
Mon, 18 Mar 2013 08:11:46 +0000 (13:41 +0530)
committerSanthosh Thottingal <santhosh.thottingal@gmail.com>
Mon, 18 Mar 2013 08:11:46 +0000 (13:41 +0530)
* CLDR does not define plural rules for sgs.
* Port the plural rules present in LanguageSgs.php to CLDR plural
  definition syntax
* Remove LanguageSgs.php
* Update the tests, reorder/rename the plural form names

Change-Id: I44658402d69a6805cdfd189fe780eadee94056c7

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

diff --git a/languages/classes/LanguageSgs.php b/languages/classes/LanguageSgs.php
deleted file mode 100644 (file)
index 0c74e45..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-<?php
-/**
- * Samogitian (Žemaitėška) 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
- */
-
-/**
- * Samogitian (Žemaitėška)
- *
- * @ingroup Language
- */
-class LanguageSgs extends Language {
-
-       /**
-        * @param $count int
-        * @param $forms array
-        * @return string
-        */
-       function convertPlural( $count, $forms ) {
-               if ( !count( $forms ) ) { return ''; }
-               $forms = $this->preConvertPlural( $forms, 4 );
-
-               $count = abs( $count );
-               if ( $count == 0 || ( $count % 100 === 0 || ( $count % 100 >= 10 && $count % 100 < 20 ) ) ) {
-                       return $forms[2];
-               } elseif ( $count % 10 === 1 ) {
-                       return $forms[0];
-               } elseif ( $count % 10 === 2 ) {
-                       return $forms[1];
-               } else {
-                       return $forms[3];
-               }
-       }
-}
index 5c4f193..07e157a 100644 (file)
                <pluralRules locales="bho">
                        <pluralRule count="one">n in 0..1</pluralRule>
                </pluralRules>
+               <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>
+               </pluralRules>
        </plurals>
 </supplementalData>
index 8a6e979..95e6346 100644 (file)
@@ -10,25 +10,25 @@ class LanguageSgsTest extends LanguageClassesTestCase {
 
        /** @dataProvider providePluralAllForms */
        function testPluralAllForms( $result, $value ) {
-               $forms = array( 'one', 'few', 'many', 'other' );
+               $forms = array( 'one', 'two', 'few', 'other' );
                $this->assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) );
        }
 
        function providePluralAllForms() {
                return array(
-                       array( 'many', 0 ),
+                       array( 'few', 0 ),
                        array( 'one', 1 ),
-                       array( 'few', 2 ),
+                       array( 'two', 2 ),
                        array( 'other', 3 ),
-                       array( 'many', 10 ),
-                       array( 'many', 11 ),
-                       array( 'many', 12 ),
-                       array( 'many', 19 ),
+                       array( 'few', 10 ),
+                       array( 'few', 11 ),
+                       array( 'few', 12 ),
+                       array( 'few', 19 ),
                        array( 'other', 20 ),
-                       array( 'many', 100 ),
+                       array( 'few', 100 ),
                        array( 'one', 101 ),
-                       array( 'many', 111 ),
-                       array( 'many', 112 ),
+                       array( 'few', 111 ),
+                       array( 'few', 112 ),
                );
        }