Skip to content

Commit

Permalink
Put back node hack for lazily loading locales
Browse files Browse the repository at this point in the history
  • Loading branch information
ichernev committed Mar 25, 2015
1 parent 3676152 commit 5fb4720
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions lib/locale/locales.js
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}

Expand Down

0 comments on commit 5fb4720

Please sign in to comment.