if ( !count( $forms ) ) {
return '';
}
+
+ // Handle explicit 0= and 1= forms
+ foreach ( $forms as $index => $form ) {
+ if ( isset( $form[1] ) && $form[1] === '=' ) {
+ if ( $form[0] === (string) $count ) {
+ return substr( $form, 2 );
+ }
+ unset( $forms[$index] );
+ }
+ }
+ $forms = array_values( $forms );
+
$pluralForm = $this->getPluralForm( $count );
$pluralForm = min( $pluralForm, count( $forms ) - 1 );
return $forms[$pluralForm];
array( 10000, 'MMMMMMMMMM' ),
);
}
+
+ /**
+ * @dataProvider providePluralData
+ */
+ function testConvertPlural( $expected, $number, $forms ) {
+ $chosen = $this->lang->convertPlural( $number, $forms );
+ $this->assertEquals( $expected, $chosen );
+ }
+
+ function providePluralData() {
+ return array(
+ array( 'explicit zero', 0, array(
+ '0=explicit zero', 'singular', 'plural'
+ ) ),
+ array( 'explicit one', 1, array(
+ 'singular', 'plural', '1=explicit one',
+ ) ),
+ array( 'singular', 1, array(
+ 'singular', 'plural', '0=explicit zero',
+ ) ),
+ array( 'plural', 3, array(
+ '0=explicit zero', '1=explicit one', 'singular', 'plural'
+ ) ),
+ );
+ }
}