summaryrefslogtreecommitdiff
path: root/resources/src/mediawiki.language/mediawiki.cldr.js
blob: f6fb8f1079b958570df027fdcd6fefa6d7997f00 (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
30
31
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 ) );