-
Notifications
You must be signed in to change notification settings - Fork 2
/
jlg-i18n.min.js
2 lines (2 loc) · 1.42 KB
/
jlg-i18n.min.js
1
2
!function(){"use strict";var a=angular.module("jlgI18n",["ngLocale"]);a.run(["$filter",function(a){a("date").$stateful=!0}]),a.provider("jlgI18nService",function(){var a="bower_components/jlg-i18n/locale";this.localeDir=function(b){return void 0!=b&&(a=b),a};var b="i18n";this.i18nDir=function(a){return void 0!=a&&(b=a),b},this.$get=["$locale","$http",function(c,d){var e={};return e.refresh=function(){var e=this;this.translation={},d({url:b+"/"+c.id+".json",cache:!0}).then(function(a){e.translation=a.data})["catch"](function(a){console.error("error",a)}),d({url:a+"/locale_"+c.id+".json",cache:!0}).then(function(a){var b=a.data;for(var d in b)c.hasOwnProperty(d)&&(c[d]=b[d])})},e.changeLocale=function(a){c.id=a,e.refresh()},e.refresh(),e}]}),a.filter("i18n",["jlgI18nService",function(a){var b=function(b){var c=b,d=Array.prototype.slice.call(arguments,1),e=a.translation;e.hasOwnProperty(b)&&(c=e[b]);var f=function(){for(var a=[],b=0;b<Math.pow(2,d.length);b++){for(var c=[],e=0;e<d.length;e++){var f=b&Math.pow(2,e);f?c.push("@"):c.push(d[e])}a.push(c.join("_"))}return a},g=Array.apply(null,new Array(d.length)).map(function(){return"@"}).join("_");if("object"==typeof c){for(var h=f(),i=!1,j=0;j<h.length;j++)if(c.hasOwnProperty(h[j])){g=h[j],c=c[g],i=!0;break}i||(c=b)}for(var k=g.split("_"),j=0;j<d.length;j++)"@"===k[j]&&(c=c.replace(/\[\[.*?\]\]/,d[j]));return c};return b.$stateful=!0,b}])}();
//# sourceMappingURL=jlg-i18n.min.map