/*! * I.js, simple helper to manage localized strings. * https://github.com/RobertoPrevato/I.js * * Copyright 2017, Roberto Prevato * https://robertoprevato.github.io/ * * Licensed under the MIT license: * http://www.opensource.org/licenses/MIT */ !function(a){if("undefined"!=typeof module&&module.exports)module.exports=a(this);else if("function"==typeof define&&define.amd){var b=this;define("i",function(){return a(b)})}else this.I=a(this)}(function(a){var b={locale:"en",current:function(){return this.regional[this.locale]},setLocale:function(a){if(this.locale=a,typeof document!==d){var b=document.body.classList;for(var e in this.regional)b.remove(c(e));b.add(c(a))}},regional:{},rx:/\{\{(.+?)\}\}/g,t:function(a,b){var c=this.locale,d=this.regional;if(!d[c])return[f,c].join(e);for(var h=e,i=d[c],j=a.split(/\./g);h=j.shift();){if(!i)return[g,a].join(e);i=i[h]}return i?"object"==typeof i?i:b&&"string"==typeof i?i.replace(this.rx,function(c,d){if(!b.hasOwnProperty(d))throw"Missing property "+d+", for template: "+a;return b[d]}):i:[g,c,".",a].join(e)},lookup:function(a){var b=this.locale,c=this.regional;if(!c[b])return[f,b].join(e);for(var g=e,h=c[b],i=a.split(/\./g);g=i.shift();){if(!h)return!1;h=h[g]}return typeof h!=d},tryGet:function(a){return this.lookup(a)?this.t(a):null},add:function(a){return this.extend(this.regional,a)},extend:function(){var a=arguments;if(a.length){if(1==a.length)return a[0];for(var b,c,d=a[0],e=1,f=a.length;f>e;e++)if(b=a[e]){var g=[];for(c in b)d.hasOwnProperty(c)?g.push("`"+c+"`"):d[c]=b[c];g.length&&console.error("I.js Found "+g.length+" duplicated keys. "+g.join("; "))}return d}}},c=function(a){return a.toLowerCase()},d="undefined",e="",f="Missing regional for: ",g="Missing translation for: ";return b});