]> git.ipfire.org Git - thirdparty/moment.git/commitdiff
Put back node hack for lazily loading locales
authorIskren Chernev <iskren.chernev@gmail.com>
Fri, 30 Jan 2015 06:51:10 +0000 (22:51 -0800)
committerIskren Chernev <iskren.chernev@gmail.com>
Wed, 25 Mar 2015 16:27:42 +0000 (09:27 -0700)
lib/locale/locales.js

index 12034457efa11254f7371b5bb531d2cf23104fe5..d085b271dcd2c663cba3742ea57137f597116746 100644 (file)
@@ -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];
 }