/\d+=/ will match a12=abc. That is wrong. The plural form must
start with digits. Changing it to /^\d+=/
Also avoid Regex instance creation in mediawiki.language.js, use
literal regex.
Follow up: I82b9067 and I50eb0c6
Bug: 51284
Change-Id: I70ad3f99ad0a2600773c005d9e9cc8238e6e6d09
function convertPlural( $count, $forms ) {
// Handle explicit n=pluralform cases
foreach ( $forms as $index => $form ) {
- if ( preg_match( '/\d+=/i', $form ) ) {
+ if ( preg_match( '/^\d+=/i', $form ) ) {
$pos = strpos( $form, '=' );
if ( substr( $form, 0, $pos ) === (string) $count ) {
return substr( $form, $pos + 1 );
convertPlural: function ( count, forms ) {
var pluralRules,
formCount,
- explicitPluralPattern = new RegExp( '\\d+=', 'i' ),
form,
index,
equalsPosition,
// Handle for explicit n= forms
for ( index = 0; index < forms.length; index++ ) {
form = forms[index];
- if ( explicitPluralPattern.test( form ) ) {
+ if ( /^\d+=/.test( form ) ) {
equalsPosition = form.indexOf( '=' );
formCount = parseInt( form.substring( 0, equalsPosition ), 10 );
if ( formCount === count ) {