}
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];
}