jenkins-bot has submitted this change and it was merged.
Change subject: (Bug 44987) Allow n=form in plural syntax
..
(Bug 44987) Allow n=form in plural syntax
phpunit testcases included
Change-Id: I7be51e24a0b953dcd1f9cb21f54af9b4127a5cdb
---
M languages/Language.php
M tests/phpunit/languages/LanguageTest.php
2 files changed, 17 insertions(+), 4 deletions(-)
Approvals:
Siebrand: Looks good to me, approved
jenkins-bot: Verified
diff --git a/languages/Language.php b/languages/Language.php
index ffb3268..7611e54 100644
--- a/languages/Language.php
+++ b/languages/Language.php
@@ -3520,11 +3520,12 @@
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] );
}
diff --git a/tests/phpunit/languages/LanguageTest.php
b/tests/phpunit/languages/LanguageTest.php
index 9507714..eba63dc 100644
--- a/tests/phpunit/languages/LanguageTest.php
+++ b/tests/phpunit/languages/LanguageTest.php
@@ -1227,6 +1227,9 @@
function providePluralData() {
return array(
+ array( 'plural', 0, array(
+ 'singular', 'plural'
+ ) ),
array( 'explicit zero', 0, array(
'0=explicit zero', 'singular', 'plural'
) ),
@@ -1239,6 +1242,15 @@
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',
+ ) ),
);
}
--
To view, visit https://gerrit.wikimedia.org/r/49011
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I7be51e24a0b953dcd1f9cb21f54af9b4127a5cdb
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Santhosh santhosh.thottin...@gmail.com
Gerrit-Reviewer: Amire80 amir.ahar...@mail.huji.ac.il
Gerrit-Reviewer: Nikerabbit niklas.laxst...@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