Skip to content
This repository has been archived by the owner on Jan 29, 2024. It is now read-only.

Commit

Permalink
feat(invalidate): added invalidate() method
Browse files Browse the repository at this point in the history
Added realization of the invalidate() method.
  • Loading branch information
DWand committed Aug 7, 2013
1 parent 76ec1b7 commit d41f91e
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/translate.js
Original file line number Diff line number Diff line change
Expand Up @@ -842,6 +842,30 @@ angular.module('pascalprecht.translate').provider('$translate', ['$STORAGE_KEY',
return storageKey();
};

$translate.invalidate = function(langKey) {
if (!langKey) {

for (var lang in $translationTable) {
delete $translationTable[lang];
}
if ($loaderFactory) {
if ($fallbackLanguage) loadAsync($fallbackLanguage);
if ($uses) $translate.uses($uses);
} else $rootScope.$broadcast('$translateChangeSuccess');

} else if ($translationTable.hasOwnProperty(langKey)) {

delete $translationTable[langKey];
if ($loaderFactory) {
if (langKey === $uses) $translate.uses($uses);
else loadAsync(langKey);
} else if (langKey === $uses) {
$rootScope.$broadcast('$translateChangeSuccess');
}

}
};

// If at least one async loader is defined and there are no (default) translations available
// we should try to load them.
if ($loaderFactory && angular.equals($translationTable, {})) {
Expand Down

0 comments on commit d41f91e

Please sign in to comment.