summaryrefslogtreecommitdiff
path: root/resources/src/mediawiki.language/mediawiki.language.js
diff options
context:
space:
mode:
Diffstat (limited to 'resources/src/mediawiki.language/mediawiki.language.js')
-rw-r--r--resources/src/mediawiki.language/mediawiki.language.js41
1 files changed, 13 insertions, 28 deletions
diff --git a/resources/src/mediawiki.language/mediawiki.language.js b/resources/src/mediawiki.language/mediawiki.language.js
index d4f3c69e..78e39191 100644
--- a/resources/src/mediawiki.language/mediawiki.language.js
+++ b/resources/src/mediawiki.language/mediawiki.language.js
@@ -40,39 +40,18 @@ $.extend( mw.language, {
*
* @param {number} count Non-localized quantifier
* @param {Array} forms List of plural forms
+ * @param {Object} [explicitPluralForms] List of explicit plural forms
* @return {string} Correct form for quantifier in this language
*/
- convertPlural: function ( count, forms ) {
+ convertPlural: function ( count, forms, explicitPluralForms ) {
var pluralRules,
- formCount,
- form,
- index,
- equalsPosition,
pluralFormIndex = 0;
- if ( !forms || forms.length === 0 ) {
- return '';
- }
-
- // Handle for explicit n= forms
- for ( index = 0; index < forms.length; index++ ) {
- form = forms[index];
- if ( /^\d+=/.test( form ) ) {
- equalsPosition = form.indexOf( '=' );
- formCount = parseInt( form.slice( 0, equalsPosition ), 10 );
- if ( formCount === count ) {
- return form.slice( equalsPosition + 1 );
- }
- forms[index] = undefined;
- }
+ if ( explicitPluralForms && explicitPluralForms[count] ) {
+ return explicitPluralForms[count];
}
- // Remove explicit plural forms from the forms.
- forms = $.map( forms, function ( form ) {
- return form;
- } );
-
- if ( forms.length === 0 ) {
+ if ( !forms || forms.length === 0 ) {
return '';
}
@@ -107,7 +86,7 @@ $.extend( mw.language, {
* Usage in message text: `{{gender:[gender|user object]|masculine|feminine|neutral}}`.
* If second or third parameter are not specified, masculine is used.
*
- * These details may be overriden per language.
+ * These details may be overridden per language.
*
* @param {string} gender 'male', 'female', or anything else for neutral.
* @param {Array} forms List of gender forms
@@ -155,7 +134,9 @@ $.extend( mw.language, {
* @return {string}
*/
listToText: function ( list ) {
- var text = '', i = 0;
+ var text = '',
+ i = 0;
+
for ( ; i < list.length; i++ ) {
text += list[i];
if ( list.length - 2 === i ) {
@@ -165,6 +146,10 @@ $.extend( mw.language, {
}
}
return text;
+ },
+
+ setSpecialCharacters: function ( data ) {
+ this.specialCharacters = data;
}
} );