[MediaWiki-commits] [Gerrit] mediawiki/core[master]: Add closure around moment-locale-overrides.js
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/345643 ) Change subject: Add closure around moment-locale-overrides.js .. Add closure around moment-locale-overrides.js Change-Id: I262d53479ab7971323db12d345fc0cd343b1df5e --- M resources/src/moment-locale-overrides.js 1 file changed, 38 insertions(+), 36 deletions(-) Approvals: jenkins-bot: Verified Jforrester: Looks good to me, approved diff --git a/resources/src/moment-locale-overrides.js b/resources/src/moment-locale-overrides.js index 8aba831..bafb86a 100644 --- a/resources/src/moment-locale-overrides.js +++ b/resources/src/moment-locale-overrides.js @@ -1,42 +1,44 @@ -/* global moment, mw */ +/* global mediaWiki, moment */ -// HACK: Overwrite moment's i18n with MediaWiki's for the current language so that -// wgTranslateNumerals is respected. -moment.updateLocale( moment.locale(), { - preparse: function ( s ) { - var i, - table = mw.language.getDigitTransformTable(); - if ( mw.config.get( 'wgTranslateNumerals' ) ) { - for ( i = 0; i < 10; i++ ) { - if ( table[ i ] !== undefined ) { - s = s.replace( new RegExp( mw.RegExp.escape( table[ i ] ), 'g' ), i ); +( function ( mw ) { + // HACK: Overwrite moment's i18n with MediaWiki's for the current language so that + // wgTranslateNumerals is respected. + moment.updateLocale( moment.locale(), { + preparse: function ( s ) { + var i, + table = mw.language.getDigitTransformTable(); + if ( mw.config.get( 'wgTranslateNumerals' ) ) { + for ( i = 0; i < 10; i++ ) { + if ( table[ i ] !== undefined ) { + s = s.replace( new RegExp( mw.RegExp.escape( table[ i ] ), 'g' ), i ); + } } } - } - // HACK: momentjs replaces commas in some languages, which is the only other use of preparse - // aside from digit transformation. We can only override preparse, not extend it, so we - // have to replicate the comma replacement functionality here. - if ( [ 'ar', 'ar-sa', 'fa' ].indexOf( mw.config.get( 'wgUserLanguage' ) ) !== -1 ) { - s = s.replace( /،/g, ',' ); - } - return s; - }, - postformat: function ( s ) { - var i, - table = mw.language.getDigitTransformTable(); - if ( mw.config.get( 'wgTranslateNumerals' ) ) { - for ( i = 0; i < 10; i++ ) { - if ( table[ i ] !== undefined ) { - s = s.replace( new RegExp( i, 'g' ), table[ i ] ); + // HACK: momentjs replaces commas in some languages, which is the only other use of preparse + // aside from digit transformation. We can only override preparse, not extend it, so we + // have to replicate the comma replacement functionality here. + if ( [ 'ar', 'ar-sa', 'fa' ].indexOf( mw.config.get( 'wgUserLanguage' ) ) !== -1 ) { + s = s.replace( /،/g, ',' ); + } + return s; + }, + postformat: function ( s ) { + var i, + table = mw.language.getDigitTransformTable(); + if ( mw.config.get( 'wgTranslateNumerals' ) ) { + for ( i = 0; i < 10; i++ ) { + if ( table[ i ] !== undefined ) { + s = s.replace( new RegExp( i, 'g' ), table[ i ] ); + } } } + // HACK: momentjs replaces commas in some languages, which is the only other use of postformat + // aside from digit transformation. We can only override postformat, not extend it, so we + // have to replicate the comma replacement functionality here. + if ( [ 'ar', 'ar-sa', 'fa' ].indexOf( mw.config.get( 'wgUserLanguage' ) ) !== -1 ) { + s = s.replace( /,/g, '،' ); + } + return s; } - // HACK: momentjs replaces commas in some languages, which is the only other use of postformat - // aside from digit transformation. We can only override
[MediaWiki-commits] [Gerrit] mediawiki/core[master]: Add closure around moment-locale-overrides.js
Fomafix has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/345643 ) Change subject: Add closure around moment-locale-overrides.js .. Add closure around moment-locale-overrides.js Change-Id: I262d53479ab7971323db12d345fc0cd343b1df5e --- M resources/src/moment-locale-overrides.js 1 file changed, 38 insertions(+), 36 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/43/345643/1 diff --git a/resources/src/moment-locale-overrides.js b/resources/src/moment-locale-overrides.js index 8aba831..bafb86a 100644 --- a/resources/src/moment-locale-overrides.js +++ b/resources/src/moment-locale-overrides.js @@ -1,42 +1,44 @@ -/* global moment, mw */ +/* global mediaWiki, moment */ -// HACK: Overwrite moment's i18n with MediaWiki's for the current language so that -// wgTranslateNumerals is respected. -moment.updateLocale( moment.locale(), { - preparse: function ( s ) { - var i, - table = mw.language.getDigitTransformTable(); - if ( mw.config.get( 'wgTranslateNumerals' ) ) { - for ( i = 0; i < 10; i++ ) { - if ( table[ i ] !== undefined ) { - s = s.replace( new RegExp( mw.RegExp.escape( table[ i ] ), 'g' ), i ); +( function ( mw ) { + // HACK: Overwrite moment's i18n with MediaWiki's for the current language so that + // wgTranslateNumerals is respected. + moment.updateLocale( moment.locale(), { + preparse: function ( s ) { + var i, + table = mw.language.getDigitTransformTable(); + if ( mw.config.get( 'wgTranslateNumerals' ) ) { + for ( i = 0; i < 10; i++ ) { + if ( table[ i ] !== undefined ) { + s = s.replace( new RegExp( mw.RegExp.escape( table[ i ] ), 'g' ), i ); + } } } - } - // HACK: momentjs replaces commas in some languages, which is the only other use of preparse - // aside from digit transformation. We can only override preparse, not extend it, so we - // have to replicate the comma replacement functionality here. - if ( [ 'ar', 'ar-sa', 'fa' ].indexOf( mw.config.get( 'wgUserLanguage' ) ) !== -1 ) { - s = s.replace( /،/g, ',' ); - } - return s; - }, - postformat: function ( s ) { - var i, - table = mw.language.getDigitTransformTable(); - if ( mw.config.get( 'wgTranslateNumerals' ) ) { - for ( i = 0; i < 10; i++ ) { - if ( table[ i ] !== undefined ) { - s = s.replace( new RegExp( i, 'g' ), table[ i ] ); + // HACK: momentjs replaces commas in some languages, which is the only other use of preparse + // aside from digit transformation. We can only override preparse, not extend it, so we + // have to replicate the comma replacement functionality here. + if ( [ 'ar', 'ar-sa', 'fa' ].indexOf( mw.config.get( 'wgUserLanguage' ) ) !== -1 ) { + s = s.replace( /،/g, ',' ); + } + return s; + }, + postformat: function ( s ) { + var i, + table = mw.language.getDigitTransformTable(); + if ( mw.config.get( 'wgTranslateNumerals' ) ) { + for ( i = 0; i < 10; i++ ) { + if ( table[ i ] !== undefined ) { + s = s.replace( new RegExp( i, 'g' ), table[ i ] ); + } } } + // HACK: momentjs replaces commas in some languages, which is the only other use of postformat + // aside from digit transformation. We can only override postformat, not extend it, so we + // have to replicate the comma replacement functionality here. + if ( [ 'ar', 'ar-sa', 'fa' ].indexOf( mw.config.get( 'wgUserLanguage' ) ) !== -1 ) { + s = s.replace( /,/g, '،' ); + } + return s; } - // HACK: momentjs replaces commas in some languages, which is the only other use of postformat - // aside from digit transformation. We can only override