forked from openiap/opencore
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathangular-localization.min.js
More file actions
9 lines (9 loc) · 6.09 KB
/
Copy pathangular-localization.min.js
File metadata and controls
9 lines (9 loc) · 6.09 KB
1
2
3
4
5
6
7
8
9
/*!
* angular-localization-spiria :: v1.6.0 :: 2017-05-10
* web: http://doshprompt.github.io/angular-localization
*
* Copyright (c) 2017 | Rahul Doshi
* License: MIT
*/
!function(e,n,t,o){"use strict";e.module("ngLocalize.Version",[]).constant("localeVer","1.6.0"),e.module("ngLocalize",["ngSanitize","ngLocalize.Config","ngLocalize.Events","ngLocalize.InstalledLanguages"]),e.module("ngLocalize.InstalledLanguages",[]).value("localeSupported",["en-US"]).value("localeFallbacks",{en:"en-US"}),e.module("ngLocalize").service("locale",["$injector","$http","$q","$log","$rootScope","$window","localeConf","localeEvents","localeSupported","localeFallbacks",function(n,o,r,a,i,l,c,u,s,f){function g(e){var n,t;if(c.allowNestedJson){var o=e?e.split("."):[];n=o.length>1?o.slice(1):"",t=o.length>0?o[0].split(K):[],t.push(o.length>1?o[1]:"")}else t=e?e.split("/").join(".").split("."):[],n=t.length>1?t[t.length-1]:"";return{key:n,path:t}}function d(e){return e&&e.length&&P.test(e)}function h(e){var n=g(e).path,t="";return n.length>1&&(t=n.slice(0,-1).join(K)),t}function v(e){return g(e).key}function p(e){var n,t=null,o=g(e).path;if(o.length>1)for(t=x,n=0;n<o.length-1;n++){if(!t[o[n]]){t=null;break}t=t[o[n]]}return t}function $(e){return(Object.isFrozen||function(e){return e&&e.$$frozen})(e)}function m(e){return(Object.freeze||function(e){e&&(e.$$frozen=!0)})(e)}function L(e,n,t){return e.replace(new RegExp(n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"g"),t)}function S(n){var t,r,l,s=g(n).path,f=x,d=C,v=c.basePath+"/"+d;if(s.length>1){for(l=0;l<s.length-1;l++)r=s[l],f[r]||(f[r]={}),t=f,f=f[r],v+="/"+r;$(f)&&(f=e.extend({},f)),f._loading||(f._loading=!0,v+=c.fileExtension,o.get(v).then(function(e){var o,a=h(n),l=e.data;for(o in l)l.hasOwnProperty(o)&&(f[o]=l[o]);delete f._loading,t[r]=m(f),f=null,i.$broadcast(u.resourceUpdates,{locale:d,path:a,bundle:t[r]}),U[a]&&U[a].resolve(a)},function(e){var t=h(n);a.error("[localizationService] Failed to load: "+v),delete f._loading,U[t]&&U[t].reject(e.data)}))}}function b(e){var n,t;return e=e||c.langFile,t=e+"._LOOKUP_",n=p(t),U[e]||(U[e]=r.defer()),n&&!n._loading?U[e].resolve(e):n||S(t),U[e].promise}function w(n){var t,o,a;if(e.isString(n))t=n.split(",");else{if(!e.isArray(n))throw new Error("locale.ready requires either an Array or comma-separated list.");t=n}return t.length>1?(a=[],t.forEach(function(e){a.push(b(e))}),o=r.all(a)):o=b(n),o}function E(n,t){var o=n,r=0;return t&&(e.isArray(t)?e.forEach(t,function(e,n){o=L(o,"%"+(n+1),e),o=L(o,"{"+(n+1)+"}",e)}):e.forEach(t,function(e,n){++r,o=L(o,"{"+n+"}",e),o=L(o,"%"+n,e),o=L(o,"%"+r,e),o=L(o,"{"+r+"}",e)})),o=o.replace(/\n/g,"<br>")}function z(n,t){var o,r,i,l="",u=!1;if(e.isString(n)&&!t&&n.indexOf(c.delimiter)!==-1&&(i=n.split(c.delimiter),n=i[0],t=e.fromJson(i[1])),u=d(n))if(e.isObject(t)||(t=[t]),o=p(n),o&&!o._loading){if(r=v(n),c.allowNestedJson){for(var s=0;s<r.length-1;s++){if(!o[r[s]]){o=null;break}o=o[r[s]]}r=r[r.length-1]}o[r]?e.isString(o[r])?l=E(o[r],t):(a.info("[localizationService] Key is not a string: "+n+". Is it a nested object?"),l="%%KEY_NOT_STRING%%"):(l="%%KEY_NOT_FOUND%%",l="%%KEY_NOT_FOUND%%")}else o||S(n);else l=n;return l}function y(e){e=e.split("-")[0],T.attr("lang",e)}function k(n){var t=null;if(n&&n.length&&(s.forEach(function(e){if(0===e.indexOf(n))return void(t=e)}),!t)){var o=f[n.split("-")[0]];e.isUndefined(o)||(t=o)}return t||c.defaultLocale}function O(n){var t;e.isString(n)&&n.length?(n=n.trim(),t=k(n)):t=c.defaultLocale,t!==C&&(x={},U={},C=t,y(t),i.$broadcast(u.localeChanges,C),j&&j.put(c.cookieName,t))}function _(){return C}function A(){var n,t,o=l.navigator,r=["language","browserLanguage","systemLanguage","userLanguage"];if(e.isArray(o.languages))for(n=0;n<o.languages.length;n++)if(t=o.languages[n])return t;for(n=0;n<r.length;n++)if(t=o[r[n]])return t;return null}function N(){O(j&&j.get(c.cookieName)?j.get(c.cookieName):A())}var C,U,x,j,P=c.validTokens||new RegExp("^([\\w-]+\\/)*([\\w-]+\\.)+([\\w\\s-])+\\w(:.*)?$"),T=e.element(t.body).parent(),K=c.allowNestedJson?"/":".";return c.persistSelection&&n.has("$cookieStore")&&(j=n.get("$cookieStore")),N(),{ready:w,isToken:d,getPath:h,getKey:v,setLocale:O,getLocale:_,getString:z,getPreferredBrowserLanguage:A}}]),e.module("ngLocalize").filter("i18n",["locale",function(e){var n=function(n,t){return e.getString(n,t)};return n.$stateful=!0,n}]),e.module("ngLocalize.Events",[]).constant("localeEvents",{resourceUpdates:"ngLocalizeResourcesUpdated",localeChanges:"ngLocalizeLocaleChanged"}),e.module("ngLocalize").directive("i18n",["$sce","locale","localeEvents","localeConf",function(n,t,o,r){function a(e,t){t!==e.html()&&e.html(n.getTrustedHtml(t))}function i(e,n,o){t.isToken(n)?t.ready(t.getPath(n)).then(function(){a(e,t.getString(n,o))}):a(e,n)}return function(n,t,a){var l;a.$observe("i18n",function(e,n){e&&e!==n&&i(t,e,l)}),e.forEach(a.$attr,function(e,n){r.observableAttrs.test(e)&&a.$observe(n,function(e){!e&&l&&l[n]||(l=l||{},l[n]=a[n],i(t,a.i18n,l))})}),n.$on(o.resourceUpdates,function(){i(t,a.i18n,l)}),n.$on(o.localeChanges,function(){i(t,a.i18n,l)})}}]).directive("i18nAttr",["$rootScope","locale","localeEvents",function(n,t,o){function r(e,n,t){e.$set(e.$normalize(n),t)}function a(e,n,o){var a={};return function(n){var i,l=e.$eval(n),c=[];for(var u in l)i=l[u],t.isToken(i)&&c.indexOf(t.getPath(i))===-1&&c.push(t.getPath(i));t.ready(c).then(function(){var e="";for(var n in l)i=l[n],e=t.getString(i),a[n]!==e&&(a[n]=e,r(o,n,e))})}}return{priority:1e3,compile:function(t,i){return e.forEach(n.$eval(i.i18nAttr),function(e,n){r(i,n,e||"...")}),function(e,n,t){var r=a(e,n,t);t.$observe("i18nAttr",function(e){e&&r(e)}),e.$on(o.resourceUpdates,function(){r(t.i18nAttr)}),e.$on(o.localeChanges,function(){r(t.i18nAttr)})}}}}]),e.module("ngLocalize.Config",[]).value("localeConf",{basePath:"languages",defaultLocale:"en-US",sharedDictionary:"common",fileExtension:".lang.json",persistSelection:!0,cookieName:"COOKIE_LOCALE_LANG",observableAttrs:new RegExp("^data-(?!ng-|i18n)"),delimiter:"::",validTokens:new RegExp("^([\\w-]+\\/)*([\\w-]+\\.)+([\\w\\s-])+\\w(:.*)?$"),allowNestedJson:!1})}(this.angular,this,this.document);
//# sourceMappingURL=angular-localization-spiria.min.js.map