From: asulaiman Date: Fri, 2 Mar 2018 18:54:40 +0000 (-0500) Subject: [misc] Print console warning when setting non-existent locales (#4085) X-Git-Tag: 2.21.0~15 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=780e83025354d1dbcc74425458f180581b25a317;p=thirdparty%2Fmoment.git [misc] Print console warning when setting non-existent locales (#4085) * Dont silently fail setting new locale when it isnt available Right now if the new locale being set is not available then it fails silently and just uses the existing global locale. A console warning would be useful to notify the user of such a failure. * added missing semicolon * Added console warn check. * Fixed if condition. * Add space --- diff --git a/src/lib/locale/locales.js b/src/lib/locale/locales.js index 7d8fb26e0..131d87e4c 100644 --- a/src/lib/locale/locales.js +++ b/src/lib/locale/locales.js @@ -77,6 +77,12 @@ export function getSetGlobalLocale (key, values) { // moment.duration._locale = moment._locale = data; globalLocale = data; } + else { + if ((typeof console !== 'undefined') && console.warn) { + //warn user if arguments are passed but the locale could not be set + console.warn('Locale ' + key + ' not found. Did you forget to load it?'); + } + } } return globalLocale._abbr;