/* jQuery Internationalization library 1.0.4
 * Copyright (C) 2012 Santhosh Thottingal
 * Dual licensed GPLv2 or later and MIT. */
!function(e){"use strict";var n,a,o=Array.prototype.slice;(a=function(n){this.options=e.extend({},a.defaults,n),this.parser=this.options.parser,this.locale=this.options.locale,this.messageStore=this.options.messageStore,this.languages={},this.init()}).prototype={init:function(){var n=this;String.locale=n.locale,String.prototype.toLocaleString=function(){var a,o,t,i,l,r,s;for(t=this.valueOf(),i=n.locale,l=0;i;){o=(a=i.split("-")).length;do{if(r=a.slice(0,o).join("-"),s=n.messageStore.get(r,t))return s;o--}while(o);if("en"===i)break;i=e.i18n.fallbacks[n.locale]&&e.i18n.fallbacks[n.locale][l]||n.options.fallbackLocale,e.i18n.log("Trying fallback locale for "+n.locale+": "+i),l++}return""}},destroy:function(){e.removeData(document,"i18n")},load:function(n,a){var o,t,i,l={};if(n||a||(n="i18n/"+e.i18n().locale+".json",a=e.i18n().locale),"string"==typeof n&&"json"!==n.split(".").pop()){l[a]=n+"/"+a+".json",o=(e.i18n.fallbacks[a]||[]).concat(this.options.fallbackLocale);for(t in o)l[i=o[t]]=n+"/"+i+".json";return this.load(l)}return this.messageStore.load(n,a)},parse:function(n,a){var o=n.toLocaleString();return this.parser.language=e.i18n.languages[e.i18n().locale]||e.i18n.languages.default,""===o&&(o=n),this.parser.parse(o,a)}},e.i18n=function(n,t){var i,l=e.data(document,"i18n"),r="object"==typeof n&&n;return r&&r.locale&&l&&l.locale!==r.locale&&(String.locale=l.locale=r.locale),l||(l=new a(r),e.data(document,"i18n",l)),"string"==typeof n?(i=void 0!==t?o.call(arguments,1):[],l.parse(n,i)):l},e.fn.i18n=function(){var n=e.data(document,"i18n");return n||(n=new a,e.data(document,"i18n",n)),String.locale=n.locale,this.each(function(){var a=e(this),o=a.data("i18n");o?a.text(n.parse(o)):a.find("[data-i18n]").i18n()})},String.locale=String.locale||e("html").attr("lang"),String.locale||(void 0!==typeof window.navigator?(n=window.navigator,String.locale=n.language||n.userLanguage||""):String.locale=""),e.i18n.languages={},e.i18n.messageStore=e.i18n.messageStore||{},e.i18n.parser={parse:function(e,n){return e.replace(/\$(\d+)/g,function(e,a){var o=parseInt(a,10)-1;return void 0!==n[o]?n[o]:"$"+a})},emitter:{}},e.i18n.fallbacks={},e.i18n.debug=!1,e.i18n.log=function(){window.console&&e.i18n.debug&&window.console.log.apply(window.console,arguments)},a.defaults={locale:String.locale,fallbackLocale:"en",parser:e.i18n.parser,messageStore:e.i18n.messageStore},e.i18n.constructor=a}(jQuery);
