angular-translate
Advanced tools
Comparing version 2.5.0 to 2.5.1
@@ -0,1 +1,10 @@ | ||
<a name="2.5.1"></a> | ||
### 2.5.1 (2014-12-10) | ||
#### Bug Fixes | ||
* **directive:** missing watch for expression within elements text nodes ([31c03560](http://github.com/angular-translate/angular-translate/commit/31c03560ddb537734303c41419b147262d511841), closes [#701](http://github.com/angular-translate/angular-translate/issues/701)) | ||
<a name="2.5.0"></a> | ||
@@ -8,3 +17,3 @@ ## 2.5.0 (2014-12-07) | ||
* **directive:** ensure directive's text will be parsed at least once ([49cfef0f](http://github.com/angular-translate/angular-translate/commit/49cfef0f58dd8c8306e6c0d4c6e78854ff2bbd8b)) | ||
* **loader:** under circum understances translation table got lost ([df373811](http://github.com/angular-translate/angular-translate/commit/df3738119677b6834b2d47455bf35161c9b0c588)) | ||
* **loader:** under certain circumstances translation table got lost ([df373811](http://github.com/angular-translate/angular-translate/commit/df3738119677b6834b2d47455bf35161c9b0c588)) | ||
* **messageformat-interpolation:** fix support for messageformat 0.2.* ([ac8d5ed1](http://github.com/angular-translate/angular-translate/commit/ac8d5ed1b43f3db7b269964383528b116ad26283)) | ||
@@ -11,0 +20,0 @@ * **service:** |
/*! | ||
* angular-translate - v2.5.0 - 2014-12-07 | ||
* angular-translate - v2.5.1 - 2014-12-10 | ||
* http://github.com/angular-translate/angular-translate | ||
* Copyright (c) 2014 ; Licensed MIT | ||
*/ | ||
angular.module('pascalprecht.translate').factory('$translateMissingTranslationHandlerLog', [ | ||
'$log', | ||
function ($log) { | ||
return function (translationId) { | ||
$log.warn('Translation for ' + translationId + ' doesn\'t exist'); | ||
}; | ||
} | ||
]); | ||
angular.module('pascalprecht.translate') | ||
/** | ||
* @ngdoc object | ||
* @name pascalprecht.translate.$translateMissingTranslationHandlerLog | ||
* @requires $log | ||
* | ||
* @description | ||
* Uses angular's `$log` service to give a warning when trying to translate a | ||
* translation id which doesn't exist. | ||
* | ||
* @returns {function} Handler function | ||
*/ | ||
.factory('$translateMissingTranslationHandlerLog', ['$log', function ($log) { | ||
return function (translationId) { | ||
$log.warn('Translation for ' + translationId + ' doesn\'t exist'); | ||
}; | ||
}]); |
/*! | ||
* angular-translate - v2.5.0 - 2014-12-07 | ||
* angular-translate - v2.5.1 - 2014-12-10 | ||
* http://github.com/angular-translate/angular-translate | ||
@@ -4,0 +4,0 @@ * Copyright (c) 2014 ; Licensed MIT |
/*! | ||
* angular-translate - v2.5.0 - 2014-12-07 | ||
* angular-translate - v2.5.1 - 2014-12-10 | ||
* http://github.com/angular-translate/angular-translate | ||
* Copyright (c) 2014 ; Licensed MIT | ||
*/ | ||
angular.module('pascalprecht.translate').constant('TRANSLATE_MF_INTERPOLATION_CACHE', '$translateMessageFormatInterpolation').factory('$translateMessageFormatInterpolation', [ | ||
'$cacheFactory', | ||
'TRANSLATE_MF_INTERPOLATION_CACHE', | ||
function ($cacheFactory, TRANSLATE_MF_INTERPOLATION_CACHE) { | ||
var $translateInterpolator = {}, $cache = $cacheFactory.get(TRANSLATE_MF_INTERPOLATION_CACHE), $mf = new MessageFormat('en'), $identifier = 'messageformat', $sanitizeValueStrategy = null, sanitizeValueStrategies = { | ||
angular.module('pascalprecht.translate') | ||
.constant('TRANSLATE_MF_INTERPOLATION_CACHE', '$translateMessageFormatInterpolation') | ||
/** | ||
* @ngdoc object | ||
* @name pascalprecht.translate.$translateMessageFormatInterpolation | ||
* @requires TRANSLATE_MF_INTERPOLATION_CACHE | ||
* | ||
* @description | ||
* Uses MessageFormat.js to interpolate strings against some values. | ||
* | ||
* @return {object} $translateInterpolator Interpolator service | ||
*/ | ||
.factory('$translateMessageFormatInterpolation', ['$cacheFactory', 'TRANSLATE_MF_INTERPOLATION_CACHE', function ($cacheFactory, TRANSLATE_MF_INTERPOLATION_CACHE) { | ||
var $translateInterpolator = {}, | ||
$cache = $cacheFactory.get(TRANSLATE_MF_INTERPOLATION_CACHE), | ||
// instantiate with default locale (which is 'en') | ||
$mf = new MessageFormat('en'), | ||
$identifier = 'messageformat', | ||
$sanitizeValueStrategy = null, | ||
// map of all sanitize strategies | ||
sanitizeValueStrategies = { | ||
escaped: function (params) { | ||
@@ -21,43 +40,86 @@ var result = {}; | ||
}; | ||
var sanitizeParams = function (params) { | ||
var result; | ||
if (angular.isFunction(sanitizeValueStrategies[$sanitizeValueStrategy])) { | ||
result = sanitizeValueStrategies[$sanitizeValueStrategy](params); | ||
} else { | ||
result = params; | ||
} | ||
return result; | ||
}; | ||
if (!$cache) { | ||
$cache = $cacheFactory(TRANSLATE_MF_INTERPOLATION_CACHE); | ||
var sanitizeParams = function (params) { | ||
var result; | ||
if (angular.isFunction(sanitizeValueStrategies[$sanitizeValueStrategy])) { | ||
result = sanitizeValueStrategies[$sanitizeValueStrategy](params); | ||
} else { | ||
result = params; | ||
} | ||
$cache.put('en', $mf); | ||
$translateInterpolator.setLocale = function (locale) { | ||
$mf = $cache.get(locale); | ||
if (!$mf) { | ||
$mf = new MessageFormat(locale); | ||
$cache.put(locale, $mf); | ||
} | ||
}; | ||
$translateInterpolator.getInterpolationIdentifier = function () { | ||
return $identifier; | ||
}; | ||
$translateInterpolator.useSanitizeValueStrategy = function (value) { | ||
$sanitizeValueStrategy = value; | ||
return this; | ||
}; | ||
$translateInterpolator.interpolate = function (string, interpolateParams) { | ||
interpolateParams = interpolateParams || {}; | ||
if ($sanitizeValueStrategy) { | ||
interpolateParams = sanitizeParams(interpolateParams); | ||
} | ||
var interpolatedText = $cache.get(string + angular.toJson(interpolateParams)); | ||
if (!interpolatedText) { | ||
interpolatedText = $mf.compile(string)(interpolateParams); | ||
$cache.put(string + angular.toJson(interpolateParams), interpolatedText); | ||
} | ||
return interpolatedText; | ||
}; | ||
return $translateInterpolator; | ||
return result; | ||
}; | ||
if (!$cache) { | ||
// create cache if it doesn't exist already | ||
$cache = $cacheFactory(TRANSLATE_MF_INTERPOLATION_CACHE); | ||
} | ||
]); | ||
$cache.put('en', $mf); | ||
/** | ||
* @ngdoc function | ||
* @name pascalprecht.translate.$translateMessageFormatInterpolation#setLocale | ||
* @methodOf pascalprecht.translate.$translateMessageFormatInterpolation | ||
* | ||
* @description | ||
* Sets current locale (this is currently not use in this interpolation). | ||
* | ||
* @param {string} locale Language key or locale. | ||
*/ | ||
$translateInterpolator.setLocale = function (locale) { | ||
$mf = $cache.get(locale); | ||
if (!$mf) { | ||
$mf = new MessageFormat(locale); | ||
$cache.put(locale, $mf); | ||
} | ||
}; | ||
/** | ||
* @ngdoc function | ||
* @name pascalprecht.translate.$translateMessageFormatInterpolation#getInterpolationIdentifier | ||
* @methodOf pascalprecht.translate.$translateMessageFormatInterpolation | ||
* | ||
* @description | ||
* Returns an identifier for this interpolation service. | ||
* | ||
* @returns {string} $identifier | ||
*/ | ||
$translateInterpolator.getInterpolationIdentifier = function () { | ||
return $identifier; | ||
}; | ||
$translateInterpolator.useSanitizeValueStrategy = function (value) { | ||
$sanitizeValueStrategy = value; | ||
return this; | ||
}; | ||
/** | ||
* @ngdoc function | ||
* @name pascalprecht.translate.$translateMessageFormatInterpolation#interpolate | ||
* @methodOf pascalprecht.translate.$translateMessageFormatInterpolation | ||
* | ||
* @description | ||
* Interpolates given string agains given interpolate params using MessageFormat.js. | ||
* | ||
* @returns {string} interpolated string. | ||
*/ | ||
$translateInterpolator.interpolate = function (string, interpolateParams) { | ||
interpolateParams = interpolateParams || {}; | ||
if ($sanitizeValueStrategy) { | ||
interpolateParams = sanitizeParams(interpolateParams); | ||
} | ||
var interpolatedText = $cache.get(string + angular.toJson(interpolateParams)); | ||
// if given string wasn't interpolated yet, we do so now and never have to do it again | ||
if (!interpolatedText) { | ||
interpolatedText = $mf.compile(string)(interpolateParams); | ||
$cache.put(string + angular.toJson(interpolateParams), interpolatedText); | ||
} | ||
return interpolatedText; | ||
}; | ||
return $translateInterpolator; | ||
}]); |
/*! | ||
* angular-translate - v2.5.0 - 2014-12-07 | ||
* angular-translate - v2.5.1 - 2014-12-10 | ||
* http://github.com/angular-translate/angular-translate | ||
@@ -4,0 +4,0 @@ * Copyright (c) 2014 ; Licensed MIT |
/*! | ||
* angular-translate - v2.5.0 - 2014-12-07 | ||
* angular-translate - v2.5.1 - 2014-12-10 | ||
* http://github.com/angular-translate/angular-translate | ||
* Copyright (c) 2014 ; Licensed MIT | ||
*/ | ||
angular.module('pascalprecht.translate').provider('$translatePartialLoader', function () { | ||
angular.module('pascalprecht.translate') | ||
/** | ||
* @ngdoc object | ||
* @name pascalprecht.translate.$translatePartialLoaderProvider | ||
* | ||
* @description | ||
* By using a $translatePartialLoaderProvider you can configure a list of a needed | ||
* translation parts directly during the configuration phase of your application's | ||
* lifetime. All parts you add by using this provider would be loaded by | ||
* angular-translate at the startup as soon as possible. | ||
*/ | ||
.provider('$translatePartialLoader', function() { | ||
/** | ||
* @constructor | ||
* @name Part | ||
* | ||
* @description | ||
* Represents Part object to add and set parts at runtime. | ||
*/ | ||
function Part(name) { | ||
@@ -12,21 +31,37 @@ this.name = name; | ||
} | ||
Part.prototype.parseUrl = function (urlTemplate, targetLang) { | ||
/** | ||
* @name parseUrl | ||
* @method | ||
* | ||
* @description | ||
* Returns a parsed url template string and replaces given target lang | ||
* and part name it. | ||
* | ||
* @param {string} urlTemplate Url pattern to use. | ||
* @param {string} targetLang Language key for language to be used. | ||
* @return {string} Parsed url template string | ||
*/ | ||
Part.prototype.parseUrl = function(urlTemplate, targetLang) { | ||
return urlTemplate.replace(/\{part\}/g, this.name).replace(/\{lang\}/g, targetLang); | ||
}; | ||
Part.prototype.getTable = function (lang, $q, $http, $httpOptions, urlTemplate, errorHandler) { | ||
Part.prototype.getTable = function(lang, $q, $http, $httpOptions, urlTemplate, errorHandler) { | ||
var deferred = $q.defer(); | ||
if (!this.tables[lang]) { | ||
var self = this; | ||
$http(angular.extend({ | ||
method: 'GET', | ||
method : 'GET', | ||
url: this.parseUrl(urlTemplate, lang) | ||
}, $httpOptions)).success(function (data) { | ||
}, $httpOptions)).success(function(data){ | ||
self.tables[lang] = data; | ||
deferred.resolve(data); | ||
}).error(function () { | ||
}).error(function() { | ||
if (errorHandler) { | ||
errorHandler(self.name, lang).then(function (data) { | ||
errorHandler(self.name, lang).then(function(data) { | ||
self.tables[lang] = data; | ||
deferred.resolve(data); | ||
}, function () { | ||
}, function() { | ||
deferred.reject(self.name); | ||
@@ -38,2 +73,3 @@ }); | ||
}); | ||
} else { | ||
@@ -44,9 +80,13 @@ deferred.resolve(this.tables[lang]); | ||
}; | ||
var parts = {}; | ||
function hasPart(name) { | ||
return Object.prototype.hasOwnProperty.call(parts, name); | ||
} | ||
function isStringValid(str) { | ||
return angular.isString(str) && str !== ''; | ||
} | ||
function isPartAvailable(name) { | ||
@@ -56,7 +96,10 @@ if (!isStringValid(name)) { | ||
} | ||
return hasPart(name) && parts[name].isActive; | ||
return (hasPart(name) && parts[name].isActive); | ||
} | ||
function deepExtend(dst, src) { | ||
for (var property in src) { | ||
if (src[property] && src[property].constructor && src[property].constructor === Object) { | ||
if (src[property] && src[property].constructor && | ||
src[property].constructor === Object) { | ||
dst[property] = dst[property] || {}; | ||
@@ -70,6 +113,25 @@ deepExtend(dst[property], src[property]); | ||
} | ||
this.addPart = function (name) { | ||
/** | ||
* @ngdoc function | ||
* @name pascalprecht.translate.$translatePartialLoaderProvider#addPart | ||
* @methodOf pascalprecht.translate.$translatePartialLoaderProvider | ||
* | ||
* @description | ||
* Registers a new part of the translation table to be loaded once the | ||
* `angular-translate` gets into runtime phase. It does not actually load any | ||
* translation data, but only registers a part to be loaded in the future. | ||
* | ||
* @param {string} name A name of the part to add | ||
* @returns {object} $translatePartialLoaderProvider, so this method is chainable | ||
* @throws {TypeError} The method could throw a **TypeError** if you pass the param | ||
* of the wrong type. Please, note that the `name` param has to be a | ||
* non-empty **string**. | ||
*/ | ||
this.addPart = function(name) { | ||
if (!isStringValid(name)) { | ||
throw new TypeError('Couldn\'t add part, part name has to be a string!'); | ||
} | ||
if (!hasPart(name)) { | ||
@@ -79,5 +141,25 @@ parts[name] = new Part(name); | ||
parts[name].isActive = true; | ||
return this; | ||
}; | ||
this.setPart = function (lang, part, table) { | ||
/** | ||
* @ngdocs function | ||
* @name pascalprecht.translate.$translatePartialLoaderProvider#setPart | ||
* @methodOf pascalprecht.translate.$translatePartialLoaderProvider | ||
* | ||
* @description | ||
* Sets a translation table to the specified part. This method does not make the | ||
* specified part available, but only avoids loading this part from the server. | ||
* | ||
* @param {string} lang A language of the given translation table | ||
* @param {string} part A name of the target part | ||
* @param {object} table A translation table to set to the specified part | ||
* | ||
* @return {object} $translatePartialLoaderProvider, so this method is chainable | ||
* @throws {TypeError} The method could throw a **TypeError** if you pass params | ||
* of the wrong type. Please, note that the `lang` and `part` params have to be a | ||
* non-empty **string**s and the `table` param has to be an object. | ||
*/ | ||
this.setPart = function(lang, part, table) { | ||
if (!isStringValid(lang)) { | ||
@@ -92,2 +174,3 @@ throw new TypeError('Couldn\'t set part.`lang` parameter has to be a string!'); | ||
} | ||
if (!hasPart(part)) { | ||
@@ -97,47 +180,126 @@ parts[part] = new Part(part); | ||
} | ||
parts[part].tables[lang] = table; | ||
return this; | ||
}; | ||
this.deletePart = function (name) { | ||
/** | ||
* @ngdoc function | ||
* @name pascalprecht.translate.$translatePartialLoaderProvider#deletePart | ||
* @methodOf pascalprecht.translate.$translatePartialLoaderProvider | ||
* | ||
* @description | ||
* Removes the previously added part of the translation data. So, `angular-translate` will not | ||
* load it at the startup. | ||
* | ||
* @param {string} name A name of the part to delete | ||
* | ||
* @returns {object} $translatePartialLoaderProvider, so this method is chainable | ||
* | ||
* @throws {TypeError} The method could throw a **TypeError** if you pass the param of the wrong | ||
* type. Please, note that the `name` param has to be a non-empty **string**. | ||
*/ | ||
this.deletePart = function(name) { | ||
if (!isStringValid(name)) { | ||
throw new TypeError('Couldn\'t delete part, first arg has to be string.'); | ||
} | ||
if (hasPart(name)) { | ||
parts[name].isActive = false; | ||
} | ||
return this; | ||
}; | ||
/** | ||
* @ngdoc function | ||
* @name pascalprecht.translate.$translatePartialLoaderProvider#isPartAvailable | ||
* @methodOf pascalprecht.translate.$translatePartialLoaderProvider | ||
* | ||
* @description | ||
* Checks if the specific part is available. A part becomes available after it was added by the | ||
* `addPart` method. Available parts would be loaded from the server once the `angular-translate` | ||
* asks the loader to that. | ||
* | ||
* @param {string} name A name of the part to check | ||
* | ||
* @returns {boolean} Returns **true** if the part is available now and **false** if not. | ||
* | ||
* @throws {TypeError} The method could throw a **TypeError** if you pass the param of the wrong | ||
* type. Please, note that the `name` param has to be a non-empty **string**. | ||
*/ | ||
this.isPartAvailable = isPartAvailable; | ||
this.$get = [ | ||
'$rootScope', | ||
'$injector', | ||
'$q', | ||
'$http', | ||
function ($rootScope, $injector, $q, $http) { | ||
var service = function (options) { | ||
if (!isStringValid(options.key)) { | ||
throw new TypeError('Unable to load data, a key is not a non-empty string.'); | ||
/** | ||
* @ngdoc object | ||
* @name pascalprecht.translate.$translatePartialLoader | ||
* | ||
* @requires $q | ||
* @requires $http | ||
* @requires $injector | ||
* @requires $rootScope | ||
* @requires $translate | ||
* | ||
* @description | ||
* | ||
* @param {object} options Options object | ||
* | ||
* @throws {TypeError} | ||
*/ | ||
this.$get = ['$rootScope', '$injector', '$q', '$http', | ||
function($rootScope, $injector, $q, $http) { | ||
/** | ||
* @ngdoc event | ||
* @name pascalprecht.translate.$translatePartialLoader#$translatePartialLoaderStructureChanged | ||
* @eventOf pascalprecht.translate.$translatePartialLoader | ||
* @eventType broadcast on root scope | ||
* | ||
* @description | ||
* A $translatePartialLoaderStructureChanged event is called when a state of the loader was | ||
* changed somehow. It could mean either some part is added or some part is deleted. Anyway when | ||
* you get this event the translation table is not longer current and has to be updated. | ||
* | ||
* @param {string} name A name of the part which is a reason why the event was fired | ||
*/ | ||
var service = function(options) { | ||
if (!isStringValid(options.key)) { | ||
throw new TypeError('Unable to load data, a key is not a non-empty string.'); | ||
} | ||
if (!isStringValid(options.urlTemplate)) { | ||
throw new TypeError('Unable to load data, a urlTemplate is not a non-empty string.'); | ||
} | ||
var errorHandler = options.loadFailureHandler; | ||
if (errorHandler !== undefined) { | ||
if (!angular.isString(errorHandler)) { | ||
throw new Error('Unable to load data, a loadFailureHandler is not a string.'); | ||
} else errorHandler = $injector.get(errorHandler); | ||
} | ||
var loaders = [], | ||
tables = [], | ||
deferred = $q.defer(); | ||
function addTablePart(table) { | ||
tables.push(table); | ||
} | ||
for (var part in parts) { | ||
if (hasPart(part) && parts[part].isActive) { | ||
loaders.push( | ||
parts[part] | ||
.getTable(options.key, $q, $http, options.$http, options.urlTemplate, errorHandler) | ||
.then(addTablePart) | ||
); | ||
parts[part].urlTemplate = options.urlTemplate; | ||
} | ||
if (!isStringValid(options.urlTemplate)) { | ||
throw new TypeError('Unable to load data, a urlTemplate is not a non-empty string.'); | ||
} | ||
var errorHandler = options.loadFailureHandler; | ||
if (errorHandler !== undefined) { | ||
if (!angular.isString(errorHandler)) { | ||
throw new Error('Unable to load data, a loadFailureHandler is not a string.'); | ||
} else | ||
errorHandler = $injector.get(errorHandler); | ||
} | ||
var loaders = [], tables = [], deferred = $q.defer(); | ||
function addTablePart(table) { | ||
tables.push(table); | ||
} | ||
for (var part in parts) { | ||
if (hasPart(part) && parts[part].isActive) { | ||
loaders.push(parts[part].getTable(options.key, $q, $http, options.$http, options.urlTemplate, errorHandler).then(addTablePart)); | ||
parts[part].urlTemplate = options.urlTemplate; | ||
} | ||
} | ||
if (loaders.length) { | ||
$q.all(loaders).then(function () { | ||
} | ||
if (loaders.length) { | ||
$q.all(loaders).then( | ||
function() { | ||
var table = {}; | ||
@@ -148,59 +310,144 @@ for (var i = 0; i < tables.length; i++) { | ||
deferred.resolve(table); | ||
}, function () { | ||
}, | ||
function() { | ||
deferred.reject(options.key); | ||
}); | ||
} | ||
); | ||
} else { | ||
deferred.resolve({}); | ||
} | ||
return deferred.promise; | ||
}; | ||
/** | ||
* @ngdoc function | ||
* @name pascalprecht.translate.$translatePartialLoader#addPart | ||
* @methodOf pascalprecht.translate.$translatePartialLoader | ||
* | ||
* @description | ||
* Registers a new part of the translation table. This method does actually not perform any xhr | ||
* requests to get a translation data. The new parts would be loaded from the server next time | ||
* `angular-translate` asks to loader to loaded translations. | ||
* | ||
* @param {string} name A name of the part to add | ||
* | ||
* @returns {object} $translatePartialLoader, so this method is chainable | ||
* | ||
* @fires {$translatePartialLoaderStructureChanged} The $translatePartialLoaderStructureChanged | ||
* event would be fired by this method in case the new part affected somehow on the loaders | ||
* state. This way it means that there are a new translation data available to be loaded from | ||
* the server. | ||
* | ||
* @throws {TypeError} The method could throw a **TypeError** if you pass the param of the wrong | ||
* type. Please, note that the `name` param has to be a non-empty **string**. | ||
*/ | ||
service.addPart = function(name) { | ||
if (!isStringValid(name)) { | ||
throw new TypeError('Couldn\'t add part, first arg has to be a string'); | ||
} | ||
if (!hasPart(name)) { | ||
parts[name] = new Part(name); | ||
$rootScope.$emit('$translatePartialLoaderStructureChanged', name); | ||
} else if (!parts[name].isActive) { | ||
parts[name].isActive = true; | ||
$rootScope.$emit('$translatePartialLoaderStructureChanged', name); | ||
} | ||
return service; | ||
}; | ||
/** | ||
* @ngdoc function | ||
* @name pascalprecht.translate.$translatePartialLoader#deletePart | ||
* @methodOf pascalprecht.translate.$translatePartialLoader | ||
* | ||
* @description | ||
* Deletes the previously added part of the translation data. The target part could be deleted | ||
* either logically or physically. When the data is deleted logically it is not actually deleted | ||
* from the browser, but the loader marks it as not active and prevents it from affecting on the | ||
* translations. If the deleted in such way part is added again, the loader will use the | ||
* previously loaded data rather than loading it from the server once more time. But if the data | ||
* is deleted physically, the loader will completely remove all information about it. So in case | ||
* of recycling this part will be loaded from the server again. | ||
* | ||
* @param {string} name A name of the part to delete | ||
* @param {boolean=} [removeData=false] An indicator if the loader has to remove a loaded | ||
* translation data physically. If the `removeData` if set to **false** the loaded data will not be | ||
* deleted physically and might be reused in the future to prevent an additional xhr requests. | ||
* | ||
* @returns {object} $translatePartialLoader, so this method is chainable | ||
* | ||
* @fires {$translatePartialLoaderStructureChanged} The $translatePartialLoaderStructureChanged | ||
* event would be fired by this method in case a part deletion process affects somehow on the | ||
* loaders state. This way it means that some part of the translation data is now deprecated and | ||
* the translation table has to be recompiled with the remaining translation parts. | ||
* | ||
* @throws {TypeError} The method could throw a **TypeError** if you pass some param of the | ||
* wrong type. Please, note that the `name` param has to be a non-empty **string** and | ||
* the `removeData` param has to be either **undefined** or **boolean**. | ||
*/ | ||
service.deletePart = function(name, removeData) { | ||
if (!isStringValid(name)) { | ||
throw new TypeError('Couldn\'t delete part, first arg has to be string'); | ||
} | ||
if (removeData === undefined) { | ||
removeData = false; | ||
} else if (typeof removeData !== 'boolean') { | ||
throw new TypeError('Invalid type of a second argument, a boolean expected.'); | ||
} | ||
if (hasPart(name)) { | ||
var wasActive = parts[name].isActive; | ||
if (removeData) { | ||
var $translate = $injector.get('$translate'); | ||
var cache = $translate.loaderCache(); | ||
if (typeof(cache) === 'string') { | ||
// getting on-demand instance of loader | ||
cache = $injector.get(cache); | ||
} | ||
// Purging items from cache... | ||
if (typeof(cache) === 'object') { | ||
angular.forEach(parts[name].tables, function(value, key) { | ||
cache.remove(parts[name].parseUrl(parts[name].urlTemplate, key)); | ||
}); | ||
} | ||
delete parts[name]; | ||
} else { | ||
deferred.resolve({}); | ||
parts[name].isActive = false; | ||
} | ||
return deferred.promise; | ||
}; | ||
service.addPart = function (name) { | ||
if (!isStringValid(name)) { | ||
throw new TypeError('Couldn\'t add part, first arg has to be a string'); | ||
} | ||
if (!hasPart(name)) { | ||
parts[name] = new Part(name); | ||
if (wasActive) { | ||
$rootScope.$emit('$translatePartialLoaderStructureChanged', name); | ||
} else if (!parts[name].isActive) { | ||
parts[name].isActive = true; | ||
$rootScope.$emit('$translatePartialLoaderStructureChanged', name); | ||
} | ||
return service; | ||
}; | ||
service.deletePart = function (name, removeData) { | ||
if (!isStringValid(name)) { | ||
throw new TypeError('Couldn\'t delete part, first arg has to be string'); | ||
} | ||
if (removeData === undefined) { | ||
removeData = false; | ||
} else if (typeof removeData !== 'boolean') { | ||
throw new TypeError('Invalid type of a second argument, a boolean expected.'); | ||
} | ||
if (hasPart(name)) { | ||
var wasActive = parts[name].isActive; | ||
if (removeData) { | ||
var $translate = $injector.get('$translate'); | ||
var cache = $translate.loaderCache(); | ||
if (typeof cache === 'string') { | ||
cache = $injector.get(cache); | ||
} | ||
if (typeof cache === 'object') { | ||
angular.forEach(parts[name].tables, function (value, key) { | ||
cache.remove(parts[name].parseUrl(parts[name].urlTemplate, key)); | ||
}); | ||
} | ||
delete parts[name]; | ||
} else { | ||
parts[name].isActive = false; | ||
} | ||
if (wasActive) { | ||
$rootScope.$emit('$translatePartialLoaderStructureChanged', name); | ||
} | ||
} | ||
return service; | ||
}; | ||
service.isPartAvailable = isPartAvailable; | ||
} | ||
return service; | ||
} | ||
]; | ||
}); | ||
}; | ||
/** | ||
* @ngdoc function | ||
* @name pascalprecht.translate.$translatePartialLoader#isPartAvailable | ||
* @methodOf pascalprecht.translate.$translatePartialLoader | ||
* | ||
* @description | ||
* Checks if a target translation part is available. The part becomes available just after it was | ||
* added by the `addPart` method. Part's availability does not mean that it was loaded from the | ||
* server, but only that it was added to the loader. The available part might be loaded next | ||
* time the loader is called. | ||
* | ||
* @param {string} name A name of the part to delete | ||
* | ||
* @returns {boolean} Returns **true** if the part is available now and **false** if not. | ||
* | ||
* @throws {TypeError} The method could throw a **TypeError** if you pass the param of the wrong | ||
* type. Please, note that the `name` param has to be a non-empty **string**. | ||
*/ | ||
service.isPartAvailable = isPartAvailable; | ||
return service; | ||
}]; | ||
}); |
/*! | ||
* angular-translate - v2.5.0 - 2014-12-07 | ||
* angular-translate - v2.5.1 - 2014-12-10 | ||
* http://github.com/angular-translate/angular-translate | ||
@@ -4,0 +4,0 @@ * Copyright (c) 2014 ; Licensed MIT |
/*! | ||
* angular-translate - v2.5.0 - 2014-12-07 | ||
* angular-translate - v2.5.1 - 2014-12-10 | ||
* http://github.com/angular-translate/angular-translate | ||
* Copyright (c) 2014 ; Licensed MIT | ||
*/ | ||
angular.module('pascalprecht.translate').factory('$translateStaticFilesLoader', [ | ||
'$q', | ||
'$http', | ||
function ($q, $http) { | ||
return function (options) { | ||
if (!options || (!angular.isString(options.prefix) || !angular.isString(options.suffix))) { | ||
throw new Error('Couldn\'t load static files, no prefix or suffix specified!'); | ||
} | ||
var deferred = $q.defer(); | ||
$http(angular.extend({ | ||
url: [ | ||
options.prefix, | ||
options.key, | ||
options.suffix | ||
].join(''), | ||
method: 'GET', | ||
params: '' | ||
}, options.$http)).success(function (data) { | ||
deferred.resolve(data); | ||
}).error(function (data) { | ||
deferred.reject(options.key); | ||
}); | ||
return deferred.promise; | ||
}; | ||
} | ||
]); | ||
angular.module('pascalprecht.translate') | ||
/** | ||
* @ngdoc object | ||
* @name pascalprecht.translate.$translateStaticFilesLoader | ||
* @requires $q | ||
* @requires $http | ||
* | ||
* @description | ||
* Creates a loading function for a typical static file url pattern: | ||
* "lang-en_US.json", "lang-de_DE.json", etc. Using this builder, | ||
* the response of these urls must be an object of key-value pairs. | ||
* | ||
* @param {object} options Options object, which gets prefix, suffix and key. | ||
*/ | ||
.factory('$translateStaticFilesLoader', ['$q', '$http', function ($q, $http) { | ||
return function (options) { | ||
if (!options || (!angular.isString(options.prefix) || !angular.isString(options.suffix))) { | ||
throw new Error('Couldn\'t load static files, no prefix or suffix specified!'); | ||
} | ||
var deferred = $q.defer(); | ||
$http(angular.extend({ | ||
url: [ | ||
options.prefix, | ||
options.key, | ||
options.suffix | ||
].join(''), | ||
method: 'GET', | ||
params: '' | ||
}, options.$http)).success(function (data) { | ||
deferred.resolve(data); | ||
}).error(function (data) { | ||
deferred.reject(options.key); | ||
}); | ||
return deferred.promise; | ||
}; | ||
}]); |
/*! | ||
* angular-translate - v2.5.0 - 2014-12-07 | ||
* angular-translate - v2.5.1 - 2014-12-10 | ||
* http://github.com/angular-translate/angular-translate | ||
@@ -4,0 +4,0 @@ * Copyright (c) 2014 ; Licensed MIT |
/*! | ||
* angular-translate - v2.5.0 - 2014-12-07 | ||
* angular-translate - v2.5.1 - 2014-12-10 | ||
* http://github.com/angular-translate/angular-translate | ||
* Copyright (c) 2014 ; Licensed MIT | ||
*/ | ||
angular.module('pascalprecht.translate').factory('$translateUrlLoader', [ | ||
'$q', | ||
'$http', | ||
function ($q, $http) { | ||
return function (options) { | ||
if (!options || !options.url) { | ||
throw new Error('Couldn\'t use urlLoader since no url is given!'); | ||
} | ||
var deferred = $q.defer(), requestParams = {}; | ||
requestParams[options.queryParameter || 'lang'] = options.key; | ||
$http(angular.extend({ | ||
url: options.url, | ||
params: requestParams, | ||
method: 'GET' | ||
}, options.$http)).success(function (data) { | ||
deferred.resolve(data); | ||
}).error(function (data) { | ||
deferred.reject(options.key); | ||
}); | ||
return deferred.promise; | ||
}; | ||
} | ||
]); | ||
angular.module('pascalprecht.translate') | ||
/** | ||
* @ngdoc object | ||
* @name pascalprecht.translate.$translateUrlLoader | ||
* @requires $q | ||
* @requires $http | ||
* | ||
* @description | ||
* Creates a loading function for a typical dynamic url pattern: | ||
* "locale.php?lang=en_US", "locale.php?lang=de_DE", "locale.php?language=nl_NL" etc. | ||
* Prefixing the specified url, the current requested, language id will be applied | ||
* with "?{queryParameter}={key}". | ||
* Using this service, the response of these urls must be an object of | ||
* key-value pairs. | ||
* | ||
* @param {object} options Options object, which gets the url, key and | ||
* optional queryParameter ('lang' is used by default). | ||
*/ | ||
.factory('$translateUrlLoader', ['$q', '$http', function ($q, $http) { | ||
return function (options) { | ||
if (!options || !options.url) { | ||
throw new Error('Couldn\'t use urlLoader since no url is given!'); | ||
} | ||
var deferred = $q.defer(), | ||
requestParams = {}; | ||
requestParams[options.queryParameter || 'lang'] = options.key; | ||
$http(angular.extend({ | ||
url: options.url, | ||
params: requestParams, | ||
method: 'GET' | ||
}, options.$http)).success(function (data) { | ||
deferred.resolve(data); | ||
}).error(function (data) { | ||
deferred.reject(options.key); | ||
}); | ||
return deferred.promise; | ||
}; | ||
}]); |
/*! | ||
* angular-translate - v2.5.0 - 2014-12-07 | ||
* angular-translate - v2.5.1 - 2014-12-10 | ||
* http://github.com/angular-translate/angular-translate | ||
@@ -4,0 +4,0 @@ * Copyright (c) 2014 ; Licensed MIT |
/*! | ||
* angular-translate - v2.5.0 - 2014-12-07 | ||
* angular-translate - v2.5.1 - 2014-12-10 | ||
* http://github.com/angular-translate/angular-translate | ||
* Copyright (c) 2014 ; Licensed MIT | ||
*/ | ||
angular.module('pascalprecht.translate').factory('$translateCookieStorage', [ | ||
'$cookieStore', | ||
function ($cookieStore) { | ||
var $translateCookieStorage = { | ||
get: function (name) { | ||
return $cookieStore.get(name); | ||
}, | ||
set: function (name, value) { | ||
$cookieStore.put(name, value); | ||
}, | ||
put: function (name, value) { | ||
$cookieStore.put(name, value); | ||
} | ||
}; | ||
return $translateCookieStorage; | ||
} | ||
]); | ||
angular.module('pascalprecht.translate') | ||
/** | ||
* @ngdoc object | ||
* @name pascalprecht.translate.$translateCookieStorage | ||
* @requires $cookieStore | ||
* | ||
* @description | ||
* Abstraction layer for cookieStore. This service is used when telling angular-translate | ||
* to use cookieStore as storage. | ||
* | ||
*/ | ||
.factory('$translateCookieStorage', ['$cookieStore', function ($cookieStore) { | ||
var $translateCookieStorage = { | ||
/** | ||
* @ngdoc function | ||
* @name pascalprecht.translate.$translateCookieStorage#get | ||
* @methodOf pascalprecht.translate.$translateCookieStorage | ||
* | ||
* @description | ||
* Returns an item from cookieStorage by given name. | ||
* | ||
* @param {string} name Item name | ||
* @return {string} Value of item name | ||
*/ | ||
get: function (name) { | ||
return $cookieStore.get(name); | ||
}, | ||
/** | ||
* @ngdoc function | ||
* @name pascalprecht.translate.$translateCookieStorage#set | ||
* @methodOf pascalprecht.translate.$translateCookieStorage | ||
* | ||
* @description | ||
* Sets an item in cookieStorage by given name. | ||
* | ||
* @deprecated use #put | ||
* | ||
* @param {string} name Item name | ||
* @param {string} value Item value | ||
*/ | ||
set: function (name, value) { | ||
$cookieStore.put(name, value); | ||
}, | ||
/** | ||
* @ngdoc function | ||
* @name pascalprecht.translate.$translateCookieStorage#put | ||
* @methodOf pascalprecht.translate.$translateCookieStorage | ||
* | ||
* @description | ||
* Sets an item in cookieStorage by given name. | ||
* | ||
* @param {string} name Item name | ||
* @param {string} value Item value | ||
*/ | ||
put: function (name, value) { | ||
$cookieStore.put(name, value); | ||
} | ||
}; | ||
return $translateCookieStorage; | ||
}]); |
/*! | ||
* angular-translate - v2.5.0 - 2014-12-07 | ||
* angular-translate - v2.5.1 - 2014-12-10 | ||
* http://github.com/angular-translate/angular-translate | ||
@@ -4,0 +4,0 @@ * Copyright (c) 2014 ; Licensed MIT |
/*! | ||
* angular-translate - v2.5.0 - 2014-12-07 | ||
* angular-translate - v2.5.1 - 2014-12-10 | ||
* http://github.com/angular-translate/angular-translate | ||
* Copyright (c) 2014 ; Licensed MIT | ||
*/ | ||
angular.module('pascalprecht.translate').factory('$translateLocalStorage', [ | ||
'$window', | ||
'$translateCookieStorage', | ||
function ($window, $translateCookieStorage) { | ||
var localStorageAdapter = function () { | ||
var langKey; | ||
return { | ||
get: function (name) { | ||
if (!langKey) { | ||
langKey = $window.localStorage.getItem(name); | ||
} | ||
return langKey; | ||
}, | ||
set: function (name, value) { | ||
langKey = value; | ||
$window.localStorage.setItem(name, value); | ||
}, | ||
put: function (name, value) { | ||
langKey = value; | ||
$window.localStorage.setItem(name, value); | ||
} | ||
}; | ||
}(); | ||
var hasLocalStorageSupport = 'localStorage' in $window; | ||
if (hasLocalStorageSupport) { | ||
var testKey = 'pascalprecht.translate.storageTest'; | ||
try { | ||
if ($window.localStorage !== null) { | ||
$window.localStorage.setItem(testKey, 'foo'); | ||
$window.localStorage.removeItem(testKey); | ||
hasLocalStorageSupport = true; | ||
} else { | ||
hasLocalStorageSupport = false; | ||
angular.module('pascalprecht.translate') | ||
/** | ||
* @ngdoc object | ||
* @name pascalprecht.translate.$translateLocalStorage | ||
* @requires $window | ||
* | ||
* @description | ||
* Abstraction layer for localStorage. This service is used when telling angular-translate | ||
* to use localStorage as storage. | ||
* | ||
*/ | ||
.factory('$translateLocalStorage', ['$window', '$translateCookieStorage', function ($window, $translateCookieStorage) { | ||
// Setup adapter | ||
var localStorageAdapter = (function(){ | ||
var langKey; | ||
return { | ||
/** | ||
* @ngdoc function | ||
* @name pascalprecht.translate.$translateLocalStorage#get | ||
* @methodOf pascalprecht.translate.$translateLocalStorage | ||
* | ||
* @description | ||
* Returns an item from localStorage by given name. | ||
* | ||
* @param {string} name Item name | ||
* @return {string} Value of item name | ||
*/ | ||
get: function (name) { | ||
if(!langKey) { | ||
langKey = $window.localStorage.getItem(name); | ||
} | ||
} catch (e) { | ||
return langKey; | ||
}, | ||
/** | ||
* @ngdoc function | ||
* @name pascalprecht.translate.$translateLocalStorage#set | ||
* @methodOf pascalprecht.translate.$translateLocalStorage | ||
* | ||
* @description | ||
* Sets an item in localStorage by given name. | ||
* | ||
* @deprecated use #put | ||
* | ||
* @param {string} name Item name | ||
* @param {string} value Item value | ||
*/ | ||
set: function (name, value) { | ||
langKey=value; | ||
$window.localStorage.setItem(name, value); | ||
}, | ||
/** | ||
* @ngdoc function | ||
* @name pascalprecht.translate.$translateLocalStorage#put | ||
* @methodOf pascalprecht.translate.$translateLocalStorage | ||
* | ||
* @description | ||
* Sets an item in localStorage by given name. | ||
* | ||
* @param {string} name Item name | ||
* @param {string} value Item value | ||
*/ | ||
put: function (name, value) { | ||
langKey=value; | ||
$window.localStorage.setItem(name, value); | ||
} | ||
}; | ||
}()); | ||
var hasLocalStorageSupport = 'localStorage' in $window; | ||
if (hasLocalStorageSupport) { | ||
var testKey = 'pascalprecht.translate.storageTest'; | ||
try { | ||
// this check have to be wrapped within a try/catch because on | ||
// a SecurityError: Dom Exception 18 on iOS | ||
if ($window.localStorage !== null) { | ||
$window.localStorage.setItem(testKey, 'foo'); | ||
$window.localStorage.removeItem(testKey); | ||
hasLocalStorageSupport = true; | ||
} else { | ||
hasLocalStorageSupport = false; | ||
} | ||
} catch (e){ | ||
hasLocalStorageSupport = false; | ||
} | ||
var $translateLocalStorage = hasLocalStorageSupport ? localStorageAdapter : $translateCookieStorage; | ||
return $translateLocalStorage; | ||
} | ||
]); | ||
var $translateLocalStorage = hasLocalStorageSupport ? localStorageAdapter : $translateCookieStorage; | ||
return $translateLocalStorage; | ||
}]); |
/*! | ||
* angular-translate - v2.5.0 - 2014-12-07 | ||
* angular-translate - v2.5.1 - 2014-12-10 | ||
* http://github.com/angular-translate/angular-translate | ||
@@ -4,0 +4,0 @@ * Copyright (c) 2014 ; Licensed MIT |
/*! | ||
* angular-translate - v2.5.0 - 2014-12-07 | ||
* angular-translate - v2.5.1 - 2014-12-10 | ||
* http://github.com/angular-translate/angular-translate | ||
* Copyright (c) 2014 ; Licensed MIT | ||
*/ | ||
angular.module("pascalprecht.translate",["ng"]).run(["$translate",function(a){var b=a.storageKey(),c=a.storage(),d=function(){var d=a.preferredLanguage();angular.isString(d)?a.use(d):c.put(b,a.use())};c?c.get(b)?a.use(c.get(b))["catch"](d):d():angular.isString(a.preferredLanguage())&&a.use(a.preferredLanguage())}]),angular.module("pascalprecht.translate").provider("$translate",["$STORAGE_KEY",function(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q={},r=[],s=a,t=[],u=!1,v="translate-cloak",w=!1,x=".",y="2.5.0",z=function(){var a,b,c=window.navigator,d=["language","browserLanguage","systemLanguage","userLanguage"];if(angular.isArray(c.languages))for(a=0;a<c.languages.length;a++)if(b=c.languages[a],b&&b.length)return b;for(a=0;a<d.length;a++)if(b=c[d[a]],b&&b.length)return b;return null};z.displayName="angular-translate/service: getFirstBrowserLanguage";var A=function(){return(z()||"").split("-").join("_")};A.displayName="angular-translate/service: getLocale";var B=function(a,b){for(var c=0,d=a.length;d>c;c++)if(a[c]===b)return c;return-1},C=function(){return this.replace(/^\s+|\s+$/g,"")},D=function(a){for(var b=[],d=angular.lowercase(a),e=0,f=r.length;f>e;e++)b.push(angular.lowercase(r[e]));if(B(b,d)>-1)return a;if(c){var g;for(var h in c){var i=!1,j=Object.prototype.hasOwnProperty.call(c,h)&&angular.lowercase(h)===angular.lowercase(a);if("*"===h.slice(-1)&&(i=h.slice(0,-1)===a.slice(0,h.length-1)),(j||i)&&(g=c[h],B(b,angular.lowercase(g))>-1))return g}}var k=a.split("_");return k.length>1&&B(b,angular.lowercase(k[0]))>-1?k[0]:a},E=function(a,b){if(!a&&!b)return q;if(a&&!b){if(angular.isString(a))return q[a]}else angular.isObject(q[a])||(q[a]={}),angular.extend(q[a],F(b));return this};this.translations=E,this.cloakClassName=function(a){return a?(v=a,this):v};var F=function(a,b,c,d){var e,f,g,h;b||(b=[]),c||(c={});for(e in a)Object.prototype.hasOwnProperty.call(a,e)&&(h=a[e],angular.isObject(h)?F(h,b.concat(e),c,e):(f=b.length?""+b.join(x)+x+e:e,b.length&&e===d&&(g=""+b.join(x),c[g]="@:"+f),c[f]=h));return c};this.addInterpolation=function(a){return t.push(a),this},this.useMessageFormatInterpolation=function(){return this.useInterpolation("$translateMessageFormatInterpolation")},this.useInterpolation=function(a){return k=a,this},this.useSanitizeValueStrategy=function(a){return u=a,this},this.preferredLanguage=function(a){return G(a),this};var G=function(a){return a&&(b=a),b};this.translationNotFoundIndicator=function(a){return this.translationNotFoundIndicatorLeft(a),this.translationNotFoundIndicatorRight(a),this},this.translationNotFoundIndicatorLeft=function(a){return a?(n=a,this):n},this.translationNotFoundIndicatorRight=function(a){return a?(o=a,this):o},this.fallbackLanguage=function(a){return H(a),this};var H=function(a){return a?(angular.isString(a)?(e=!0,d=[a]):angular.isArray(a)&&(e=!1,d=a),angular.isString(b)&&B(d,b)<0&&d.push(b),this):e?d[0]:d};this.use=function(a){if(a){if(!q[a]&&!l)throw new Error("$translateProvider couldn't find translationTable for langKey: '"+a+"'");return f=a,this}return f};var I=function(a){return a?void(s=a):i?i+s:s};this.storageKey=I,this.useUrlLoader=function(a,b){return this.useLoader("$translateUrlLoader",angular.extend({url:a},b))},this.useStaticFilesLoader=function(a){return this.useLoader("$translateStaticFilesLoader",a)},this.useLoader=function(a,b){return l=a,m=b||{},this},this.useLocalStorage=function(){return this.useStorage("$translateLocalStorage")},this.useCookieStorage=function(){return this.useStorage("$translateCookieStorage")},this.useStorage=function(a){return h=a,this},this.storagePrefix=function(a){return a?(i=a,this):a},this.useMissingTranslationHandlerLog=function(){return this.useMissingTranslationHandler("$translateMissingTranslationHandlerLog")},this.useMissingTranslationHandler=function(a){return j=a,this},this.usePostCompiling=function(a){return w=!!a,this},this.determinePreferredLanguage=function(a){var c=a&&angular.isFunction(a)?a():A();return b=r.length?D(c):c,this},this.registerAvailableLanguageKeys=function(a,b){return a?(r=a,b&&(c=b),this):r},this.useLoaderCache=function(a){return a===!1?p=void 0:a===!0?p=!0:"undefined"==typeof a?p="$translationCache":a&&(p=a),this},this.$get=["$log","$injector","$rootScope","$q",function(a,c,i,r){var x,z,A,J=c.get(k||"$translateDefaultInterpolation"),K=!1,L={},M={},N=function(a,c,e){if(angular.isArray(a)){var g=function(a){for(var b={},d=[],f=function(a){var d=r.defer(),f=function(c){b[a]=c,d.resolve([a,c])};return N(a,c,e).then(f,f),d.promise},g=0,h=a.length;h>g;g++)d.push(f(a[g]));return r.all(d).then(function(){return b})};return g(a)}var i=r.defer();a&&(a=C.apply(a));var j=function(){var a=b?M[b]:M[f];if(z=0,h&&!a){var c=x.get(s);if(a=M[c],d&&d.length){var e=B(d,c);z=0===e?1:0,B(d,b)<0&&d.push(b)}}return a}();return j?j.then(function(){Z(a,c,e).then(i.resolve,i.reject)},i.reject):Z(a,c,e).then(i.resolve,i.reject),i.promise},O=function(a){return n&&(a=[n,a].join(" ")),o&&(a=[a,o].join(" ")),a},P=function(a){f=a,i.$emit("$translateChangeSuccess",{language:a}),h&&x.put(N.storageKey(),f),J.setLocale(f),angular.forEach(L,function(a,b){L[b].setLocale(f)}),i.$emit("$translateChangeEnd",{language:a})},Q=function(a){if(!a)throw"No language key specified for loading.";var b=r.defer();i.$emit("$translateLoadingStart",{language:a}),K=!0;var d=p;"string"==typeof d&&(d=c.get(d));var e=angular.extend({},m,{key:a,$http:angular.extend({},{cache:d},m.$http)});return c.get(l)(e).then(function(c){var d={};i.$emit("$translateLoadingSuccess",{language:a}),angular.isArray(c)?angular.forEach(c,function(a){angular.extend(d,F(a))}):angular.extend(d,F(c)),K=!1,b.resolve({key:a,table:d}),i.$emit("$translateLoadingEnd",{language:a})},function(a){i.$emit("$translateLoadingError",{language:a}),b.reject(a),i.$emit("$translateLoadingEnd",{language:a})}),b.promise};if(h&&(x=c.get(h),!x.get||!x.put))throw new Error("Couldn't use storage '"+h+"', missing get() or put() method!");angular.isFunction(J.useSanitizeValueStrategy)&&J.useSanitizeValueStrategy(u),t.length&&angular.forEach(t,function(a){var d=c.get(a);d.setLocale(b||f),angular.isFunction(d.useSanitizeValueStrategy)&&d.useSanitizeValueStrategy(u),L[d.getInterpolationIdentifier()]=d});var R=function(a){var b=r.defer();return Object.prototype.hasOwnProperty.call(q,a)?b.resolve(q[a]):M[a]?M[a].then(function(a){E(a.key,a.table),b.resolve(a.table)},b.reject):b.reject(),b.promise},S=function(a,b,c,d){var e=r.defer();return R(a).then(function(g){Object.prototype.hasOwnProperty.call(g,b)?(d.setLocale(a),e.resolve(d.interpolate(g[b],c)),d.setLocale(f)):e.reject()},e.reject),e.promise},T=function(a,b,c,d){var e,g=q[a];return g&&Object.prototype.hasOwnProperty.call(g,b)&&(d.setLocale(a),e=d.interpolate(g[b],c),d.setLocale(f)),e},U=function(a){if(j){var b=c.get(j)(a,f);return void 0!==b?b:a}return a},V=function(a,b,c,e){var f=r.defer();if(a<d.length){var g=d[a];S(g,b,c,e).then(f.resolve,function(){V(a+1,b,c,e).then(f.resolve)})}else f.resolve(U(b));return f.promise},W=function(a,b,c,e){var f;if(a<d.length){var g=d[a];f=T(g,b,c,e),f||(f=W(a+1,b,c,e))}return f},X=function(a,b,c){return V(A>0?A:z,a,b,c)},Y=function(a,b,c){return W(A>0?A:z,a,b,c)},Z=function(a,b,c){var e=r.defer(),g=f?q[f]:q,h=c?L[c]:J;if(g&&Object.prototype.hasOwnProperty.call(g,a)){var i=g[a];"@:"===i.substr(0,2)?N(i.substr(2),b,c).then(e.resolve,e.reject):e.resolve(h.interpolate(i,b))}else{var k;j&&!K&&(k=U(a)),f&&d&&d.length?X(a,b,h).then(function(a){e.resolve(a)},function(a){e.reject(O(a))}):j&&!K&&k?e.resolve(k):e.reject(O(a))}return e.promise},$=function(a,b,c){var e,g=f?q[f]:q,h=c?L[c]:J;if(g&&Object.prototype.hasOwnProperty.call(g,a)){var i=g[a];e="@:"===i.substr(0,2)?$(i.substr(2),b,c):h.interpolate(i,b)}else{var k;j&&!K&&(k=U(a)),f&&d&&d.length?(z=0,e=Y(a,b,h)):e=j&&!K&&k?k:O(a)}return e};if(N.preferredLanguage=function(a){return a&&G(a),b},N.cloakClassName=function(){return v},N.fallbackLanguage=function(a){if(void 0!==a&&null!==a){if(H(a),l&&d&&d.length)for(var b=0,c=d.length;c>b;b++)M[d[b]]||(M[d[b]]=Q(d[b]));N.use(N.use())}return e?d[0]:d},N.useFallbackLanguage=function(a){if(void 0!==a&&null!==a)if(a){var b=B(d,a);b>-1&&(A=b)}else A=0},N.proposedLanguage=function(){return g},N.storage=function(){return x},N.use=function(a){if(!a)return f;var b=r.defer();i.$emit("$translateChangeStart",{language:a});var c=D(a);return c&&(a=c),q[a]||!l||M[a]?(b.resolve(a),P(a)):(g=a,M[a]=Q(a).then(function(c){return E(c.key,c.table),b.resolve(c.key),P(c.key),g===a&&(g=void 0),c},function(a){g===a&&(g=void 0),i.$emit("$translateChangeError",{language:a}),b.reject(a),i.$emit("$translateChangeEnd",{language:a})})),b.promise},N.storageKey=function(){return I()},N.isPostCompilingEnabled=function(){return w},N.refresh=function(a){function b(){e.resolve(),i.$emit("$translateRefreshEnd",{language:a})}function c(){e.reject(),i.$emit("$translateRefreshEnd",{language:a})}if(!l)throw new Error("Couldn't refresh translation table, no loader registered!");var e=r.defer();if(i.$emit("$translateRefreshStart",{language:a}),a)q[a]?Q(a).then(function(c){E(c.key,c.table),a===f&&P(f),b()},c):c();else{var g=[],h={};if(d&&d.length)for(var j=0,k=d.length;k>j;j++)g.push(Q(d[j])),h[d[j]]=!0;f&&!h[f]&&g.push(Q(f)),r.all(g).then(function(a){angular.forEach(a,function(a){q[a.key]&&delete q[a.key],E(a.key,a.table)}),f&&P(f),b()})}return e.promise},N.instant=function(a,c,e){if(null===a||angular.isUndefined(a))return a;if(angular.isArray(a)){for(var g={},h=0,i=a.length;i>h;h++)g[a[h]]=N.instant(a[h],c,e);return g}if(angular.isString(a)&&a.length<1)return a;a&&(a=C.apply(a));var k,l=[];b&&l.push(b),f&&l.push(f),d&&d.length&&(l=l.concat(d));for(var m=0,n=l.length;n>m;m++){var o=l[m];if(q[o]&&"undefined"!=typeof q[o][a]&&(k=$(a,c,e)),"undefined"!=typeof k)break}return k||""===k||(k=J.interpolate(a,c),j&&!K&&(k=U(a))),k},N.versionInfo=function(){return y},N.loaderCache=function(){return p},l&&(angular.equals(q,{})&&N.use(N.use()),d&&d.length))for(var _=function(a){return E(a.key,a.table),i.$emit("$translateChangeEnd",{language:a.key}),a},ab=0,bb=d.length;bb>ab;ab++)M[d[ab]]=Q(d[ab]).then(_);return N}]}]),angular.module("pascalprecht.translate").factory("$translateDefaultInterpolation",["$interpolate",function(a){var b,c={},d="default",e=null,f={escaped:function(a){var b={};for(var c in a)Object.prototype.hasOwnProperty.call(a,c)&&(b[c]=angular.element("<div></div>").text(a[c]).html());return b}},g=function(a){var b;return b=angular.isFunction(f[e])?f[e](a):a};return c.setLocale=function(a){b=a},c.getInterpolationIdentifier=function(){return d},c.useSanitizeValueStrategy=function(a){return e=a,this},c.interpolate=function(b,c){return e&&(c=g(c)),a(b)(c||{})},c}]),angular.module("pascalprecht.translate").constant("$STORAGE_KEY","NG_TRANSLATE_LANG_KEY"),angular.module("pascalprecht.translate").directive("translate",["$translate","$q","$interpolate","$compile","$parse","$rootScope",function(a,b,c,d,e,f){return{restrict:"AE",scope:!0,compile:function(b,g){var h=g.translateValues?g.translateValues:void 0,i=g.translateInterpolation?g.translateInterpolation:void 0,j=b[0].outerHTML.match(/translate-value-+/i),k="^(.*)("+c.startSymbol()+".*"+c.endSymbol()+")(.*)";return function(b,l,m){b.interpolateParams={},b.preText="",b.postText="";var n={},o=function(a){if(angular.equals(a,"")||!angular.isDefined(a)){var d=l.text().match(k);angular.isArray(d)?(b.preText=d[1],b.postText=d[3],n.translate=c(d[2])(b.$parent)):n.translate=l.text().replace(/^\s+|\s+$/g,"")}else n.translate=a;t()},p=function(a){m.$observe(a,function(b){n[a]=b,t()})};m.$observe("translate",function(a){o(a)});for(var q in m)m.hasOwnProperty(q)&&"translateAttr"===q.substr(0,13)&&p(q);if(m.$observe("translateDefault",function(a){b.defaultText=a}),h&&m.$observe("translateValues",function(a){a&&b.$parent.$watch(function(){angular.extend(b.interpolateParams,e(a)(b.$parent))})}),j){var r=function(a){m.$observe(a,function(c){var d=angular.lowercase(a.substr(14,1))+a.substr(15);b.interpolateParams[d]=c})};for(var s in m)Object.prototype.hasOwnProperty.call(m,s)&&"translateValue"===s.substr(0,14)&&"translateValues"!==s&&r(s)}var t=function(){for(var a in n)n.hasOwnProperty(a)&&n[a]&&u(a,n[a],b,b.interpolateParams)},u=function(b,c,d,e){a(c,e,i).then(function(a){v(a,d,!0,b)},function(a){v(a,d,!1,b)})},v=function(b,c,e,f){if("translate"===f){e||"undefined"==typeof c.defaultText||(b=c.defaultText),l.html(c.preText+b+c.postText);var h=a.isPostCompilingEnabled(),i="undefined"!=typeof g.translateCompile,j=i&&"false"!==g.translateCompile;(h&&!i||j)&&d(l.contents())(c)}else{e||"undefined"==typeof c.defaultText||(b=c.defaultText);var k=m.$attr[f].substr(15);l.attr(k,b)}};b.$watch("interpolateParams",t,!0);var w=f.$on("$translateChangeSuccess",t);l.text().length&&o(""),t(),b.$on("$destroy",w)}}}}]),angular.module("pascalprecht.translate").directive("translateCloak",["$rootScope","$translate",function(a,b){return{compile:function(c){var d=function(){c.addClass(b.cloakClassName())},e=function(){c.removeClass(b.cloakClassName())},f=a.$on("$translateChangeEnd",function(){e(),f(),f=null});return d(),function(a,c,f){f.translateCloak&&f.translateCloak.length&&f.$observe("translateCloak",function(a){b(a).then(e,d)})}}}}]),angular.module("pascalprecht.translate").filter("translate",["$parse","$translate",function(a,b){var c=function(c,d,e){return angular.isObject(d)||(d=a(d)(this)),b.instant(c,d,e)};return c.$stateful=!0,c}]); | ||
angular.module("pascalprecht.translate",["ng"]).run(["$translate",function(a){var b=a.storageKey(),c=a.storage(),d=function(){var d=a.preferredLanguage();angular.isString(d)?a.use(d):c.put(b,a.use())};c?c.get(b)?a.use(c.get(b))["catch"](d):d():angular.isString(a.preferredLanguage())&&a.use(a.preferredLanguage())}]),angular.module("pascalprecht.translate").provider("$translate",["$STORAGE_KEY",function(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q={},r=[],s=a,t=[],u=!1,v="translate-cloak",w=!1,x=".",y="2.5.1",z=function(){var a,b,c=window.navigator,d=["language","browserLanguage","systemLanguage","userLanguage"];if(angular.isArray(c.languages))for(a=0;a<c.languages.length;a++)if(b=c.languages[a],b&&b.length)return b;for(a=0;a<d.length;a++)if(b=c[d[a]],b&&b.length)return b;return null};z.displayName="angular-translate/service: getFirstBrowserLanguage";var A=function(){return(z()||"").split("-").join("_")};A.displayName="angular-translate/service: getLocale";var B=function(a,b){for(var c=0,d=a.length;d>c;c++)if(a[c]===b)return c;return-1},C=function(){return this.replace(/^\s+|\s+$/g,"")},D=function(a){for(var b=[],d=angular.lowercase(a),e=0,f=r.length;f>e;e++)b.push(angular.lowercase(r[e]));if(B(b,d)>-1)return a;if(c){var g;for(var h in c){var i=!1,j=Object.prototype.hasOwnProperty.call(c,h)&&angular.lowercase(h)===angular.lowercase(a);if("*"===h.slice(-1)&&(i=h.slice(0,-1)===a.slice(0,h.length-1)),(j||i)&&(g=c[h],B(b,angular.lowercase(g))>-1))return g}}var k=a.split("_");return k.length>1&&B(b,angular.lowercase(k[0]))>-1?k[0]:a},E=function(a,b){if(!a&&!b)return q;if(a&&!b){if(angular.isString(a))return q[a]}else angular.isObject(q[a])||(q[a]={}),angular.extend(q[a],F(b));return this};this.translations=E,this.cloakClassName=function(a){return a?(v=a,this):v};var F=function(a,b,c,d){var e,f,g,h;b||(b=[]),c||(c={});for(e in a)Object.prototype.hasOwnProperty.call(a,e)&&(h=a[e],angular.isObject(h)?F(h,b.concat(e),c,e):(f=b.length?""+b.join(x)+x+e:e,b.length&&e===d&&(g=""+b.join(x),c[g]="@:"+f),c[f]=h));return c};this.addInterpolation=function(a){return t.push(a),this},this.useMessageFormatInterpolation=function(){return this.useInterpolation("$translateMessageFormatInterpolation")},this.useInterpolation=function(a){return k=a,this},this.useSanitizeValueStrategy=function(a){return u=a,this},this.preferredLanguage=function(a){return G(a),this};var G=function(a){return a&&(b=a),b};this.translationNotFoundIndicator=function(a){return this.translationNotFoundIndicatorLeft(a),this.translationNotFoundIndicatorRight(a),this},this.translationNotFoundIndicatorLeft=function(a){return a?(n=a,this):n},this.translationNotFoundIndicatorRight=function(a){return a?(o=a,this):o},this.fallbackLanguage=function(a){return H(a),this};var H=function(a){return a?(angular.isString(a)?(e=!0,d=[a]):angular.isArray(a)&&(e=!1,d=a),angular.isString(b)&&B(d,b)<0&&d.push(b),this):e?d[0]:d};this.use=function(a){if(a){if(!q[a]&&!l)throw new Error("$translateProvider couldn't find translationTable for langKey: '"+a+"'");return f=a,this}return f};var I=function(a){return a?void(s=a):i?i+s:s};this.storageKey=I,this.useUrlLoader=function(a,b){return this.useLoader("$translateUrlLoader",angular.extend({url:a},b))},this.useStaticFilesLoader=function(a){return this.useLoader("$translateStaticFilesLoader",a)},this.useLoader=function(a,b){return l=a,m=b||{},this},this.useLocalStorage=function(){return this.useStorage("$translateLocalStorage")},this.useCookieStorage=function(){return this.useStorage("$translateCookieStorage")},this.useStorage=function(a){return h=a,this},this.storagePrefix=function(a){return a?(i=a,this):a},this.useMissingTranslationHandlerLog=function(){return this.useMissingTranslationHandler("$translateMissingTranslationHandlerLog")},this.useMissingTranslationHandler=function(a){return j=a,this},this.usePostCompiling=function(a){return w=!!a,this},this.determinePreferredLanguage=function(a){var c=a&&angular.isFunction(a)?a():A();return b=r.length?D(c):c,this},this.registerAvailableLanguageKeys=function(a,b){return a?(r=a,b&&(c=b),this):r},this.useLoaderCache=function(a){return a===!1?p=void 0:a===!0?p=!0:"undefined"==typeof a?p="$translationCache":a&&(p=a),this},this.$get=["$log","$injector","$rootScope","$q",function(a,c,i,r){var x,z,A,J=c.get(k||"$translateDefaultInterpolation"),K=!1,L={},M={},N=function(a,c,e){if(angular.isArray(a)){var g=function(a){for(var b={},d=[],f=function(a){var d=r.defer(),f=function(c){b[a]=c,d.resolve([a,c])};return N(a,c,e).then(f,f),d.promise},g=0,h=a.length;h>g;g++)d.push(f(a[g]));return r.all(d).then(function(){return b})};return g(a)}var i=r.defer();a&&(a=C.apply(a));var j=function(){var a=b?M[b]:M[f];if(z=0,h&&!a){var c=x.get(s);if(a=M[c],d&&d.length){var e=B(d,c);z=0===e?1:0,B(d,b)<0&&d.push(b)}}return a}();return j?j.then(function(){Z(a,c,e).then(i.resolve,i.reject)},i.reject):Z(a,c,e).then(i.resolve,i.reject),i.promise},O=function(a){return n&&(a=[n,a].join(" ")),o&&(a=[a,o].join(" ")),a},P=function(a){f=a,i.$emit("$translateChangeSuccess",{language:a}),h&&x.put(N.storageKey(),f),J.setLocale(f),angular.forEach(L,function(a,b){L[b].setLocale(f)}),i.$emit("$translateChangeEnd",{language:a})},Q=function(a){if(!a)throw"No language key specified for loading.";var b=r.defer();i.$emit("$translateLoadingStart",{language:a}),K=!0;var d=p;"string"==typeof d&&(d=c.get(d));var e=angular.extend({},m,{key:a,$http:angular.extend({},{cache:d},m.$http)});return c.get(l)(e).then(function(c){var d={};i.$emit("$translateLoadingSuccess",{language:a}),angular.isArray(c)?angular.forEach(c,function(a){angular.extend(d,F(a))}):angular.extend(d,F(c)),K=!1,b.resolve({key:a,table:d}),i.$emit("$translateLoadingEnd",{language:a})},function(a){i.$emit("$translateLoadingError",{language:a}),b.reject(a),i.$emit("$translateLoadingEnd",{language:a})}),b.promise};if(h&&(x=c.get(h),!x.get||!x.put))throw new Error("Couldn't use storage '"+h+"', missing get() or put() method!");angular.isFunction(J.useSanitizeValueStrategy)&&J.useSanitizeValueStrategy(u),t.length&&angular.forEach(t,function(a){var d=c.get(a);d.setLocale(b||f),angular.isFunction(d.useSanitizeValueStrategy)&&d.useSanitizeValueStrategy(u),L[d.getInterpolationIdentifier()]=d});var R=function(a){var b=r.defer();return Object.prototype.hasOwnProperty.call(q,a)?b.resolve(q[a]):M[a]?M[a].then(function(a){E(a.key,a.table),b.resolve(a.table)},b.reject):b.reject(),b.promise},S=function(a,b,c,d){var e=r.defer();return R(a).then(function(g){Object.prototype.hasOwnProperty.call(g,b)?(d.setLocale(a),e.resolve(d.interpolate(g[b],c)),d.setLocale(f)):e.reject()},e.reject),e.promise},T=function(a,b,c,d){var e,g=q[a];return g&&Object.prototype.hasOwnProperty.call(g,b)&&(d.setLocale(a),e=d.interpolate(g[b],c),d.setLocale(f)),e},U=function(a){if(j){var b=c.get(j)(a,f);return void 0!==b?b:a}return a},V=function(a,b,c,e){var f=r.defer();if(a<d.length){var g=d[a];S(g,b,c,e).then(f.resolve,function(){V(a+1,b,c,e).then(f.resolve)})}else f.resolve(U(b));return f.promise},W=function(a,b,c,e){var f;if(a<d.length){var g=d[a];f=T(g,b,c,e),f||(f=W(a+1,b,c,e))}return f},X=function(a,b,c){return V(A>0?A:z,a,b,c)},Y=function(a,b,c){return W(A>0?A:z,a,b,c)},Z=function(a,b,c){var e=r.defer(),g=f?q[f]:q,h=c?L[c]:J;if(g&&Object.prototype.hasOwnProperty.call(g,a)){var i=g[a];"@:"===i.substr(0,2)?N(i.substr(2),b,c).then(e.resolve,e.reject):e.resolve(h.interpolate(i,b))}else{var k;j&&!K&&(k=U(a)),f&&d&&d.length?X(a,b,h).then(function(a){e.resolve(a)},function(a){e.reject(O(a))}):j&&!K&&k?e.resolve(k):e.reject(O(a))}return e.promise},$=function(a,b,c){var e,g=f?q[f]:q,h=c?L[c]:J;if(g&&Object.prototype.hasOwnProperty.call(g,a)){var i=g[a];e="@:"===i.substr(0,2)?$(i.substr(2),b,c):h.interpolate(i,b)}else{var k;j&&!K&&(k=U(a)),f&&d&&d.length?(z=0,e=Y(a,b,h)):e=j&&!K&&k?k:O(a)}return e};if(N.preferredLanguage=function(a){return a&&G(a),b},N.cloakClassName=function(){return v},N.fallbackLanguage=function(a){if(void 0!==a&&null!==a){if(H(a),l&&d&&d.length)for(var b=0,c=d.length;c>b;b++)M[d[b]]||(M[d[b]]=Q(d[b]));N.use(N.use())}return e?d[0]:d},N.useFallbackLanguage=function(a){if(void 0!==a&&null!==a)if(a){var b=B(d,a);b>-1&&(A=b)}else A=0},N.proposedLanguage=function(){return g},N.storage=function(){return x},N.use=function(a){if(!a)return f;var b=r.defer();i.$emit("$translateChangeStart",{language:a});var c=D(a);return c&&(a=c),q[a]||!l||M[a]?(b.resolve(a),P(a)):(g=a,M[a]=Q(a).then(function(c){return E(c.key,c.table),b.resolve(c.key),P(c.key),g===a&&(g=void 0),c},function(a){g===a&&(g=void 0),i.$emit("$translateChangeError",{language:a}),b.reject(a),i.$emit("$translateChangeEnd",{language:a})})),b.promise},N.storageKey=function(){return I()},N.isPostCompilingEnabled=function(){return w},N.refresh=function(a){function b(){e.resolve(),i.$emit("$translateRefreshEnd",{language:a})}function c(){e.reject(),i.$emit("$translateRefreshEnd",{language:a})}if(!l)throw new Error("Couldn't refresh translation table, no loader registered!");var e=r.defer();if(i.$emit("$translateRefreshStart",{language:a}),a)q[a]?Q(a).then(function(c){E(c.key,c.table),a===f&&P(f),b()},c):c();else{var g=[],h={};if(d&&d.length)for(var j=0,k=d.length;k>j;j++)g.push(Q(d[j])),h[d[j]]=!0;f&&!h[f]&&g.push(Q(f)),r.all(g).then(function(a){angular.forEach(a,function(a){q[a.key]&&delete q[a.key],E(a.key,a.table)}),f&&P(f),b()})}return e.promise},N.instant=function(a,c,e){if(null===a||angular.isUndefined(a))return a;if(angular.isArray(a)){for(var g={},h=0,i=a.length;i>h;h++)g[a[h]]=N.instant(a[h],c,e);return g}if(angular.isString(a)&&a.length<1)return a;a&&(a=C.apply(a));var k,l=[];b&&l.push(b),f&&l.push(f),d&&d.length&&(l=l.concat(d));for(var m=0,n=l.length;n>m;m++){var o=l[m];if(q[o]&&"undefined"!=typeof q[o][a]&&(k=$(a,c,e)),"undefined"!=typeof k)break}return k||""===k||(k=J.interpolate(a,c),j&&!K&&(k=U(a))),k},N.versionInfo=function(){return y},N.loaderCache=function(){return p},l&&(angular.equals(q,{})&&N.use(N.use()),d&&d.length))for(var _=function(a){return E(a.key,a.table),i.$emit("$translateChangeEnd",{language:a.key}),a},ab=0,bb=d.length;bb>ab;ab++)M[d[ab]]=Q(d[ab]).then(_);return N}]}]),angular.module("pascalprecht.translate").factory("$translateDefaultInterpolation",["$interpolate",function(a){var b,c={},d="default",e=null,f={escaped:function(a){var b={};for(var c in a)Object.prototype.hasOwnProperty.call(a,c)&&(b[c]=angular.element("<div></div>").text(a[c]).html());return b}},g=function(a){var b;return b=angular.isFunction(f[e])?f[e](a):a};return c.setLocale=function(a){b=a},c.getInterpolationIdentifier=function(){return d},c.useSanitizeValueStrategy=function(a){return e=a,this},c.interpolate=function(b,c){return e&&(c=g(c)),a(b)(c||{})},c}]),angular.module("pascalprecht.translate").constant("$STORAGE_KEY","NG_TRANSLATE_LANG_KEY"),angular.module("pascalprecht.translate").directive("translate",["$translate","$q","$interpolate","$compile","$parse","$rootScope",function(a,b,c,d,e,f){return{restrict:"AE",scope:!0,compile:function(b,g){var h=g.translateValues?g.translateValues:void 0,i=g.translateInterpolation?g.translateInterpolation:void 0,j=b[0].outerHTML.match(/translate-value-+/i),k="^(.*)("+c.startSymbol()+".*"+c.endSymbol()+")(.*)",l="^(.*)"+c.startSymbol()+"(.*)"+c.endSymbol()+"(.*)";return function(b,m,n){b.interpolateParams={},b.preText="",b.postText="";var o={},p=function(a){if(angular.equals(a,"")||!angular.isDefined(a)){var d=m.text().match(k);angular.isArray(d)?(b.preText=d[1],b.postText=d[3],o.translate=c(d[2])(b.$parent),watcherMatches=m.text().match(l),angular.isArray(watcherMatches)&&watcherMatches[2]&&watcherMatches[2].length&&b.$watch(watcherMatches[2],function(a){o.translate=a,u()})):o.translate=m.text().replace(/^\s+|\s+$/g,"")}else o.translate=a;u()},q=function(a){n.$observe(a,function(b){o[a]=b,u()})};n.$observe("translate",function(a){p(a)});for(var r in n)n.hasOwnProperty(r)&&"translateAttr"===r.substr(0,13)&&q(r);if(n.$observe("translateDefault",function(a){b.defaultText=a}),h&&n.$observe("translateValues",function(a){a&&b.$parent.$watch(function(){angular.extend(b.interpolateParams,e(a)(b.$parent))})}),j){var s=function(a){n.$observe(a,function(c){var d=angular.lowercase(a.substr(14,1))+a.substr(15);b.interpolateParams[d]=c})};for(var t in n)Object.prototype.hasOwnProperty.call(n,t)&&"translateValue"===t.substr(0,14)&&"translateValues"!==t&&s(t)}var u=function(){for(var a in o)o.hasOwnProperty(a)&&o[a]&&v(a,o[a],b,b.interpolateParams)},v=function(b,c,d,e){a(c,e,i).then(function(a){w(a,d,!0,b)},function(a){w(a,d,!1,b)})},w=function(b,c,e,f){if("translate"===f){e||"undefined"==typeof c.defaultText||(b=c.defaultText),m.html(c.preText+b+c.postText);var h=a.isPostCompilingEnabled(),i="undefined"!=typeof g.translateCompile,j=i&&"false"!==g.translateCompile;(h&&!i||j)&&d(m.contents())(c)}else{e||"undefined"==typeof c.defaultText||(b=c.defaultText);var k=n.$attr[f].substr(15);m.attr(k,b)}};b.$watch("interpolateParams",u,!0);var x=f.$on("$translateChangeSuccess",u);m.text().length&&p(""),u(),b.$on("$destroy",x)}}}}]),angular.module("pascalprecht.translate").directive("translateCloak",["$rootScope","$translate",function(a,b){return{compile:function(c){var d=function(){c.addClass(b.cloakClassName())},e=function(){c.removeClass(b.cloakClassName())},f=a.$on("$translateChangeEnd",function(){e(),f(),f=null});return d(),function(a,c,f){f.translateCloak&&f.translateCloak.length&&f.$observe("translateCloak",function(a){b(a).then(e,d)})}}}}]),angular.module("pascalprecht.translate").filter("translate",["$parse","$translate",function(a,b){var c=function(c,d,e){return angular.isObject(d)||(d=a(d)(this)),b.instant(c,d,e)};return c.$stateful=!0,c}]); |
{ | ||
"name": "angular-translate", | ||
"version": "2.5.0", | ||
"version": "2.5.1", | ||
"description": "A translation module for AngularJS", | ||
@@ -47,9 +47,15 @@ "main": "dist/angular-translate.js", | ||
"grunt-express": "~0.3.3", | ||
"grunt-karma": "~0.6.x", | ||
"grunt-karma": "~0.9.0", | ||
"grunt-ng-annotate": "^0.8.0", | ||
"grunt-ngdocs": "~0.1.11", | ||
"grunt-ngmin": "0.0.2", | ||
"grunt-version": "~0.3.0", | ||
"karma": "~0.10.9", | ||
"jasmine-core": "^2.1.3", | ||
"karma": "~0.12.28", | ||
"karma-chrome-launcher": "~0.1.5", | ||
"karma-coverage": "^0.2.7", | ||
"karma-firefox-launcher": "~0.1.3", | ||
"karma-jasmine": "^0.3.2", | ||
"karma-phantomjs-launcher": "~0.1.4", | ||
"load-grunt-tasks": "~0.2.0" | ||
} | ||
} |
# [![angular-translate](https://raw.github.com/angular-translate/angular-translate/canary/identity/logo/angular-translate-alternative/angular-translate_alternative_medium2.png)](http://angular-translate.github.io) | ||
![Bower](https://img.shields.io/bower/v/angular-translate.svg) [![NPM](https://img.shields.io/npm/v/angular-translate.svg)](https://www.npmjs.com/package/angular-translate) [![Build Status](https://img.shields.io/travis/angular-translate/angular-translate.svg)](https://travis-ci.org/angular-translate/angular-translate) ![License](https://img.shields.io/npm/l/angular-translate.svg) [![Built with Grunt](https://cdn.gruntjs.com/builtwith.png)](http://gruntjs.com/) | ||
> i18n for your Angular app, made easy! | ||
@@ -8,5 +11,4 @@ | ||
| ------------- |:-------------:| | ||
| master | [![Build Status](https://travis-ci.org/angular-translate/angular-translate.png?branch=master)](https://travis-ci.org/angular-translate/angular-translate) | | ||
| canary |[![Build Status](https://travis-ci.org/angular-translate/angular-translate.png?branch=canary)](https://travis-ci.org/angular-translate/angular-translate) | | ||
| BitDeli |[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/angular-translate/angular-translate/trend.png)](https://bitdeli.com/free "Bitdeli Badge") | | ||
| master | [![Build Status](https://travis-ci.org/angular-translate/angular-translate.svg?branch=master)](https://travis-ci.org/angular-translate/angular-translate) | | ||
| canary |[![Build Status](https://travis-ci.org/angular-translate/angular-translate.svg?branch=canary)](https://travis-ci.org/angular-translate/angular-translate) | | ||
@@ -43,1 +45,20 @@ ### Presentation (Dutch AngularJS Meetup 2013) | ||
and everybody who comes with new ideas and feature requests! So **THANK YOU**! | ||
## Contribution | ||
Contributing to <code>angular-translate</code> is fairly easy. [This document](CONTRIBUTING.md) shows you how to | ||
get the project, run all provided tests and generate a production ready build. | ||
## Tests | ||
### Unit tests | ||
Note: Check that dependencies are be installed (`npm install`). | ||
The *unit tests* are available with `npm test`. It performs tests under the current primary target version of AngularJS and other scoped versions as well. Under the hood, this calls `grunt test` for the primary target and for each scope. | ||
Testing only the primary target AngularJS version, simply invoke `grunt test`. | ||
## License | ||
Licensed under MIT. |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
155628
2854
63
25