angular-gettext
Advanced tools
Comparing version 2.3.10 to 2.3.11
{ | ||
"name": "angular-gettext", | ||
"version": "2.3.10", | ||
"version": "2.3.11", | ||
"main": "dist/angular-gettext.js", | ||
@@ -5,0 +5,0 @@ "ignore": [ |
@@ -63,3 +63,3 @@ /** | ||
* @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 | ||
*/ | ||
@@ -262,3 +262,3 @@ angular.module('gettext').factory('gettextCatalog', ["gettextPlurals", "gettextFallbackLanguage", "$http", "$cacheFactory", "$interpolate", "$rootScope", function (gettextPlurals, gettextFallbackLanguage, $http, $cacheFactory, $interpolate, $rootScope) { | ||
* @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} | ||
@@ -310,3 +310,3 @@ * @returns {String|Null} translated or annotated string or null if language is not set | ||
* @public | ||
* @param {Number} n number to build sting form for | ||
* @param {Number} n number to build string form for | ||
* @param {String} string translation key | ||
@@ -416,3 +416,4 @@ * @param {String} stringPlural plural translation key | ||
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 lowercase = angular.$$lowercase || angular.lowercase; | ||
var msie = parseInt((/msie (\d+)/.exec(lowercase($window.navigator.userAgent)) || [])[1], 10); | ||
var PARAMS_PREFIX = 'translateParams'; | ||
@@ -419,0 +420,0 @@ |
@@ -1,1 +0,1 @@ | ||
angular.module("gettext",[]),angular.module("gettext").constant("gettext",function(a){return a}),angular.module("gettext").factory("gettextCatalog",["gettextPlurals","gettextFallbackLanguage","$http","$cacheFactory","$interpolate","$rootScope",function(a,b,c,d,e,f){function g(){f.$broadcast("gettextLanguageChanged")}var h,i="$$noContext",j='<span id="test" title="test" class="tested">test</span>',k=angular.element("<span>"+j+"</span>").html()!==j,l=function(a){return h.debug&&h.currentLanguage!==h.baseLanguage?h.debugPrefix+a:a},m=function(a){return h.showTranslatedMarkers?h.translatedMarkerPrefix+a+h.translatedMarkerSuffix:a};return h={debug:!1,debugPrefix:"[MISSING]: ",showTranslatedMarkers:!1,translatedMarkerPrefix:"[",translatedMarkerSuffix:"]",strings:{},baseLanguage:"en",currentLanguage:"en",cache:d("strings"),setCurrentLanguage:function(a){this.currentLanguage=a,g()},getCurrentLanguage:function(){return this.currentLanguage},setStrings:function(b,c){this.strings[b]||(this.strings[b]={});var d=a(b,1);for(var e in c){var f=c[e];if(k&&(e=angular.element("<span>"+e+"</span>").html()),angular.isString(f)||angular.isArray(f)){var h={};h[i]=f,f=h}this.strings[b][e]||(this.strings[b][e]={});for(var j in f){var l=f[j];angular.isArray(l)?this.strings[b][e][j]=l:(this.strings[b][e][j]=[],this.strings[b][e][j][d]=l)}}g()},getStringFormFor:function(b,c,d,e){if(!b)return null;var f=this.strings[b]||{},g=f[c]||{},h=g[e||i]||[];return h[a(b,d)]},getString:function(a,c,d){var f=b(this.currentLanguage);return a=this.getStringFormFor(this.currentLanguage,a,1,d)||this.getStringFormFor(f,a,1,d)||l(a),a=c?e(a)(c):a,m(a)},getPlural:function(a,c,d,f,g){var h=b(this.currentLanguage);return c=this.getStringFormFor(this.currentLanguage,c,a,g)||this.getStringFormFor(h,c,a,g)||l(1===a?c:d),f&&(f.$count=a,c=e(c)(f)),m(c)},loadRemote:function(a){return c({method:"GET",url:a,cache:h.cache}).then(function(a){var b=a.data;for(var c in b)h.setStrings(c,b[c]);return a})}}}]),angular.module("gettext").directive("translate",["gettextCatalog","$parse","$animate","$compile","$window","gettextUtil",function(a,b,c,d,e,f){function g(a){return f.lcFirst(a.replace(j,""))}function h(a,b,c){var d=Object.keys(b).filter(function(a){return f.startsWith(a,j)&&a!==j});if(!d.length)return null;var e=angular.extend({},a),h=[];return d.forEach(function(d){var f=a.$watch(b[d],function(a){var b=g(d);e[b]=a,c(e)});h.push(f)}),a.$on("$destroy",function(){h.forEach(function(a){a()})}),e}var i=parseInt((/msie (\d+)/.exec(angular.lowercase(e.navigator.userAgent))||[])[1],10),j="translateParams";return{restrict:"AE",terminal:!0,compile:function(e,g){f.assert(!g.translatePlural||g.translateN,"translate-n","translate-plural"),f.assert(!g.translateN||g.translatePlural,"translate-plural","translate-n");var j=f.trim(e.html()),k=g.translatePlural,l=g.translateContext;return 8>=i&&"<!--IE fix-->"===j.slice(-13)&&(j=j.slice(0,-13)),{post:function(e,g,i){function m(b){b=b||null;var h;k?(e=o||(o=e.$new()),e.$count=n(e),h=a.getPlural(e.$count,j,k,b,l)):h=a.getString(j,b,l);var i=g.contents();if(i||h){if(h===f.trim(i.html()))return void(p&&d(i)(e));var m=angular.element("<span>"+h+"</span>");d(m.contents())(e);var q=m.contents();c.enter(q,g),c.leave(i)}}var n=b(i.translateN),o=null,p=!0,q=h(e,i,m);m(q),p=!1,i.translateN&&e.$watch(i.translateN,function(){m(q)}),e.$on("gettextLanguageChanged",function(){m(q)})}}}}}]),angular.module("gettext").factory("gettextFallbackLanguage",function(){var a={},b=/([^_]+)_[^_]+$/;return function(c){if(a[c])return a[c];var d=b.exec(c);return d?(a[c]=d[1],d[1]):null}}),angular.module("gettext").filter("translate",["gettextCatalog",function(a){function b(b,c){return a.getString(b,null,c)}return b.$stateful=!0,b}]),angular.module("gettext").factory("gettextPlurals",function(){function a(a){return b[a]||(b[a]=a.split(/\-|_/).shift()),b[a]}var b={pt_BR:"pt_BR","pt-BR":"pt_BR"};return function(b,c){switch(a(b)){case"ay":case"bo":case"cgg":case"dz":case"fa":case"id":case"ja":case"jbo":case"ka":case"kk":case"km":case"ko":case"ky":case"lo":case"ms":case"my":case"sah":case"su":case"th":case"tt":case"ug":case"vi":case"wo":case"zh":return 0;case"is":return c%10!=1||c%100==11?1:0;case"jv":return 0!=c?1:0;case"mk":return 1==c||c%10==1?0:1;case"ach":case"ak":case"am":case"arn":case"br":case"fil":case"fr":case"gun":case"ln":case"mfe":case"mg":case"mi":case"oc":case"pt_BR":case"tg":case"ti":case"tr":case"uz":case"wa":case"zh":return c>1?1:0;case"lv":return c%10==1&&c%100!=11?0:0!=c?1:2;case"lt":return c%10==1&&c%100!=11?0:c%10>=2&&(10>c%100||c%100>=20)?1:2;case"be":case"bs":case"hr":case"ru":case"sr":case"uk":return c%10==1&&c%100!=11?0:c%10>=2&&4>=c%10&&(10>c%100||c%100>=20)?1:2;case"mnk":return 0==c?0:1==c?1:2;case"ro":return 1==c?0:0==c||c%100>0&&20>c%100?1:2;case"pl":return 1==c?0:c%10>=2&&4>=c%10&&(10>c%100||c%100>=20)?1:2;case"cs":case"sk":return 1==c?0:c>=2&&4>=c?1:2;case"sl":return c%100==1?1:c%100==2?2:c%100==3||c%100==4?3:0;case"mt":return 1==c?0:0==c||c%100>1&&11>c%100?1:c%100>10&&20>c%100?2:3;case"gd":return 1==c||11==c?0:2==c||12==c?1:c>2&&20>c?2:3;case"cy":return 1==c?0:2==c?1:8!=c&&11!=c?2:3;case"kw":return 1==c?0:2==c?1:3==c?2:3;case"ga":return 1==c?0:2==c?1:7>c?2:11>c?3:4;case"ar":return 0==c?0:1==c?1:2==c?2:c%100>=3&&10>=c%100?3:c%100>=11?4:5;default:return 1!=c?1:0}}}),angular.module("gettext").factory("gettextUtil",function(){function a(a,b,c){if(!a)throw new Error("You should add a "+b+" attribute whenever you add a "+c+" attribute.")}function b(a,b){return 0===a.indexOf(b)}function c(a){var b=a.charAt(0).toLowerCase();return b+a.substr(1)}var d=function(){return String.prototype.trim?function(a){return"string"==typeof a?a.trim():a}:function(a){return"string"==typeof a?a.replace(/^\s*/,"").replace(/\s*$/,""):a}}();return{trim:d,assert:a,startsWith:b,lcFirst:c}}); | ||
angular.module("gettext",[]),angular.module("gettext").constant("gettext",function(t){return t}),angular.module("gettext").factory("gettextCatalog",["gettextPlurals","gettextFallbackLanguage","$http","$cacheFactory","$interpolate","$rootScope",function(i,u,e,t,c,r){var a,l="$$noContext",n='<span id="test" title="test" class="tested">test</span>',g=angular.element("<span>"+n+"</span>").html()!==n,o=function(t){return a.debug&&a.currentLanguage!==a.baseLanguage?a.debugPrefix+t:t},f=function(t){return a.showTranslatedMarkers?a.translatedMarkerPrefix+t+a.translatedMarkerSuffix:t};function h(){r.$broadcast("gettextLanguageChanged")}return a={debug:!1,debugPrefix:"[MISSING]: ",showTranslatedMarkers:!1,translatedMarkerPrefix:"[",translatedMarkerSuffix:"]",strings:{},baseLanguage:"en",currentLanguage:"en",cache:t("strings"),setCurrentLanguage:function(t){this.currentLanguage=t,h()},getCurrentLanguage:function(){return this.currentLanguage},setStrings:function(t,e){this.strings[t]||(this.strings[t]={});var r=i(t,1);for(var a in e){var n=e[a];if(g&&(a=angular.element("<span>"+a+"</span>").html()),angular.isString(n)||angular.isArray(n)){var s={};s[l]=n,n=s}for(var u in this.strings[t][a]||(this.strings[t][a]={}),n){var c=n[u];angular.isArray(c)?this.strings[t][a][u]=c:(this.strings[t][a][u]=[],this.strings[t][a][u][r]=c)}}h()},getStringFormFor:function(t,e,r,a){return t?(((this.strings[t]||{})[e]||{})[a||l]||[])[i(t,r)]:null},getString:function(t,e,r){var a=u(this.currentLanguage);return t=this.getStringFormFor(this.currentLanguage,t,1,r)||this.getStringFormFor(a,t,1,r)||o(t),t=e?c(t)(e):t,f(t)},getPlural:function(t,e,r,a,n){var s=u(this.currentLanguage);return e=this.getStringFormFor(this.currentLanguage,e,t,n)||this.getStringFormFor(s,e,t,n)||o(1===t?e:r),a&&(a.$count=t,e=c(e)(a)),f(e)},loadRemote:function(t){return e({method:"GET",url:t,cache:a.cache}).then(function(t){var e=t.data;for(var r in e)a.setStrings(r,e[r]);return t})}}}]),angular.module("gettext").directive("translate",["gettextCatalog","$parse","$animate","$compile","$window","gettextUtil",function(h,a,m,d,t,x){var e=angular.$$lowercase||angular.lowercase,r=parseInt((/msie (\d+)/.exec(e(t.navigator.userAgent))||[])[1],10),c="translateParams";function n(e,r,n){var t=Object.keys(r).filter(function(t){return x.startsWith(t,c)&&t!==c});if(!t.length)return null;var s=angular.extend({},e),u=[];return t.forEach(function(a){var t=e.$watch(r[a],function(t){var e,r=(e=a,x.lcFirst(e.replace(c,"")));s[r]=t,n(s)});u.push(t)}),e.$on("$destroy",function(){u.forEach(function(t){t()})}),s}return{restrict:"AE",terminal:!0,compile:function(t,e){x.assert(!e.translatePlural||e.translateN,"translate-n","translate-plural"),x.assert(!e.translateN||e.translatePlural,"translate-plural","translate-n");var g=x.trim(t.html()),o=e.translatePlural,f=e.translateContext;return r<=8&&"\x3c!--IE fix--\x3e"===g.slice(-13)&&(g=g.slice(0,-13)),{post:function(s,u,t){var c=a(t.translateN),i=null,l=!0;function e(t){var e;t=t||null,o?((s=i||(i=s.$new())).$count=c(s),e=h.getPlural(s.$count,g,o,t,f)):e=h.getString(g,t,f);var r=u.contents();if(r||e)if(e!==x.trim(r.html())){var a=angular.element("<span>"+e+"</span>");d(a.contents())(s);var n=a.contents();m.enter(n,u),m.leave(r)}else l&&d(r)(s)}var r=n(s,t,e);e(r),l=!1,t.translateN&&s.$watch(t.translateN,function(){e(r)}),s.$on("gettextLanguageChanged",function(){e(r)})}}}}}]),angular.module("gettext").factory("gettextFallbackLanguage",function(){var r={},a=/([^_]+)_[^_]+$/;return function(t){if(r[t])return r[t];var e=a.exec(t);return e?(r[t]=e[1],e[1]):null}}),angular.module("gettext").filter("translate",["gettextCatalog",function(r){function t(t,e){return r.getString(t,null,e)}return t.$stateful=!0,t}]),angular.module("gettext").factory("gettextPlurals",function(){var r={pt_BR:"pt_BR","pt-BR":"pt_BR"};return function(t,e){switch(function(t){r[t]||(r[t]=t.split(/\-|_/).shift());return r[t]}(t)){case"ay":case"bo":case"cgg":case"dz":case"fa":case"id":case"ja":case"jbo":case"ka":case"kk":case"km":case"ko":case"ky":case"lo":case"ms":case"my":case"sah":case"su":case"th":case"tt":case"ug":case"vi":case"wo":case"zh":return 0;case"is":return e%10!=1||e%100==11?1:0;case"jv":return 0!=e?1:0;case"mk":return 1==e||e%10==1?0:1;case"ach":case"ak":case"am":case"arn":case"br":case"fil":case"fr":case"gun":case"ln":case"mfe":case"mg":case"mi":case"oc":case"pt_BR":case"tg":case"ti":case"tr":case"uz":case"wa":case"zh":return 1<e?1:0;case"lv":return e%10==1&&e%100!=11?0:0!=e?1:2;case"lt":return e%10==1&&e%100!=11?0:2<=e%10&&(e%100<10||20<=e%100)?1:2;case"be":case"bs":case"hr":case"ru":case"sr":case"uk":return e%10==1&&e%100!=11?0:2<=e%10&&e%10<=4&&(e%100<10||20<=e%100)?1:2;case"mnk":return 0==e?0:1==e?1:2;case"ro":return 1==e?0:0==e||0<e%100&&e%100<20?1:2;case"pl":return 1==e?0:2<=e%10&&e%10<=4&&(e%100<10||20<=e%100)?1:2;case"cs":case"sk":return 1==e?0:2<=e&&e<=4?1:2;case"sl":return e%100==1?1:e%100==2?2:e%100==3||e%100==4?3:0;case"mt":return 1==e?0:0==e||1<e%100&&e%100<11?1:10<e%100&&e%100<20?2:3;case"gd":return 1==e||11==e?0:2==e||12==e?1:2<e&&e<20?2:3;case"cy":return 1==e?0:2==e?1:8!=e&&11!=e?2:3;case"kw":return 1==e?0:2==e?1:3==e?2:3;case"ga":return 1==e?0:2==e?1:e<7?2:e<11?3:4;case"ar":return 0==e?0:1==e?1:2==e?2:3<=e%100&&e%100<=10?3:11<=e%100?4:5;default:return 1!=e?1:0}}}),angular.module("gettext").factory("gettextUtil",function(){return{trim:String.prototype.trim?function(t){return"string"==typeof t?t.trim():t}:function(t){return"string"==typeof t?t.replace(/^\s*/,"").replace(/\s*$/,""):t},assert:function(t,e,r){if(!t)throw new Error("You should add a "+e+" attribute whenever you add a "+r+" attribute.")},startsWith:function(t,e){return 0===t.indexOf(e)},lcFirst:function(t){return t.charAt(0).toLowerCase()+t.substr(1)}}}); |
{ | ||
"name": "angular-gettext", | ||
"version": "2.3.10", | ||
"version": "2.3.11", | ||
"title": "Angular Gettext", | ||
@@ -26,23 +26,23 @@ "description": "Gettext support for Angular.js", | ||
"devDependencies": { | ||
"chai": "^3.5.0", | ||
"dgeni-alive": "~0.2.1", | ||
"chai": "^4.1.2", | ||
"dgeni-alive": "~0.4.1", | ||
"grunt": "~1.0.1", | ||
"grunt-bump": "0.8.0", | ||
"grunt-contrib-clean": "~1.0.0", | ||
"grunt-contrib-clean": "~1.1.0", | ||
"grunt-contrib-concat": "~1.0.0", | ||
"grunt-contrib-connect": "~1.0.0", | ||
"grunt-contrib-jshint": "~1.0.0", | ||
"grunt-contrib-uglify": "~1.0.0", | ||
"grunt-contrib-watch": "~1.0.0", | ||
"grunt-contrib-jshint": "~1.1.0", | ||
"grunt-contrib-uglify": "~3.3.0", | ||
"grunt-contrib-watch": "~1.1.0", | ||
"grunt-jscs": "^3.0.0", | ||
"grunt-karma": "~2.0.0", | ||
"grunt-ng-annotate": "^2.0.2", | ||
"grunt-protractor-runner": "^4.0.0", | ||
"grunt-shell": "^1.3.0", | ||
"karma": "~0.13.22", | ||
"grunt-ng-annotate": "^3.0.0", | ||
"grunt-protractor-runner": "^5.0.0", | ||
"grunt-shell": "^2.1.0", | ||
"karma": "~2.0.2", | ||
"karma-chai": "~0.1.0", | ||
"karma-firefox-launcher": "~1.0.0", | ||
"karma-mocha": "~1.0.1", | ||
"karma-chrome-launcher": "^2.2.0", | ||
"karma-mocha": "~1.3.0", | ||
"karma-phantomjs-launcher": "^1.0.0", | ||
"mocha": "^2.5.3", | ||
"mocha": "^5.1.1", | ||
"phantomjs-prebuilt": "^2.1.7", | ||
@@ -49,0 +49,0 @@ "serve-static": "^1.11.1" |
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
200214
12
834