]> git.ipfire.org Git - thirdparty/moment.git/commitdiff
List loaded locales
authorJD Isaacks <jd@jisaacks.com>
Sun, 31 Jan 2016 21:34:25 +0000 (16:34 -0500)
committerIskren Chernev <iskren.chernev@gmail.com>
Sun, 6 Mar 2016 08:51:49 +0000 (00:51 -0800)
src/lib/locale/locale.js
src/lib/locale/locales.js
src/moment.js
src/test/moment/locale.js

index 9657a5b58eca2dd78795ffc7bd5d939394b0719f..ac9cebfb824997a5384048ca913fca24b32ee493 100644 (file)
@@ -5,7 +5,8 @@ import {
     getSetGlobalLocale,
     defineLocale,
     updateLocale,
-    getLocale
+    getLocale,
+    listLocales
 } from './locales';
 
 import {
@@ -21,6 +22,7 @@ export {
     defineLocale,
     updateLocale,
     getLocale,
+    listLocales,
     listMonths,
     listMonthsShort,
     listWeekdays,
index 64eebd3ea1d62f108f448bd23d5f6240528bd9e1..b2386064b7b75374c14ba582b2038bb3bc42c9c1 100644 (file)
@@ -157,3 +157,7 @@ export function getLocale (key) {
 
     return chooseLocale(key);
 }
+
+export function listLocales() {
+    return Object.keys(locales);
+}
index df9afa81f6a2949ee9e7b15ca7e3ca3a38dffdee..e4eed10139cad5494accfabf5c0df50826c1c31b 100644 (file)
@@ -26,6 +26,7 @@ import {
     updateLocale,
     getSetGlobalLocale as locale,
     getLocale          as localeData,
+    listLocales        as locales,
     listMonths         as months,
     listMonthsShort    as monthsShort,
     listWeekdays       as weekdays,
@@ -65,6 +66,7 @@ moment.monthsShort           = monthsShort;
 moment.weekdaysMin           = weekdaysMin;
 moment.defineLocale          = defineLocale;
 moment.updateLocale          = updateLocale;
+moment.locales               = locales;
 moment.weekdaysShort         = weekdaysShort;
 moment.normalizeUnits        = normalizeUnits;
 moment.relativeTimeThreshold = relativeTimeThreshold;
index ef8ccbcf1e5e9f6dea4e8a3c5f84ef078489778a..aee174749891b5e870ffb27d9f0717991eeebf5f 100644 (file)
@@ -152,6 +152,10 @@ test('defineLocale', function (assert) {
     assert.equal(moment().locale('dude').locale(), 'dude', 'defineLocale defines a locale');
 });
 
+test('locales', function (assert) {
+    assert.equal(moment.locales().length > 0, true, 'locales returns an array of defined locales');
+});
+
 test('library convenience', function (assert) {
     moment.locale('something', {week: {dow: 3}});
     moment.locale('something');