]> source.dussan.org Git - nextcloud-server.git/commitdiff
Better use of promise in OC.L10N.load()
authorVincent Petry <pvince81@owncloud.com>
Wed, 19 Nov 2014 13:49:15 +0000 (14:49 +0100)
committerVincent Petry <pvince81@owncloud.com>
Wed, 19 Nov 2014 13:49:15 +0000 (14:49 +0100)
core/js/l10n.js

index 2db4609ded247aa472a9fc143934bbefe982e29e..3e37da013693410be14c52bc709d4e6be8273193 100644 (file)
@@ -44,22 +44,17 @@ OC.L10N = {
                }
 
                var self = this;
-               var deferred = $.Deferred();
                var url = OC.filePath(appName, 'l10n', OC.getLocale() + '.json');
 
                // load JSON translation bundle per AJAX
-               $.get(url,
-                       function(result) {
-                               if (result.translations) {
-                                       self.register(appName, result.translations, result.pluralForm);
-                               }
-                               if (callback) {
-                                       callback();
-                                       deferred.resolve();
-                               }
-                       }
-               );
-               return deferred.promise();
+               return $.get(url)
+                       .then(
+                               function(result) {
+                                       if (result.translations) {
+                                               self.register(appName, result.translations, result.pluralForm);
+                                       }
+                               })
+                       .then(callback);
        },
 
        /**