diff options
Diffstat (limited to 'resources/src/mediawiki.language/mediawiki.cldr.js')
-rw-r--r-- | resources/src/mediawiki.language/mediawiki.cldr.js | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/resources/src/mediawiki.language/mediawiki.cldr.js b/resources/src/mediawiki.language/mediawiki.cldr.js new file mode 100644 index 00000000..f6fb8f10 --- /dev/null +++ b/resources/src/mediawiki.language/mediawiki.cldr.js @@ -0,0 +1,32 @@ +( function ( mw ) { + 'use strict'; + + /** + * Namespace for CLDR-related utility methods. + * + * @class + * @singleton + */ + mw.cldr = { + /** + * Get the plural form index for the number. + * + * In case none of the rules passed, we return `pluralRules.length` - + * that means it is the "other" form. + * + * @param {number} number + * @param {Array} pluralRules + * @return {number} plural form index + */ + getPluralForm: function ( number, pluralRules ) { + var i; + for ( i = 0; i < pluralRules.length; i++ ) { + if ( mw.libs.pluralRuleParser( pluralRules[i], number ) ) { + break; + } + } + return i; + } + }; + +}( mediaWiki ) ); |