@angular/localize
Version:
Angular - library for localizing messages
41 lines • 5.35 kB
JavaScript
/**
* @license Angular v10.1.0-next.7
* (c) 2010-2020 Google LLC. https://angular.io/
* License: MIT
*/
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/compiler")):"function"==typeof define&&define.amd?define("@angular/localize",["exports","@angular/compiler"],t):t(((e=e||self).ng=e.ng||{},e.ng.localize={}),e.ng.compiler)}(this,(function(e,t){"use strict";
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/var r=function(e,t){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)};function n(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,a=r.call(e),i=[];try{for(;(void 0===t||t-- >0)&&!(n=a.next()).done;)i.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=a.return)&&r.call(a)}finally{if(o)throw o.error}}return i}function o(e,r,n){for(var o,s={},l=a(e[0],e.raw[0]),c=[l.text],u=[],f=l.text,d=1;d<e.length;d++){var p=i(e[d],e.raw[d]),g=p.text,h=p.block,m=void 0===h?1===(o=d)?"PH":"PH_"+(o-1):h;f+="{$"+m+"}"+g,void 0!==r&&(s[m]=r[d-1]),u.push(m),c.push(g)}var v=l.id||t.computeMsgId(f,l.meaning||""),y=l.legacyIds?l.legacyIds.filter((function(e){return e!==v})):[];return{id:v,legacyIds:y,substitutions:s,text:f,meaning:l.meaning||"",description:l.description||"",messageParts:c,placeholderNames:u,location:n}}function a(e,t){var r=i(e,t),o=r.text,a=r.block;if(void 0===a)return{text:o};var s=n(a.split("␟")),l=s[0],c=s.slice(1),u=n(l.split("@@",2),2),f=u[1],d=n(u[0].split("|",2),2),p=d[0],g=d[1];return void 0===g&&(g=p,p=void 0),""===g&&(g=void 0),{text:o,meaning:p,description:g,id:f,legacyIds:c}}function i(e,t){if(":"!==t.charAt(0))return{text:e};var r=s(e,t);return{block:e.substring(1,r),text:e.substring(r+1)}}function s(e,t){for(var r=1,n=1;r<e.length;r++,n++)if("\\"===t[n])n++;else if(":"===e[r])return r;throw new Error('Unterminated $localize metadata block in "'+t+'".')}var l=function(e){function t(t){var r=e.call(this,"No translation found for "+d(t)+".")||this;return r.parsedMessage=t,r.type="MissingTranslationError",r}return function n(e,t){function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}(t,e),t}(Error);function c(e,t,r){var n=o(t,r),a=e[n.id];if(void 0!==n.legacyIds)for(var i=0;i<n.legacyIds.length&&void 0===a;i++)a=e[n.legacyIds[i]];if(void 0===a)throw new l(n);return[a.messageParts,a.placeholderNames.map((function(e){if(n.substitutions.hasOwnProperty(e))return n.substitutions[e];throw new Error("There is a placeholder name mismatch with the translation provided for the message "+d(n)+".\nThe translation contains a placeholder with name "+e+", which does not exist in the message.")}))]}function u(e){for(var t=e.split(/{\$([^}]*)}/),r=[t[0]],n=[],o=1;o<t.length-1;o+=2)n.push(t[o]),r.push(""+t[o+1]);var a=r.map((function(e){return":"===e.charAt(0)?"\\"+e:e}));return{text:e,messageParts:f(r,a),placeholderNames:n}}function f(e,t){return Object.defineProperty(e,"raw",{value:t}),e}function d(e){var t=e.meaning&&' - "'+e.meaning+'"',r=e.legacyIds&&e.legacyIds.length>0?" ["+e.legacyIds.map((function(e){return'"'+e+'"'})).join(", ")+"]":"";return'"'+e.id+'"'+r+' ("'+e.text+'"'+t+")"}
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/function p(e,t){try{return c($localize.TRANSLATIONS,e,t)}catch(r){return console.warn(r.message),[e,t]}}
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/Object.defineProperty(e,"ɵcomputeMsgId",{enumerable:!0,get:function(){return t.computeMsgId}}),e.clearTranslations=function g(){$localize.translate=void 0,$localize.TRANSLATIONS={}},e.loadTranslations=function h(e){$localize.translate||($localize.translate=p),$localize.TRANSLATIONS||($localize.TRANSLATIONS={}),Object.keys(e).forEach((function(t){$localize.TRANSLATIONS[t]=u(e[t])}))},e.ɵMissingTranslationError=l,e.ɵfindEndOfBlock=s,e.ɵisMissingTranslationError=function m(e){return"MissingTranslationError"===e.type},e.ɵmakeParsedTranslation=function v(e,t){void 0===t&&(t=[]);for(var r=e[0],n=0;n<t.length-1;n++)r+="{$"+t[n]+"}"+e[n+1];return{text:r,messageParts:f(e,e),placeholderNames:t}},e.ɵmakeTemplateObject=f,e.ɵparseMessage=o,e.ɵparseMetadata=a,e.ɵparseTranslation=u,e.ɵsplitBlock=i,e.ɵtranslate=c,Object.defineProperty(e,"__esModule",{value:!0})}));