summaryrefslogtreecommitdiff
path: root/resources/mediawiki.language/mediawiki.cldr.js
blob: c3023cd5a0a63192b7db5b918cd6f507b1599999 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/**
 *  CLDR related utility methods.
 */
( function ( mw ) {
	'use strict';

	var cldr = {
		/**
		 * For the number, get the plural for index
		 * In case none of the rules passed, we return pluralRules.length
		 * That means it is the "other" form.
		 * @param 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;
		}
	};

	mw.cldr = cldr;

}( mediaWiki ) );