Gettext=function(a){this.domain='messages';this.locale_data=undefined;var b=["domain","locale_data"];if(this.isValidObject(a)){for(var i in a){for(var j=0;j0){for(var i=0;i+*/%:;a-zA-Z0-9_\(\)])+)','m');if(k.test(j)){var l=Gettext._locale_data[b].head['plural-forms'];if(!/;\s*$/.test(l))l=l.concat(';');var m='var plural; var nplurals; '+l+' return { "nplural" : nplurals, "plural" : (plural === true ? 1 : plural ? plural : 0) };';Gettext._locale_data[b].head.plural_func=new Function("n",m)}else{throw new Error("Syntax error in language file. Plural-Forms header is invalid ["+j+"]");}}else if(typeof(Gettext._locale_data[b].head.plural_func)=='undefined'){Gettext._locale_data[b].head.plural_func=function(n){var p=(n!=1)?1:0;return{'nplural':2,'plural':p}}}}return};Gettext.prototype.try_load_lang_po=function(a){var b=this.sjax(a);if(!b)return;var c=this.uri_basename(a);var d=this.parse_po(b);var e={};if(d){if(!d[""])d[""]={};if(!d[""]["domain"])d[""]["domain"]=c;c=d[""]["domain"];e[c]=d;this.parse_locale_data(e)}return 1};Gettext.prototype.uri_basename=function(a){var b;if(b=a.match(/^(.*\/)?(.*)/)){var c;if(c=b[2].match(/^(.*)\..+$/))return c[1];else return b[2]}else{return""}};Gettext.prototype.parse_po=function(a){var b={};var c={};var d="";var e=[];var f=a.split("\n");for(var i=0;i1)b[h]=k;c={};d=""}}else if(/^#/.test(f[i])){continue}else if(g=f[i].match(/^msgctxt\s+(.*)/)){d='msgctxt';c[d]=this.parse_po_dequote(g[1])}else if(g=f[i].match(/^msgid\s+(.*)/)){d='msgid';c[d]=this.parse_po_dequote(g[1])}else if(g=f[i].match(/^msgid_plural\s+(.*)/)){d='msgid_plural';c[d]=this.parse_po_dequote(g[1])}else if(g=f[i].match(/^msgstr\s+(.*)/)){d='msgstr_0';c[d]=this.parse_po_dequote(g[1])}else if(g=f[i].match(/^msgstr\[0\]\s+(.*)/)){d='msgstr_0';c[d]=this.parse_po_dequote(g[1])}else if(g=f[i].match(/^msgstr\[(\d+)\]\s+(.*)/)){d='msgstr_'+g[1];c[d]=this.parse_po_dequote(g[2])}else if(/^"/.test(f[i])){c[d]+=this.parse_po_dequote(f[i])}else{e.push("Strange line ["+i+"] : "+f[i])}}if(typeof(c['msgid'])!='undefined'){var h=(typeof(c['msgctxt'])!='undefined'&&c['msgctxt'].length)?c['msgctxt']+Gettext.context_glue+c['msgid']:c['msgid'];var j=(typeof(c['msgid_plural'])!='undefined'&&c['msgid_plural'].length)?c['msgid_plural']:null;var k=[];for(var l in c){var g;if(g=l.match(/^msgstr_(\d+)/))k[parseInt(g[1])]=c[l]}k.unshift(j);if(k.length>1)b[h]=k;c={};d=""}if(b[""]&&b[""][1]){var m={};var n=b[""][1].split(/\\n/);for(var i=0;i0&&o[0].length!=0)break}}}if(o.length==0||o[0].length==0){o=[c,d]}var t=o[0];if(f){var p;if(q&&this.isValidObject(r.head.plural_func)){var u=r.head.plural_func(n);if(!u.plural)u.plural=0;if(!u.nplural)u.nplural=0;if(u.nplural<=u.plural)u.plural=0;p=u.plural}else{p=(n!=1)?1:0}if(this.isValidObject(o[p]))t=o[p]}return t};Gettext.strargs=function(a,b){if(null==b||'undefined'==typeof(b)){b=[]}else if(b.constructor!=Array){b=[b]}var c="";while(true){var i=a.indexOf('%');var d;if(i==-1){c+=a;break}c+=a.substr(0,i);if(a.substr(i,2)=='%%'){c+='%';a=a.substr((i+2))}else if(d=a.substr(i).match(/^%(\d+)/)){var e=parseInt(d[1]);var f=d[1].length;if(e>0&&b[e-1]!=null&&typeof(b[e-1])!='undefined')c+=b[e-1];a=a.substr((i+1+f))}else{c+='%';a=a.substr((i+1))}}return c};Gettext.prototype.strargs=function(a,b){return Gettext.strargs(a,b)};Gettext.prototype.isArray=function(a){return this.isValidObject(a)&&a.constructor==Array};Gettext.prototype.isValidObject=function(a){if(null==a){return false}else if('undefined'==typeof(a)){return false}else{return true}};Gettext.prototype.sjax=function(a){var b;if(window.XMLHttpRequest){b=new XMLHttpRequest()}else if(navigator.userAgent.toLowerCase().indexOf('msie 5')!=-1){b=new ActiveXObject("Microsoft.XMLHTTP")}else{b=new ActiveXObject("Msxml2.XMLHTTP")}if(!b)throw new Error("Your browser doesn't do Ajax. Unable to support external language files.");b.open('GET',a,false);try{b.send(null)}catch(e){return}var c=b.status;if(c==200||c==0){return b.responseText}else{var d=b.statusText+" (Error "+b.status+")";if(b.responseText.length){d+="\n"+b.responseText}alert(d);return}};Gettext.prototype.JSON=function(a){return eval('('+a+')')}