From: Iskren Chernev Date: Fri, 30 Jan 2015 06:51:10 +0000 (-0800) Subject: Put back node hack for lazily loading locales X-Git-Tag: 2.10.2~15^2~37 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5fb4720c05cd8a1f3f616d3467d687d95126f997;p=thirdparty%2Fmoment.git Put back node hack for lazily loading locales --- diff --git a/lib/locale/locales.js b/lib/locale/locales.js index 12034457e..d085b271d 100644 --- a/lib/locale/locales.js +++ b/lib/locale/locales.js @@ -38,16 +38,18 @@ function chooseLocale(names) { } function loadLocale(name) { - // var oldLocale = null; + var oldLocale = null; // TODO: Find a better way to register and load all the locales in Node - // if (!locales[name] && hasModule) { - // try { - // oldLocale = moment.locale(); - // require('./locale/' + name); - // // because defineLocale currently also sets the global locale, we want to undo that for lazy loaded locales - // moment.locale(oldLocale); - // } catch (e) { } - // } + if (!locales[name] && typeof module !== 'undefined' && + module && module.exports) { + try { + oldLocale = moment.locale(); + require('./locale/' + name); + // because defineLocale currently also sets the global locale, we + // want to undo that for lazy loaded locales + moment.locale(oldLocale); + } catch (e) { } + } return locales[name]; }