Better use of promise in OC.L10N.load()

This commit is contained in:
Vincent Petry 2014-11-19 14:49:15 +01:00
parent cd60a27ad6
commit 1c5933c96c
1 changed files with 8 additions and 13 deletions

View 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);
},
/**