"use strict";!function(e){var t,n=function(){var t=this;t.messageStore={},t.currentLanguage=e("html").attr("lang")||"en",e('script[type="application/l10n"]').livequery((function(){var n,a=e(this),r=a.data(),o=r.i18nSrc||a.attr("src");r.i18nLanguage===t.currentLanguage&&(void 0===o?(n=JSON.parse(a.text()),t.addResource(n,r.i18nLanguage,r.i18nNamespace),t.translateAllElements()):t.loadResource(o,r.i18nLanguage,r.i18nNamespace))})),e(".i18n:not(.i18nTranslated)").livequery((function(){t.translateElement(this)})),e("html").on("change",(function(){var n=e(this).attr("lang")||"en";n!==t.currentLanguage&&t.changeLanguage(n)}))};n.prototype.loadResource=function(t,n,a){var r=this;e.getJSON(t).done((function(e){r.addResource(e,n,a),r.translateAllElements()})).fail((function(e,n,a){console&&console.error("error loading i18n dictionary from url "+t+", error: ",a)}))},n.prototype.addResource=function(t,n,a){var r=this;function o(t,o){o=a||"*",void 0===r.messageStore[n]&&(r.messageStore[n]={"*":{}}),r.messageStore[n][o]=e.extend(!0,r.messageStore[n][o],t)}n=n||r.currentLanguage,t instanceof Array?t.forEach((function(e){o(e.data,e.namespace)})):o(t)},n.prototype.translateAllElements=function(){var t=this;e(".i18n:not(.i18nTranslated)").each((function(){t.translateElement(this)}))},n.prototype.translateElement=function(t){var n,a=e(t),r=a.data(),o=r.i18nMessage,i={};return e.each(r,(function(e,t){e.match(/^i18n(.*)$/)&&"i18nMessage"!==e&&(e=RegExp.$1.toLowerCase(),i[e]=t)})),void 0===o&&(o=a.text()),void 0!==o&&(n=this.translate(o,i))!==o&&a.html(n).addClass("i18nTranslated"),a},n.prototype.translate=function(t,n){var a,r=this.messageStore[this.currentLanguage];return void 0!==r&&void 0===(a=r["*"][t])&&e.each(r,(function(e,n){return"*"!==e&&(a=n[t]),void 0===a||""===a})),void 0!==a&&""!==a||(a=t),void 0!==n&&e.each(n,(function(e,t){void 0!==e&&void 0!==t&&(a=a.replace("%"+e+"%",t))})),a},n.prototype.changeLanguage=function(e){this.currentLanguage=e,this.translateAllElements()},t=new n,e.i18n=function(e,n){return t.translate(e,n)}}(jQuery);
