angular-gettext
Advanced tools
Comparing version 0.0.1 to 0.0.2
@@ -7,2 +7,3 @@ angular.module('gettext', []); | ||
Catalog = function () { | ||
var prefixDebug; | ||
function Catalog() { | ||
@@ -13,14 +14,32 @@ this.debug = false; | ||
} | ||
prefixDebug = function (debug, string) { | ||
if (debug) { | ||
return '[MISSING]: ' + string; | ||
} else { | ||
return string; | ||
} | ||
}; | ||
Catalog.prototype.setStrings = function (language, strings) { | ||
return this.strings[language] = strings; | ||
var key, val, _results; | ||
this.strings[language] = {}; | ||
_results = []; | ||
for (key in strings) { | ||
val = strings[key]; | ||
if (typeof val === 'string') { | ||
_results.push(this.strings[language][key] = [val]); | ||
} else { | ||
_results.push(this.strings[language][key] = val); | ||
} | ||
} | ||
return _results; | ||
}; | ||
Catalog.prototype.getString = function (string) { | ||
var _ref; | ||
return ((_ref = this.strings[this.currentLanguage]) != null ? _ref[string] : void 0) || (this.debug ? '[MISSING]: ' + string : string); | ||
var _ref, _ref1; | ||
return ((_ref = this.strings[this.currentLanguage]) != null ? (_ref1 = _ref[string]) != null ? _ref1[0] : void 0 : void 0) || prefixDebug(this.debug, string); | ||
}; | ||
Catalog.prototype.getPlural = function (n, string, stringPlural) { | ||
var form, plurals, _ref, _ref1; | ||
var form, plurals, _ref; | ||
form = gettextPlurals(this.currentLanguage, n); | ||
plurals = ((_ref = this.strings[this.currentLanguage]) != null ? (_ref1 = _ref['_plurals']) != null ? _ref1[string] : void 0 : void 0) || []; | ||
return plurals[form] || (n === 1 ? string : stringPlural); | ||
plurals = ((_ref = this.strings[this.currentLanguage]) != null ? _ref[string] : void 0) || []; | ||
return plurals[form] || prefixDebug(this.debug, n === 1 ? string : stringPlural); | ||
}; | ||
@@ -27,0 +46,0 @@ return Catalog; |
@@ -1,1 +0,1 @@ | ||
angular.module("gettext",[]),angular.module("gettext").factory("gettextCatalog",["gettextPlurals",function(a){var b;return b=function(){function b(){this.debug=!1,this.strings={},this.currentLanguage="en"}return b.prototype.setStrings=function(a,b){return this.strings[a]=b},b.prototype.getString=function(a){var b;return(null!=(b=this.strings[this.currentLanguage])?b[a]:void 0)||(this.debug?"[MISSING]: "+a:a)},b.prototype.getPlural=function(b,c,d){var e,f,g,h;return e=a(this.currentLanguage,b),f=(null!=(g=this.strings[this.currentLanguage])?null!=(h=g._plurals)?h[c]:void 0:void 0)||[],f[e]||(1===b?c:d)},b}(),new b}]),angular.module("gettext").directive("translate",["gettextCatalog","$interpolate","$parse",function(a,b,c){return{compile:function(d,e){var f,g;return f=function(a,b){throw new Error("You should add a "+a+" attribute whenever you add a "+b+" attribute.")},e.translatePlural&&!e.translateN&&f("translate-n","translate-plural"),e.translateN&&!e.translatePlural&&f("translate-plural","translate-n"),g=d.html(),function(f){var h,i;return h=c(e.translateN),i=function(){var c,i,j;return i=d.html(),j=e.translatePlural?a.getPlural(h(f),g,e.translatePlural):a.getString(g),c=b(j)(f),i!==c?d.html(c):void 0},f.$watch(i)}}}}]),angular.module("gettext").factory("gettextPlurals",function(){return function(a,b){switch(a){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 1!=b%10||11==b%100?1:0;case"jv":return 0!=b?1:0;case"mk":return 1==b||1==b%10?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"tg":case"ti":case"tr":case"uz":case"wa":case"zh":return b>1?1:0;case"lv":return 1==b%10&&11!=b%100?0:0!=b?1:2;case"lt":return 1==b%10&&11!=b%100?0:b%10>=2&&(10>b%100||b%100>=20)?1:2;case"be":case"bs":case"hr":case"ru":case"sr":case"uk":return 1==b%10&&11!=b%100?0:b%10>=2&&4>=b%10&&(10>b%100||b%100>=20)?1:2;case"mnk":return 0==b?0:1==b?1:2;case"ro":return 1==b?0:0==b||b%100>0&&20>b%100?1:2;case"pl":return 1==b?0:b%10>=2&&4>=b%10&&(10>b%100||b%100>=20)?1:2;case"cs":case"sk":return 1==b?0:b>=2&&4>=b?1:2;case"sl":return 1==b%100?1:2==b%100?2:3==b%100||4==b%100?3:0;case"mt":return 1==b?0:0==b||b%100>1&&11>b%100?1:b%100>10&&20>b%100?2:3;case"gd":return 1==b||11==b?0:2==b||12==b?1:b>2&&20>b?2:3;case"cy":return 1==b?0:2==b?1:8!=b&&11!=b?2:3;case"kw":return 1==b?0:2==b?1:3==b?2:3;case"ga":return 1==b?0:2==b?1:7>b?2:11>b?3:4;case"ar":return 0==b?0:1==b?1:2==b?2:b%100>=3&&10>=b%100?3:b%100>=11?4:5;default:return 1!=b?1:0}}}); | ||
angular.module("gettext",[]),angular.module("gettext").factory("gettextCatalog",["gettextPlurals",function(a){var b;return b=function(){function b(){this.debug=!1,this.strings={},this.currentLanguage="en"}var c;return c=function(a,b){return a?"[MISSING]: "+b:b},b.prototype.setStrings=function(a,b){var c,d,e;this.strings[a]={},e=[];for(c in b)d=b[c],"string"==typeof d?e.push(this.strings[a][c]=[d]):e.push(this.strings[a][c]=d);return e},b.prototype.getString=function(a){var b,d;return(null!=(b=this.strings[this.currentLanguage])?null!=(d=b[a])?d[0]:void 0:void 0)||c(this.debug,a)},b.prototype.getPlural=function(b,d,e){var f,g,h;return f=a(this.currentLanguage,b),g=(null!=(h=this.strings[this.currentLanguage])?h[d]:void 0)||[],g[f]||c(this.debug,1===b?d:e)},b}(),new b}]),angular.module("gettext").directive("translate",["gettextCatalog","$interpolate","$parse",function(a,b,c){return{compile:function(d,e){var f,g;return f=function(a,b){throw new Error("You should add a "+a+" attribute whenever you add a "+b+" attribute.")},e.translatePlural&&!e.translateN&&f("translate-n","translate-plural"),e.translateN&&!e.translatePlural&&f("translate-plural","translate-n"),g=d.html(),function(f){var h,i;return h=c(e.translateN),i=function(){var c,i,j;return i=d.html(),j=e.translatePlural?a.getPlural(h(f),g,e.translatePlural):a.getString(g),c=b(j)(f),i!==c?d.html(c):void 0},f.$watch(i)}}}}]),angular.module("gettext").factory("gettextPlurals",function(){return function(a,b){switch(a){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 1!=b%10||11==b%100?1:0;case"jv":return 0!=b?1:0;case"mk":return 1==b||1==b%10?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"tg":case"ti":case"tr":case"uz":case"wa":case"zh":return b>1?1:0;case"lv":return 1==b%10&&11!=b%100?0:0!=b?1:2;case"lt":return 1==b%10&&11!=b%100?0:b%10>=2&&(10>b%100||b%100>=20)?1:2;case"be":case"bs":case"hr":case"ru":case"sr":case"uk":return 1==b%10&&11!=b%100?0:b%10>=2&&4>=b%10&&(10>b%100||b%100>=20)?1:2;case"mnk":return 0==b?0:1==b?1:2;case"ro":return 1==b?0:0==b||b%100>0&&20>b%100?1:2;case"pl":return 1==b?0:b%10>=2&&4>=b%10&&(10>b%100||b%100>=20)?1:2;case"cs":case"sk":return 1==b?0:b>=2&&4>=b?1:2;case"sl":return 1==b%100?1:2==b%100?2:3==b%100||4==b%100?3:0;case"mt":return 1==b?0:0==b||b%100>1&&11>b%100?1:b%100>10&&20>b%100?2:3;case"gd":return 1==b||11==b?0:2==b||12==b?1:b>2&&20>b?2:3;case"cy":return 1==b?0:2==b?1:8!=b&&11!=b?2:3;case"kw":return 1==b?0:2==b?1:3==b?2:3;case"ga":return 1==b?0:2==b?1:7>b?2:11>b?3:4;case"ar":return 0==b?0:1==b?1:2==b?2:b%100>=3&&10>=b%100?3:b%100>=11?4:5;default:return 1!=b?1:0}}}); |
{ | ||
"name": "angular-gettext", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "Gettext support for Angular.js", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
35209
309