Skip to content

Commit

Permalink
A bunch of fixes. Could also merge both URL lists...
Browse files Browse the repository at this point in the history
  • Loading branch information
Elad Efrat authored and Elad Efrat committed Sep 4, 2015
1 parent 6873a75 commit 418305b
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions angular-kencale.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,11 +160,9 @@ angular.module('angularKencale', [
isRTL: isRTL
};

return serviceAPI;

// Public API
function isRTL(localeId) {
localeId = localeId || $rootScope.localeId;
localeId = localeId || currentLocaleId;
return !!availableLocales[localeId].rtl;
};

Expand All @@ -188,6 +186,7 @@ angular.module('angularKencale', [
if (serviceAPI) {
serviceAPI.id = localeId;
}
onSetLocale && onSetLocale(localeId);
$rootScope.isRTL = isRTL(localeId);

return this;
Expand All @@ -196,6 +195,8 @@ angular.module('angularKencale', [
function onSetLocale(callback) {
setLocaleCallback = callback;
}

return serviceAPI;
}
}).
// Simplified copy of https://github.com/angular-translate/bower-angular-translate-loader-static-files
Expand Down Expand Up @@ -231,16 +232,14 @@ factory('kencaleLoader', function ($q, $http) {

// Append any template URLs.
if (options.templateUrls) {
for (var i = 0, _len = options.templateUrls.length; i < _len; i++) {
urls.push(options.templateUrls[i].replace('{localeId}', options.key));
}
urls = urls.concat(options.templateUrls);
}

var length = urls.length;

for (var i = 0; i < length; i++) {
promises.push(load(urls[i]));
}
urls.forEach(function (url) {
promises.push(load(url.replace('{localeId}', options.key)));
});

$q.all(promises).then(function (data) {
var length = data.length,
Expand All @@ -260,4 +259,4 @@ factory('kencaleLoader', function ($q, $http) {
return deferred.promise;
};
});
})();
})();

0 comments on commit 418305b

Please sign in to comment.