Merge "user: Allow "CAS update failed" exceptions to be normalised"
[lhc/web/wiklou.git] / resources / src / moment / moment-locale-overrides.js
1 /* global moment */
2
3 ( function () {
4 // HACK: Overwrite moment's i18n with MediaWiki's for the current language so that
5 // wgTranslateNumerals is respected.
6 moment.updateLocale( moment.locale(), {
7 preparse: function ( s ) {
8 var i,
9 table = mw.language.getDigitTransformTable();
10 if ( mw.config.get( 'wgTranslateNumerals' ) ) {
11 for ( i = 0; i < 10; i++ ) {
12 if ( table[ i ] !== undefined ) {
13 s = s.replace( new RegExp( mw.RegExp.escape( table[ i ] ), 'g' ), i );
14 }
15 }
16 }
17 // HACK: momentjs replaces commas in some languages, which is the only other use of preparse
18 // aside from digit transformation. We can only override preparse, not extend it, so we
19 // have to replicate the comma replacement functionality here.
20 if ( [ 'ar', 'ar-sa', 'fa' ].indexOf( mw.config.get( 'wgUserLanguage' ) ) !== -1 ) {
21 s = s.replace( /،/g, ',' );
22 }
23 return s;
24 },
25 postformat: function ( s ) {
26 var i,
27 table = mw.language.getDigitTransformTable();
28 if ( mw.config.get( 'wgTranslateNumerals' ) ) {
29 for ( i = 0; i < 10; i++ ) {
30 if ( table[ i ] !== undefined ) {
31 s = s.replace( new RegExp( i, 'g' ), table[ i ] );
32 }
33 }
34 }
35 // HACK: momentjs replaces commas in some languages, which is the only other use of postformat
36 // aside from digit transformation. We can only override postformat, not extend it, so we
37 // have to replicate the comma replacement functionality here.
38 if ( [ 'ar', 'ar-sa', 'fa' ].indexOf( mw.config.get( 'wgUserLanguage' ) ) !== -1 ) {
39 s = s.replace( /,/g, '،' );
40 }
41 return s;
42 }
43 } );
44 }() );