Merge "(Bug 44987) Allow n=form in plural syntax"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Tue, 26 Feb 2013 15:27:31 +0000 (15:27 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Tue, 26 Feb 2013 15:27:31 +0000 (15:27 +0000)
languages/Language.php
tests/phpunit/languages/LanguageTest.php

index 9ae3d29..ef6a367 100644 (file)
@@ -3532,11 +3532,12 @@ class Language {
                        return '';
                }
 
-               // Handle explicit 0= and 1= forms
+               // Handle explicit n=pluralform cases
                foreach ( $forms as $index => $form ) {
-                       if ( isset( $form[1] ) && $form[1] === '=' ) {
-                               if ( $form[0] === (string) $count ) {
-                                       return substr( $form, 2 );
+                       if ( preg_match( '/\d+=/i', $form ) ) {
+                               $pos = strpos( $form, '=' );
+                               if ( substr( $form, 0, $pos ) === (string) $count ) {
+                                       return substr( $form, $pos + 1 );
                                }
                                unset( $forms[$index] );
                        }
index 3c9ca23..9de6722 100644 (file)
@@ -1227,6 +1227,9 @@ class LanguageTest extends LanguageClassesTestCase {
 
        function providePluralData() {
                return array(
+                       array( 'plural', 0, array(
+                               'singular', 'plural'
+                       ) ),
                        array( 'explicit zero', 0, array(
                                '0=explicit zero', 'singular', 'plural'
                        ) ),
@@ -1239,6 +1242,15 @@ class LanguageTest extends LanguageClassesTestCase {
                        array( 'plural', 3, array(
                                '0=explicit zero', '1=explicit one', 'singular', 'plural'
                        ) ),
+                       array( 'explicit elevan', 11, array(
+                               'singular', 'plural', '11=explicit elevan',
+                       ) ),
+                       array( 'plural', 12, array(
+                               'singular', 'plural', '11=explicit twelve',
+                       ) ),
+                       array( 'plural', 12, array(
+                               'singular', 'plural', '=explicit form',
+                       ) ),
                );
        }