Don't override all Moment locales to English
authorBartosz Dziewoński <matma.rex@gmail.com>
Tue, 17 May 2016 02:51:25 +0000 (04:51 +0200)
committerBartosz Dziewoński <matma.rex@gmail.com>
Tue, 17 May 2016 02:55:17 +0000 (04:55 +0200)
Calling moment.locale() not only defines a locale, it also sets the
current one. The call at the top of moment-locale-overrides.js would
always set it to English.

Follow-up to c81ab8ae5f89056d23a4b0d36066120b9701d07e.

Bug: T135462
Change-Id: Ie1b70bc410ff0c436bed5bcbfffb8d4433a1923f

resources/Resources.php
resources/src/moment-dmy.js [new file with mode: 0644]
resources/src/moment-locale-overrides.js

index 3fc5801..9a5931f 100644 (file)
@@ -756,6 +756,7 @@ return [
                        'de' => 'resources/lib/moment/locale/de.js',
                        'de-at' => 'resources/lib/moment/locale/de-at.js',
                        'el' => 'resources/lib/moment/locale/el.js',
+                       'en' => 'resources/src/moment-dmy.js',
                        'en-au' => 'resources/lib/moment/locale/en-au.js',
                        'en-ca' => 'resources/lib/moment/locale/en-ca.js',
                        'en-gb' => 'resources/lib/moment/locale/en-gb.js',
diff --git a/resources/src/moment-dmy.js b/resources/src/moment-dmy.js
new file mode 100644 (file)
index 0000000..c67b93e
--- /dev/null
@@ -0,0 +1,16 @@
+// Use DMY date format for Moment.js, in accordance with MediaWiki's date formatting routines.
+// This affects English only (and languages without localisations, that fall back to English).
+// http://momentjs.com/docs/#/customization/long-date-formats/
+/*global moment */
+moment.locale( 'en', {
+       longDateFormat: {
+               // Unchanged, but have to be repeated here:
+               LT: 'h:mm A',
+               LTS: 'h:mm:ss A',
+               // Customized:
+               L: 'DD/MM/YYYY',
+               LL: 'D MMMM YYYY',
+               LLL: 'D MMMM YYYY LT',
+               LLLL: 'dddd, D MMMM YYYY LT'
+       }
+} );
index d49fcdc..9af0598 100644 (file)
@@ -1,19 +1,4 @@
-// Use DMY date format for Moment.js, in accordance with MediaWiki's date formatting routines.
-// This affects English only (and languages without localisations, that fall back to English).
-// http://momentjs.com/docs/#/customization/long-date-formats/
 /*global moment, mw */
-moment.locale( 'en', {
-       longDateFormat: {
-               // Unchanged, but have to be repeated here:
-               LT: 'h:mm A',
-               LTS: 'h:mm:ss A',
-               // Customized:
-               L: 'DD/MM/YYYY',
-               LL: 'D MMMM YYYY',
-               LLL: 'D MMMM YYYY LT',
-               LLLL: 'dddd, D MMMM YYYY LT'
-       }
-} );
 
 // HACK: Overwrite moment's i18n with MediaWiki's for the current language so that
 // wgTranslateNumerals is respected.