Update to 2.4.1

Change-Id: Iae603434f1897fcbf47cf37bbedf5956848a5bd2
This commit is contained in:
Radomir Dopieralski 2020-01-21 13:51:01 +01:00
parent 9c8b0dd8e7
commit 6b7ba0f82b
4 changed files with 27 additions and 20 deletions

View File

@ -1,5 +1,5 @@
XStatic-Angular-Gettext
--------------
-----------------------
Angular-Gettext javascript library packaged for setuptools (easy_install) / pip.

View File

@ -1,9 +1,9 @@
[metadata]
name = XStatic-Angular-Gettext
description = Angular-Gettext 2.3.8 (XStatic packaging standard)
description = Angular-Gettext 2.4.1 (XStatic packaging standard)
description-file = README.rst
maintainer = Rob Cresswell
maintainer-email = robert.cresswell@outlook.com
maintainer = Radomir Dopieralski
maintainer-email = openstack@sheep.art.pl
home-page = https://angular-gettext.rocketeer.be/
keywords = angular_gettext xstatic
license = MIT

View File

@ -11,7 +11,7 @@ NAME = __name__.split('.')[-1] # package name (e.g. 'foo' or 'foo_bar')
# please use a all-lowercase valid python
# package name
VERSION = '2.3.8' # version of the packaged files, please use the upstream
VERSION = '2.4.1' # version of the packaged files, please use the upstream
# version number
BUILD = '0' # our package build number, so we can release new builds
# with fixes for xstatic stuff.
@ -24,8 +24,8 @@ CLASSIFIERS = []
KEYWORDS = '%s xstatic' % NAME
# XStatic-* package maintainer:
MAINTAINER = 'Rob Cresswell'
MAINTAINER_EMAIL = 'robert.cresswell@outlook.com'
MAINTAINER = 'Radomir Dopieralski'
MAINTAINER_EMAIL = 'openstack@sheep.art.pl'
# this refers to the project homepage of the stuff we packaged:
HOMEPAGE = 'https://angular-gettext.rocketeer.be/'

View File

@ -60,7 +60,7 @@ angular.module('gettext').constant('gettext', function (str) {
* @requires https://docs.angularjs.org/api/ng/service/$cacheFactory $cacheFactory
* @requires https://docs.angularjs.org/api/ng/service/$interpolate $interpolate
* @requires https://docs.angularjs.org/api/ng/service/$rootScope $rootScope
* @description Provides set of method to translate stings
* @description Provides set of method to translate strings
*/
angular.module('gettext').factory('gettextCatalog', ["gettextPlurals", "gettextFallbackLanguage", "$http", "$cacheFactory", "$interpolate", "$rootScope", function (gettextPlurals, gettextFallbackLanguage, $http, $cacheFactory, $interpolate, $rootScope) {
var catalog;
@ -233,15 +233,20 @@ angular.module('gettext').factory('gettextCatalog', ["gettextPlurals", "gettextF
val = obj;
}
// Expand single strings for each context.
if (!this.strings[language][key]) {
this.strings[language][key] = {};
}
for (var context in val) {
var str = val[context];
if (!angular.isArray(str)) {
val[context] = [];
val[context][defaultPlural] = str;
// Expand single strings
this.strings[language][key][context] = [];
this.strings[language][key][context][defaultPlural] = str;
} else {
this.strings[language][key][context] = str;
}
}
this.strings[language][key] = val;
}
broadcastUpdated();
@ -253,7 +258,7 @@ angular.module('gettext').factory('gettextCatalog', ["gettextPlurals", "gettextF
* @protected
* @param {String} language language name
* @param {String} string translation key
* @param {Number=} n number to build sting form for
* @param {Number=} n number to build string form for
* @param {String=} context translation key context, e.g. {@link doc:context Verb, Noun}
* @returns {String|Null} translated or annotated string or null if language is not set
* @description Translate a string with the given language, count and context.
@ -300,7 +305,7 @@ angular.module('gettext').factory('gettextCatalog', ["gettextPlurals", "gettextF
* @ngdoc method
* @name gettextCatalog#getPlural
* @public
* @param {Number} n number to build sting form for
* @param {Number} n number to build string form for
* @param {String} string translation key
* @param {String} stringPlural plural translation key
* @param {$rootScope.Scope=} scope scope to do interpolation against
@ -405,7 +410,7 @@ angular.module('gettext').factory('gettextCatalog', ["gettextPlurals", "gettextF
* ```
*/
angular.module('gettext').directive('translate', ["gettextCatalog", "$parse", "$animate", "$compile", "$window", "gettextUtil", function (gettextCatalog, $parse, $animate, $compile, $window, gettextUtil) {
var msie = parseInt((/msie (\d+)/.exec(angular.lowercase($window.navigator.userAgent)) || [])[1], 10);
var msie = parseInt((/msie (\d+)/i.exec($window.navigator.userAgent) || [])[1], 10);
var PARAMS_PREFIX = 'translateParams';
function getCtxAttr(key) {
@ -421,7 +426,7 @@ angular.module('gettext').directive('translate', ["gettextCatalog", "$parse", "$
return null;
}
var interpolationContext = angular.extend({}, scope);
var interpolationContext = scope.$new();
var unwatchers = [];
attributes.forEach(function (attribute) {
var unwatch = scope.$watch(attrs[attribute], function (newVal) {
@ -435,6 +440,8 @@ angular.module('gettext').directive('translate', ["gettextCatalog", "$parse", "$
unwatchers.forEach(function (unwatch) {
unwatch();
});
interpolationContext.$destroy();
});
return interpolationContext;
}
@ -473,13 +480,13 @@ angular.module('gettext').directive('translate', ["gettextCatalog", "$parse", "$
if (translatePlural) {
scope = pluralScope || (pluralScope = scope.$new());
scope.$count = countFn(scope);
translated = gettextCatalog.getPlural(scope.$count, msgid, translatePlural, interpolationContext, translateContext);
translated = gettextCatalog.getPlural(scope.$count, msgid, translatePlural, null, translateContext);
} else {
translated = gettextCatalog.getString(msgid, interpolationContext, translateContext);
translated = gettextCatalog.getString(msgid, null, translateContext);
}
var oldContents = element.contents();
if (oldContents.length === 0){
if (!oldContents && !translated){
return;
}
@ -494,7 +501,7 @@ angular.module('gettext').directive('translate', ["gettextCatalog", "$parse", "$
// Swap in the translation
var newWrapper = angular.element('<span>' + translated + '</span>');
$compile(newWrapper.contents())(scope);
$compile(newWrapper.contents())(interpolationContext || scope);
var newContents = newWrapper.contents();
$animate.enter(newContents, element);