From 780e83025354d1dbcc74425458f180581b25a317 Mon Sep 17 00:00:00 2001 From: asulaiman Date: Fri, 2 Mar 2018 13:54:40 -0500 Subject: [PATCH] [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 --- src/lib/locale/locales.js | 6 ++++++ 1 file changed, 6 insertions(+) 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; -- 2.47.2