summaryrefslogtreecommitdiff
path: root/resources/src/mediawiki.language/mediawiki.language.months.js
blob: 5a1a5cb64ad556d676da896c10c9f66aceccdb10 (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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/*
 * Transfer of month names from messages into mw.language.
 *
 * Loading this module also ensures the availability of appropriate messages via mw.msg.
 */
( function ( mw, $ ) {
	var
		monthMessages = [
			'january', 'february', 'march', 'april',
			'may_long', 'june', 'july', 'august',
			'september', 'october', 'november', 'december'
		],
		monthGenMessages = [
			'january-gen', 'february-gen', 'march-gen', 'april-gen',
			'may-gen', 'june-gen', 'july-gen', 'august-gen',
			'september-gen', 'october-gen', 'november-gen', 'december-gen'
		],
		monthAbbrevMessages = [
			'jan', 'feb', 'mar', 'apr',
			'may', 'jun', 'jul', 'aug',
			'sep', 'oct', 'nov', 'dec'
		];

	// Function suitable for passing to jQuery.map
	// Can't use mw.msg directly because jQuery.map passes element index as second argument
	function mwMsgMapper( key ) {
		return mw.msg( key );
	}

	/**
	 * Information about month names in current UI language.
	 *
	 * Object keys:
	 *
	 * - `names`: array of month names (in nominative case in languages which have the distinction),
	 *   zero-indexed
	 * - `genitive`: array of month names in genitive case, zero-indexed
	 * - `abbrev`: array of three-letter-long abbreviated month names, zero-indexed
	 * - `keys`: object with three keys like the above, containing zero-indexed arrays of message keys
	 *   for appropriate messages which can be passed to mw.msg.
	 *
	 * @property
	 * @member mw.language
	 */
	mw.language.months = {
		keys: {
			names: monthMessages,
			genitive: monthGenMessages,
			abbrev: monthAbbrevMessages
		},
		names: $.map( monthMessages, mwMsgMapper ),
		genitive: $.map( monthGenMessages, mwMsgMapper ),
		abbrev: $.map( monthAbbrevMessages, mwMsgMapper )
	};

}( mediaWiki, jQuery ) );