forked from angular-translate/angular-translate
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(loaders): introduce loader cache
It useful if we disable cache for dynamic content, but want enable it for translation files (static content). Also it useful if we need include translation into build file (cache in advance for production). ```js app.run(function($translationCache) { $translationCache.put('/compiled/module1/locals/en.json', '{"MODULE1.HELLO":"Hi!"}'); // Other translations string added by Grunt }); ``` feat(cache): introduce customizable loader cache * `$translationCache` is fully flexible a string (name of an instance) or an instance itself * `$translationCache` could be `true` for an AJS internal default New feature usage: ```js $translateProvider.useLoaderCache(false) // disable any cache (default behaviour) $translateProvider.useLoaderCache(true) // use `$http({cache: true}) $translateProvider.useLoaderCache() // use our internal default `$translationCache` (actually `$translateProvider.useLoaderCache('$translationCache')` $translateProvider.useLoaderCache('cacheService') // use the given identifying cacheService $translateProvider.useLoaderCache(cacheService) // use the cacheService ``` This also introduces the feature loaders are provided with the option `$http` for additional standard params. Currently, only `$http.cache` could be defined. Closes angular-translate#529
- Loading branch information
Showing
8 changed files
with
154 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/** | ||
* @ngdoc service | ||
* @name $translationCache | ||
* @requires $cacheFactory | ||
* | ||
* @description | ||
* The first time a translation table is used, it is loaded in the translation cache for quick retrieval. You | ||
* can load translation tables directly into the cache by consuming the | ||
* `$translationCache` service directly. | ||
* | ||
* @return {object} $cacheFactory object. | ||
*/ | ||
angular.module('pascalprecht.translate').factory('$translationCache', ['$cacheFactory', function ($cacheFactory) { | ||
return $cacheFactory('translations'); | ||
}]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters