Localisation updates from https://translatewiki.net.
[mediawiki.git] / resources / src / mediawiki.cldr / index.js
blobad3dcdbec232be3106aa3f812f026272817dc567
1 ( function () {
2         'use strict';
4         /**
5          * Namespace for CLDR-related utility methods.
6          * Provided by the `mediawiki.cdlr` ResourceLoader module.
7          *
8          * @namespace mw.cldr
9          * @singleton
10          */
11         mw.cldr = {
12                 /**
13                  * Get the plural form index for the number.
14                  *
15                  * In case none of the rules passed, we return `pluralRules.length` -
16                  * that means it is the "other" form.
17                  *
18                  * @param {number} number
19                  * @param {Array} pluralRules
20                  * @return {number} plural form index
21                  */
22                 getPluralForm: function ( number, pluralRules ) {
23                         const pluralRuleParser = require( 'mediawiki.libs.pluralruleparser' );
24                         let i;
25                         for ( i = 0; i < pluralRules.length; i++ ) {
26                                 if ( pluralRuleParser( pluralRules[ i ], number ) ) {
27                                         break;
28                                 }
29                         }
30                         return i;
31                 }
32         };
34 }() );