/* * # i18n library * * ## locale.js: i18n for Node.js and browser * * @author Dmitry A. Chleck * @url https://github.com/chleck/locale-js */var locale=new function(){function i(r,i){var o,a;if(!r.phrase)return"";try{r.n===undefined?o=n[i][r.phrase]||u(r.phrase):(a=t[i](r.n),o=n[i][r.phrase[0]][a])}catch(f){if(r.n===undefined)o=u(r.phrase);else try{a=t[e](r.n),o=u(r.phrase[a])}catch(f){o=u(r.phrase[0])}}return s(o,r.args,r.n)}function s(e,t,n){function a(){return r=e[i++],r}function f(){o={};switch(a()){case undefined:break;case"%":u.push("%");break;case"(":l();break;default:i--,c()}}function l(){var t=i;while(a())if(r==")"){o.name=e.substring(t,i-1),c();break}}function c(){o.flags="";while(a()&&" +-".indexOf(r)>=0)o.flags+=r;r&&(i--,h())}function h(){o.width="";while(a()&&"0123456789".indexOf(r)>=0)o.width+=r;r&&(o.width*=1,r=="."?p():d())}function p(){o.precision="";while(a()&&"0123456789".indexOf(r)>=0)o.precision+=r;r&&(o.precision=Number(o.precision),o.precision<0&&(o.precision=0),d())}function d(){var e="",i="";o.type=r;if(o.type=="n"){o.type="d";var a=n}else var a=(o.name?t[o.name]:t[s++])||"";if("debhxX".indexOf(o.type)>=0){typeof a!="number"&&(a=NaN);if(isNaN(a)){if(o.flags.indexOf(" ")>=0||o.flags.indexOf("+")>=0)i=" "}else a<0?i="-":(o.flags.indexOf(" ")>=0&&(i=" "),o.flags.indexOf("+")>=0&&(i="+"));a=Math.abs(a)}switch(o.type){case"s":e=a,!e&&o.flags.indexOf(" ")>=0&&(e=" "),o.precision&&(e=e.substr(0,o.precision));break;case"d":e=i+(o.precision?a.toFixed(o.precision):a.toString());break;case"e":e=i+a.toExponential(o.precision?o.precision:6);break;case"b":e=i+Math.round(a).toString(2)+"b";break;case"h":e=i+Math.round(a).toString(16).toUpperCase()+"h";break;case"x":e=i+"0x"+Math.round(a).toString(16);break;case"X":e=i+"0x"+Math.round(a).toString(16).toUpperCase();break;default:return}var f="";for(var l=o.width-e.length;l>0;l--)f+=" ";o.flags.indexOf("-")>=0?e+=f:e=f+e,u.push(e)}var r,i=0,s=0,o,u=[];while(a())r=="%"?f():u.push(r);return u.join("")}function o(e){var t=0,n;while(n=e[t++])if(n=="#"){if(e[t]!="#")break;t++}var r=e.indexOf(" ",t);r<0&&(r=e.length);var i=e.slice(0,t-1),s=e.slice(t,r);return s&&(i+="#"+s),i}function u(e){var t=0,n;while(n=e[t++])if(n=="#"){if(e[t]!="#")break;t++}return e.slice(0,t-1).replace(/##/g,"#")}var e,t,n={},r=this;this.init=function(n,r){e=n||"en",t={},t[e]=Function("n","return "+(r||"(n == 1 ? 0 : 1)"))},this.add=function(e,r){n[e]=r,t[e]=Function("n","return "+(r[""]||"(n == 1 ? 0 : 1)"))},this.i18n=function(t){var n=this,r;r=t===undefined?"":t,this.to=function(t){if(t===undefined)return r;t===""&&(t=e||"en"),r=t},this.__=function(){var e,t,n=Array.prototype.slice.call(arguments);e=n.shift()||"",Array.isArray(e)&&(t=n.shift());if(t===undefined)e=o(e);else for(var s in e)e[s]=o(e[s]);if(typeof n[0]=="object"||Array.isArray(n[0]))n=n[0];var u={__i18n:!0,phrase:e,n:t,args:n};return r===null?u:i(u,r)},this.tr=function(e){if(typeof e!="object")return;for(var t in e)e[t].__i18n?e[t]=i(e[t],r):n.tr(e[t])}};var a=new r.i18n;for(var f in a)r[f]=a[f]};typeof exports=="object"&&(exports.locale=locale);