Socket
Socket
Sign inDemoInstall

@angular/localize

Package Overview
Dependencies
Maintainers
1
Versions
544
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@angular/localize - npm Package Compare versions

Comparing version 9.0.0-next.6 to 9.0.0-next.7

bundles/localize-init.umd.js

512

bundles/localize.umd.js
/**
* @license Angular v9.0.0-next.6
* @license Angular v9.0.0-next.7
* (c) 2010-2019 Google LLC. https://angular.io/

@@ -7,6 +7,7 @@ * License: MIT

(function (factory) {
typeof define === 'function' && define.amd ? define('@angular/localize', factory) :
factory();
}(function () { 'use strict';
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/compiler')) :
typeof define === 'function' && define.amd ? define('@angular/localize', ['exports', '@angular/compiler'], factory) :
(global = global || self, factory((global.ng = global.ng || {}, global.ng.localize = {}), global.ng.compiler));
}(this, function (exports, compiler) { 'use strict';

@@ -20,22 +21,17 @@ /**

*/
var __globalThis = typeof globalThis !== 'undefined' && globalThis;
var __window = typeof window !== 'undefined' && window;
var __self = typeof self !== 'undefined' && typeof WorkerGlobalScope !== 'undefined' &&
self instanceof WorkerGlobalScope && self;
var __global = typeof global !== 'undefined' && global;
// Always use __globalThis if available; this is the spec-defined global variable across all
// environments.
// Then fallback to __global first; in Node tests both __global and __window may be defined.
var _global = __globalThis || __global || __window || __self;
/**
* @license
* Copyright Google Inc. All Rights Reserved.
* The character used to mark the start and end of a "block" in a `$localize` tagged string.
* A block can indicate metadata about the message or specify a name of a placeholder for a
* substitution expressions.
*
* 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
* For example:
*
* ```ts
* $localize`Hello, ${title}:title:!`;
* $localize`:meaning|description@@id:source message text`;
* ```
*/
var PLACEHOLDER_NAME_MARKER = ':';
var BLOCK_MARKER = ':';
/**
* Tag a template literal string for localization.
* The marker used to separate a message's "meaning" from its "description" in a metadata block.
*

@@ -45,94 +41,427 @@ * For example:

* ```ts
* $localize `some string to localize`
* $localize `:correct|Indicates that the user got the answer correct: Right!`;
* $localize `:movement|Button label for moving to the right: Right!`;
* ```
*/
var MEANING_SEPARATOR = '|';
/**
* The marker used to separate a message's custom "id" from its "description" in a metadata block.
*
* **Naming placeholders**
* For example:
*
* If the template literal string contains expressions then you can optionally name the placeholder
* associated with each expression. Do this by providing the placeholder name wrapped in `:`
* characters directly after the expression. These placeholder names are stripped out of the
* rendered localized string.
*
* For example, to name the `item.length` expression placeholder `itemCount` you write:
*
* ```ts
* $localize `There are ${item.length}:itemCount: items`;
* $localize `:A welcome message on the home page@@myApp-homepage-welcome: Welcome!`;
* ```
*/
var ID_SEPARATOR = '@@';
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
/* global Reflect, Promise */
var extendStatics = function(d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
function __extends(d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
}
var __assign = function() {
__assign = Object.assign || function __assign(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
function __rest(s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function")
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0)
t[p[i]] = s[p[i]];
return t;
}
function __decorate(decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
}
function __param(paramIndex, decorator) {
return function (target, key) { decorator(target, key, paramIndex); }
}
function __metadata(metadataKey, metadataValue) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
}
function __awaiter(thisArg, _arguments, P, generator) {
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
}
function __generator(thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
}
function __exportStar(m, exports) {
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
}
function __values(o) {
var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
if (m) return m.call(o);
return {
next: function () {
if (o && i >= o.length) o = void 0;
return { value: o && o[i++], done: !o };
}
};
}
function __read(o, n) {
var m = typeof Symbol === "function" && o[Symbol.iterator];
if (!m) return o;
var i = m.call(o), r, ar = [], e;
try {
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
}
catch (error) { e = { error: error }; }
finally {
try {
if (r && !r.done && (m = i["return"])) m.call(i);
}
finally { if (e) throw e.error; }
}
return ar;
}
function __spread() {
for (var ar = [], i = 0; i < arguments.length; i++)
ar = ar.concat(__read(arguments[i]));
return ar;
}
function __await(v) {
return this instanceof __await ? (this.v = v, this) : new __await(v);
}
function __asyncGenerator(thisArg, _arguments, generator) {
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
var g = generator.apply(thisArg, _arguments || []), i, q = [];
return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
function fulfill(value) { resume("next", value); }
function reject(value) { resume("throw", value); }
function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
}
function __asyncDelegator(o) {
var i, p;
return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
}
function __asyncValues(o) {
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
var m = o[Symbol.asyncIterator], i;
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
}
function __makeTemplateObject(cooked, raw) {
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
return cooked;
};
function __importStar(mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result.default = mod;
return result;
}
function __importDefault(mod) {
return (mod && mod.__esModule) ? mod : { default: mod };
}
/**
* Parse a `$localize` tagged string into a structure that can be used for translation.
*
* If you need to use a `:` character directly an expression you must either provide a name or you
* can escape the `:` by preceding it with a backslash:
* See `ParsedMessage` for an example.
*/
function parseMessage(messageParts, expressions) {
var substitutions = {};
var metadata = parseMetadata(messageParts[0], messageParts.raw[0]);
var messageString = metadata.text;
for (var i = 1; i < messageParts.length; i++) {
var _a = splitBlock(messageParts[i], messageParts.raw[i]), messagePart = _a.text, _b = _a.block, placeholderName = _b === void 0 ? computePlaceholderName(i) : _b;
messageString += "{$" + placeholderName + "}" + messagePart;
if (expressions !== undefined) {
substitutions[placeholderName] = expressions[i - 1];
}
}
return {
messageId: metadata.id || compiler.computeMsgId(messageString, metadata.meaning || ''),
substitutions: substitutions,
messageString: messageString,
};
}
/**
* Parse the given message part (`cooked` + `raw`) to extract the message metadata from the text.
*
* If the message part has a metadata block this function will extract the `meaning`,
* `description` and `id` (if provided) from the block. These metadata properties are serialized in
* the string delimited by `|` and `@@` respectively.
*
* For example:
*
* ```ts
* $localize `${label}:label:: ${}`
* // or
* $localize `${label}\: ${}`
* `:meaning|description@@id`
* `:meaning|@@id`
* `:meaning|description`
* `description@@id`
* `meaning|`
* `description`
* `@@id`
* ```
*
* **Processing localized strings:**
* @param cooked The cooked version of the message part to parse.
* @param raw The raw version of the message part to parse.
* @returns A object containing any metadata that was parsed from the message part.
*/
function parseMetadata(cooked, raw) {
var _a = splitBlock(cooked, raw), text = _a.text, block = _a.block;
if (block === undefined) {
return { text: text, meaning: undefined, description: undefined, id: undefined };
}
else {
var _b = __read(block.split(ID_SEPARATOR, 2), 2), meaningAndDesc = _b[0], id = _b[1];
var _c = __read(meaningAndDesc.split(MEANING_SEPARATOR, 2), 2), meaning = _c[0], description = _c[1];
if (description === undefined) {
description = meaning;
meaning = undefined;
}
if (description === '') {
description = undefined;
}
return { text: text, meaning: meaning, description: description, id: id };
}
}
/**
* Split a message part (`cooked` + `raw`) into an optional delimited "block" off the front and the
* rest of the text of the message part.
*
* There are three scenarios:
* Blocks appear at the start of message parts. They are delimited by a colon `:` character at the
* start and end of the block.
*
* * **compile-time inlining**: the `$localize` tag is transformed at compile time by a transpiler,
* removing the tag and replacing the template literal string with a translated literal string
* from a collection of translations provided to the transpilation tool.
* If the block is in the first message part then it will be metadata about the whole message:
* meaning, description, id. Otherwise it will be metadata about the immediately preceding
* substitution: placeholder name.
*
* * **run-time evaluation**: the `$localize` tag is a run-time function that replaces and reorders
* the parts (static strings and expressions) of the template literal string with strings from a
* collection of translations loaded at run-time.
* Since blocks are optional, it is possible that the content of a message block actually starts
* with a block marker. In this case the marker must be escaped `\:`.
*
* * **pass-through evaluation**: the `$localize` tag is a run-time function that simply evaluates
* the original template literal string without applying any translations to the parts. This version
* is used during development or where there is no need to translate the localized template
* literals.
* @param cooked The cooked version of the message part to parse.
* @param raw The raw version of the message part to parse.
* @returns An object containing the `text` of the message part and the text of the `block`, if it
* exists.
*/
function splitBlock(cooked, raw) {
// Synthesizing AST nodes that represent template literals using the TypeScript API is problematic
// because it doesn't allow for the raw value of messageParts to be programmatically set.
// The result is that synthesized AST nodes have empty `raw` values.
// Normally we rely upon checking the `raw` value to check whether the `BLOCK_MARKER` was escaped
// in the original source. If the `raw` value is missing then we cannot do this.
// In such a case we fall back on the `cooked` version and assume that the `BLOCK_MARKER` was not
// escaped.
// This should be OK because synthesized nodes only come from the Angular template compiler, which
// always provides full id and placeholder name information so it will never escape `BLOCK_MARKER`
// characters.
if ((raw || cooked).charAt(0) !== BLOCK_MARKER) {
return { text: cooked };
}
else {
var endOfBlock = cooked.indexOf(BLOCK_MARKER, 1);
return {
block: cooked.substring(1, endOfBlock),
text: cooked.substring(endOfBlock + 1),
};
}
}
function computePlaceholderName(index) {
return index === 1 ? 'PH' : "PH_" + (index - 1);
}
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* @param messageParts a collection of the static parts of the template string.
* @param expressions a collection of the values of each placeholder in the template string.
* @returns the translated string, with the `messageParts` and `expressions` interleaved together.
* 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 $localize = function (messageParts) {
var expressions = [];
for (var _i = 1; _i < arguments.length; _i++) {
expressions[_i - 1] = arguments[_i];
/**
* Translate the text of the `$localize` tagged-string (i.e. `messageParts` and
* `substitutions`) using the given `translations`.
*
* The tagged-string is parsed to extract its `messageId` which is used to find an appropriate
* `ParsedTranslation`.
*
* If one is found then it is used to translate the message into a new set of `messageParts` and
* `substitutions`.
* The translation may reorder (or remove) substitutions as appropriate.
*
* If no translation matches then an error is thrown.
*/
function translate(translations, messageParts, substitutions) {
var message = parseMessage(messageParts, substitutions);
var translation = translations[message.messageId];
if (translation !== undefined) {
return [
translation.messageParts,
translation.placeholderNames.map(function (placeholder) { return message.substitutions[placeholder]; })
];
}
if ($localize.translate) {
// Don't use array expansion here to avoid the compiler adding `__read()` helper unnecessarily.
var translation = $localize.translate(messageParts, expressions);
messageParts = translation[0];
expressions = translation[1];
else {
throw new Error("No translation found for \"" + message.messageId + "\" (\"" + message.messageString + "\").");
}
var message = messageParts[0];
for (var i = 1; i < messageParts.length; i++) {
message += expressions[i - 1] + stripPlaceholderName(messageParts[i], messageParts.raw[i]);
}
/**
* Parse the `messageParts` and `placeholderNames` out of a target `message`.
*
* Used by `loadTranslations()` to convert target message strings into a structure that is more
* appropriate for doing translation.
*
* @param message the message to be parsed.
*/
function parseTranslation(message) {
var parts = message.split(/{\$([^}]*)}/);
var messageParts = [parts[0]];
var placeholderNames = [];
for (var i = 1; i < parts.length - 1; i += 2) {
placeholderNames.push(parts[i]);
messageParts.push("" + parts[i + 1]);
}
return message;
};
var rawMessageParts = messageParts.map(function (part) { return part.charAt(0) === BLOCK_MARKER ? '\\' + part : part; });
return { messageParts: makeTemplateObject(messageParts, rawMessageParts), placeholderNames: placeholderNames };
}
/**
* Strip the placeholder name from the start of the `messagePart`, if it is found.
* Create the specialized array that is passed to tagged-string tag functions.
*
* Placeholder marker characters (:) may appear after a substitution that does not provide an
* explicit placeholder name. In this case the character must be escaped with a backslash, `\:`.
* We can check for this by looking at the `raw` messagePart, which should still contain the
* backslash.
* @param cooked The message parts with their escape codes processed.
* @param raw The message parts with their escaped codes as-is.
*/
function makeTemplateObject(cooked, raw) {
Object.defineProperty(cooked, 'raw', { value: raw });
return cooked;
}
/**
* Load translations for `$localize`.
*
* If the template literal was synthesized then its raw array will only contain empty strings.
* This is because TS needs the original source code to find the raw text and in the case of
* synthesize AST nodes, there is no source code.
* The given `translations` are processed and added to a lookup based on their `MessageId`.
* A new translation will overwrite a previous translation if it has the same `MessageId`.
*
* The workaround is to assume that the template literal did not contain an escaped placeholder
* name, and fall back on checking the cooked array instead.
* * If a message is generated by the Angular compiler from an `i18n` marker in a template, the
* `MessageId` is passed through to the `$localize` call as a custom `MessageId`. The `MessageId`
* will match what is extracted into translation files.
*
* This should be OK because synthesized nodes (from the Angular template compiler) will always
* provide explicit placeholder names and so will never need to escape placeholder name markers.
* * If the translation is from a call to `$localize` in application code, and no custom `MessageId`
* is provided, then the `MessageId` can be generated by passing the tagged string message-parts
* to the `parseMessage()` function (not currently public API).
*
* @param messagePart The cooked message part to process.
* @param rawMessagePart The raw message part to check.
* @returns the message part with the placeholder name stripped, if found.
* @publicApi
*
*/
function stripPlaceholderName(messagePart, rawMessagePart) {
return (rawMessagePart || messagePart).charAt(0) === PLACEHOLDER_NAME_MARKER ?
messagePart.substring(messagePart.indexOf(PLACEHOLDER_NAME_MARKER, 1) + 1) :
messagePart;
function loadTranslations(translations) {
// Ensure the translate function exists
if (!$localize.translate) {
$localize.translate = translate$1;
}
if (!$localize.TRANSLATIONS) {
$localize.TRANSLATIONS = {};
}
Object.keys(translations).forEach(function (key) {
$localize.TRANSLATIONS[key] = parseTranslation(translations[key]);
});
}
/**
* Remove all translations for `$localize`.
*
* @publicApi
*/
function clearTranslations() {
$localize.TRANSLATIONS = {};
}
/**
* Translate the text of the given message, using the loaded translations.
*
* This function may reorder (or remove) substitutions as indicated in the matching translation.
*/
function translate$1(messageParts, substitutions) {
try {
return translate($localize.TRANSLATIONS, messageParts, substitutions);
}
catch (e) {
console.warn(e.message);
return [messageParts, substitutions];
}
}

@@ -146,6 +475,17 @@ /**

*/
// Attach $localize to the global context, as a side-effect of this module.
_global.$localize = $localize;
/**
* @license
* Copyright Google Inc. 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
*/
exports.clearTranslations = clearTranslations;
exports.loadTranslations = loadTranslations;
Object.defineProperty(exports, '__esModule', { value: true });
}));
//# sourceMappingURL=localize.umd.js.map
/**
* @license Angular v9.0.0-next.6
* @license Angular v9.0.0-next.7
* (c) 2010-2019 Google LLC. https://angular.io/
* License: MIT
*/
!function(e){"function"==typeof define&&define.amd?define("@angular/localize",e):e()}(function(){"use strict";
!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";
/**

@@ -13,3 +13,3 @@ * @license

* found in the LICENSE file at https://angular.io/license
*/var e="undefined"!=typeof globalThis&&globalThis,n="undefined"!=typeof window&&window,o="undefined"!=typeof self&&"undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope&&self,f="undefined"!=typeof global&&global,l=function(e){for(var n=[],o=1;o<arguments.length;o++)n[o-1]=arguments[o];if(l.translate){var f=l.translate(e,n);e=f[0],n=f[1]}for(var i,a=e[0],t=1;t<e.length;t++)a+=n[t-1]+(i=e[t],":"===(e.raw[t]||i).charAt(0)?i.substring(i.indexOf(":",1)+1):i);return a};
*/var r=":",n="|",o="@@";function i(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,i=r.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(n=i.next()).done;)a.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return a}function a(e,t){if((t||e).charAt(0)!==r)return{text:e};var n=e.indexOf(r,1);return{block:e.substring(1,n),text:e.substring(n+1)}}function l(e,r){try{
/**

@@ -22,2 +22,16 @@ * @license

*/
(e||f||n||o).$localize=l});
return function l(e,r,s){var c=function u(e,r){for(var l,s={},c=function u(e,t){var r=a(e,t),l=r.text,s=r.block;if(void 0===s)return{text:l,meaning:void 0,description:void 0,id:void 0};var c=i(s.split(o,2),2),u=c[1],f=i(c[0].split(n,2),2),d=f[0],g=f[1];return void 0===g&&(g=d,d=void 0),""===g&&(g=void 0),{text:l,meaning:d,description:g,id:u}}(e[0],e.raw[0]),f=c.text,d=1;d<e.length;d++){var g=a(e[d],e.raw[d]),p=g.block,v=void 0===p?1===(l=d)?"PH":"PH_"+(l-1):p;f+="{$"+v+"}"+g.text,void 0!==r&&(s[v]=r[d-1])}return{messageId:c.id||t.computeMsgId(f,c.meaning||""),substitutions:s,messageString:f}}(r,s),f=e[c.messageId];if(void 0!==f)return[f.messageParts,f.placeholderNames.map(function(e){return c.substitutions[e]})];throw new Error('No translation found for "'+c.messageId+'" ("'+c.messageString+'").')}($localize.TRANSLATIONS,e,r)}catch(t){return console.warn(t.message),[e,r]}}
/**
* @license
* Copyright Google Inc. 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 Inc. 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
*/e.clearTranslations=function s(){$localize.TRANSLATIONS={}},e.loadTranslations=function c(e){$localize.translate||($localize.translate=l),$localize.TRANSLATIONS||($localize.TRANSLATIONS={}),Object.keys(e).forEach(function(t){$localize.TRANSLATIONS[t]=function n(e){for(var t=e.split(/{\$([^}]*)}/),n=[t[0]],o=[],i=1;i<t.length-1;i+=2)o.push(t[i]),n.push(""+t[i+1]);var a,l,s=n.map(function(e){return e.charAt(0)===r?"\\"+e:e});return{messageParts:(a=n,l=s,Object.defineProperty(a,"raw",{value:l}),a),placeholderNames:o}}(e[t])})},Object.defineProperty(e,"__esModule",{value:!0})});

10

esm2015/index.js

@@ -8,6 +8,6 @@ /**

*/
import { _global } from './src/global';
import { $localize as _localize } from './src/localize';
// Attach $localize to the global context, as a side-effect of this module.
_global.$localize = _localize;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi9wYWNrYWdlcy9sb2NhbGl6ZS9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTs7Ozs7O0dBTUc7QUFDSCxPQUFPLEVBQUMsT0FBTyxFQUFDLE1BQU0sY0FBYyxDQUFDO0FBQ3JDLE9BQU8sRUFBQyxTQUFTLElBQUksU0FBUyxFQUEwQixNQUFNLGdCQUFnQixDQUFDO0FBRS9FLDJFQUEyRTtBQUMzRSxPQUFPLENBQUMsU0FBUyxHQUFHLFNBQVMsQ0FBQyIsInNvdXJjZXNDb250ZW50IjpbIi8qKlxuICogQGxpY2Vuc2VcbiAqIENvcHlyaWdodCBHb29nbGUgSW5jLiBBbGwgUmlnaHRzIFJlc2VydmVkLlxuICpcbiAqIFVzZSBvZiB0aGlzIHNvdXJjZSBjb2RlIGlzIGdvdmVybmVkIGJ5IGFuIE1JVC1zdHlsZSBsaWNlbnNlIHRoYXQgY2FuIGJlXG4gKiBmb3VuZCBpbiB0aGUgTElDRU5TRSBmaWxlIGF0IGh0dHBzOi8vYW5ndWxhci5pby9saWNlbnNlXG4gKi9cbmltcG9ydCB7X2dsb2JhbH0gZnJvbSAnLi9zcmMvZ2xvYmFsJztcbmltcG9ydCB7JGxvY2FsaXplIGFzIF9sb2NhbGl6ZSwgTG9jYWxpemVGbiwgVHJhbnNsYXRlRm59IGZyb20gJy4vc3JjL2xvY2FsaXplJztcblxuLy8gQXR0YWNoICRsb2NhbGl6ZSB0byB0aGUgZ2xvYmFsIGNvbnRleHQsIGFzIGEgc2lkZS1lZmZlY3Qgb2YgdGhpcyBtb2R1bGUuXG5fZ2xvYmFsLiRsb2NhbGl6ZSA9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IGBtZXNzYWdlUGFydHNgIGFuZCBgZXhwcmVzc2lvbnNgIGludGVybGVhdmVkIHRvZ2V0aGVyLlxuICAgKi9cbiAgY29uc3QgJGxvY2FsaXplOiBMb2NhbGl6ZUZuO1xufVxuIl19
// DO NOT ADD public exports to this file.
// The public API exports are specified in the `./localize` module, which is checked by the
// public_api_guard rules
export * from './localize';
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi9wYWNrYWdlcy9sb2NhbGl6ZS9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTs7Ozs7O0dBTUc7QUFFSCwwQ0FBMEM7QUFDMUMsMkZBQTJGO0FBQzNGLHlCQUF5QjtBQUV6QixjQUFjLFlBQVksQ0FBQyIsInNvdXJjZXNDb250ZW50IjpbIi8qKlxuICogQGxpY2Vuc2VcbiAqIENvcHlyaWdodCBHb29nbGUgSW5jLiBBbGwgUmlnaHRzIFJlc2VydmVkLlxuICpcbiAqIFVzZSBvZiB0aGlzIHNvdXJjZSBjb2RlIGlzIGdvdmVybmVkIGJ5IGFuIE1JVC1zdHlsZSBsaWNlbnNlIHRoYXQgY2FuIGJlXG4gKiBmb3VuZCBpbiB0aGUgTElDRU5TRSBmaWxlIGF0IGh0dHBzOi8vYW5ndWxhci5pby9saWNlbnNlXG4gKi9cblxuLy8gRE8gTk9UIEFERCBwdWJsaWMgZXhwb3J0cyB0byB0aGlzIGZpbGUuXG4vLyBUaGUgcHVibGljIEFQSSBleHBvcnRzIGFyZSBzcGVjaWZpZWQgaW4gdGhlIGAuL2xvY2FsaXplYCBtb2R1bGUsIHdoaWNoIGlzIGNoZWNrZWQgYnkgdGhlXG4vLyBwdWJsaWNfYXBpX2d1YXJkIHJ1bGVzXG5cbmV4cG9ydCAqIGZyb20gJy4vbG9jYWxpemUnO1xuIl19

@@ -8,6 +8,6 @@ /**

*/
import { _global } from './src/global';
import { $localize as _localize } from './src/localize';
// Attach $localize to the global context, as a side-effect of this module.
_global.$localize = _localize;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi8uLi8uLi8uLi9wYWNrYWdlcy9sb2NhbGl6ZS9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTs7Ozs7O0dBTUc7QUFDSCxPQUFPLEVBQUMsT0FBTyxFQUFDLE1BQU0sY0FBYyxDQUFDO0FBQ3JDLE9BQU8sRUFBQyxTQUFTLElBQUksU0FBUyxFQUEwQixNQUFNLGdCQUFnQixDQUFDO0FBRS9FLDJFQUEyRTtBQUMzRSxPQUFPLENBQUMsU0FBUyxHQUFHLFNBQVMsQ0FBQyIsInNvdXJjZXNDb250ZW50IjpbIi8qKlxuICogQGxpY2Vuc2VcbiAqIENvcHlyaWdodCBHb29nbGUgSW5jLiBBbGwgUmlnaHRzIFJlc2VydmVkLlxuICpcbiAqIFVzZSBvZiB0aGlzIHNvdXJjZSBjb2RlIGlzIGdvdmVybmVkIGJ5IGFuIE1JVC1zdHlsZSBsaWNlbnNlIHRoYXQgY2FuIGJlXG4gKiBmb3VuZCBpbiB0aGUgTElDRU5TRSBmaWxlIGF0IGh0dHBzOi8vYW5ndWxhci5pby9saWNlbnNlXG4gKi9cbmltcG9ydCB7X2dsb2JhbH0gZnJvbSAnLi9zcmMvZ2xvYmFsJztcbmltcG9ydCB7JGxvY2FsaXplIGFzIF9sb2NhbGl6ZSwgTG9jYWxpemVGbiwgVHJhbnNsYXRlRm59IGZyb20gJy4vc3JjL2xvY2FsaXplJztcblxuLy8gQXR0YWNoICRsb2NhbGl6ZSB0byB0aGUgZ2xvYmFsIGNvbnRleHQsIGFzIGEgc2lkZS1lZmZlY3Qgb2YgdGhpcy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0aGUgdHJhbnNsYXRlZCBzdHJpbmcsIHdpdGggdGhlIGBtZXNzYWdlUGFydHNgIGFuZCBgZXhwcmVzc2lvbnNgIGludGVybGVhdmVkIHRvZ2V0aGVyLlxuICAgKi9cbiAgY29uc3QgJGxvY2FsaXplOiBMb2NhbGl6ZUZuO1xufVxuIl19
// DO NOT ADD public exports to this file.
// The public API exports are specified in the `./localize` module, which is checked by the
// public_api_guard rules
export * from './localize';
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi8uLi8uLi8uLi9wYWNrYWdlcy9sb2NhbGl6ZS9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTs7Ozs7O0dBTUc7QUFFSCwwQ0FBMEM7QUFDMUMsMkZBQTJGO0FBQzNGLHlCQUF5QjtBQUV6QixjQUFjLFlBQVksQ0FBQyIsInNvdXJjZXNDb250ZW50IjpbIi8qKlxuICogQGxpY2Vuc2VcbiAqIENvcHlyaWdodCBHb29nbGUgSW5jLiBBbGwgUmlnaHRzIFJlc2VydmVkLlxuICpcbiAqIFVzZSBvZiB0aGlzIHNvdXJjZSBjb2RlIGlzIGdvdmVybmVkIGJ5IGFuIE1JVC1zdHlsZSBsaWNlbnNlIHRoYXQgY2FuIGJlXG4gKiBmb3VuZCBpbiB0aGUgTElDRU5TRSBmaWxlIGF0IGh0dHBzOi8vYW5ndWxhci5pby9saWNlbnNlXG4gKi9cblxuLy8gRE8gTk9UIEFERCBwdWJsaWMgZXhwb3J0cyB0byB0aGlzIGZpbGUuXG4vLyBUaGUgcHVibGljIEFQSSBleHBvcnRzIGFyZSBzcGVjaWZpZWQgaW4gdGhlIGAuL2xvY2FsaXplYCBtb2R1bGUsIHdoaWNoIGlzIGNoZWNrZWQgYnkgdGhlXG4vLyBwdWJsaWNfYXBpX2d1YXJkIHJ1bGVzXG5cbmV4cG9ydCAqIGZyb20gJy4vbG9jYWxpemUnO1xuIl19
/**
* @license Angular v9.0.0-next.6
* @license Angular v9.0.0-next.7
* (c) 2010-2019 Google LLC. https://angular.io/

@@ -7,2 +7,4 @@ * License: MIT

import { computeMsgId } from '@angular/compiler';
/**

@@ -15,22 +17,17 @@ * @license

*/
const __globalThis = typeof globalThis !== 'undefined' && globalThis;
const __window = typeof window !== 'undefined' && window;
const __self = typeof self !== 'undefined' && typeof WorkerGlobalScope !== 'undefined' &&
self instanceof WorkerGlobalScope && self;
const __global = typeof global !== 'undefined' && global;
// Always use __globalThis if available; this is the spec-defined global variable across all
// environments.
// Then fallback to __global first; in Node tests both __global and __window may be defined.
const _global = __globalThis || __global || __window || __self;
/**
* @license
* Copyright Google Inc. All Rights Reserved.
* The character used to mark the start and end of a "block" in a `$localize` tagged string.
* A block can indicate metadata about the message or specify a name of a placeholder for a
* substitution expressions.
*
* 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
* For example:
*
* ```ts
* $localize`Hello, ${title}:title:!`;
* $localize`:meaning|description@@id:source message text`;
* ```
*/
const PLACEHOLDER_NAME_MARKER = ':';
const BLOCK_MARKER = ':';
/**
* Tag a template literal string for localization.
* The marker used to separate a message's "meaning" from its "description" in a metadata block.
*

@@ -40,90 +37,247 @@ * For example:

* ```ts
* $localize `some string to localize`
* $localize `:correct|Indicates that the user got the answer correct: Right!`;
* $localize `:movement|Button label for moving to the right: Right!`;
* ```
*/
const MEANING_SEPARATOR = '|';
/**
* The marker used to separate a message's custom "id" from its "description" in a metadata block.
*
* **Naming placeholders**
* For example:
*
* If the template literal string contains expressions then you can optionally name the placeholder
* associated with each expression. Do this by providing the placeholder name wrapped in `:`
* characters directly after the expression. These placeholder names are stripped out of the
* rendered localized string.
*
* For example, to name the `item.length` expression placeholder `itemCount` you write:
*
* ```ts
* $localize `There are ${item.length}:itemCount: items`;
* $localize `:A welcome message on the home page@@myApp-homepage-welcome: Welcome!`;
* ```
*/
const ID_SEPARATOR = '@@';
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* If you need to use a `:` character directly an expression you must either provide a name or you
* can escape the `:` by preceding it with a backslash:
* 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
*/
/**
* Parse a `$localize` tagged string into a structure that can be used for translation.
*
* See `ParsedMessage` for an example.
*/
function parseMessage(messageParts, expressions) {
const substitutions = {};
const metadata = parseMetadata(messageParts[0], messageParts.raw[0]);
let messageString = metadata.text;
for (let i = 1; i < messageParts.length; i++) {
const { text: messagePart, block: placeholderName = computePlaceholderName(i) } = splitBlock(messageParts[i], messageParts.raw[i]);
messageString += `{$${placeholderName}}${messagePart}`;
if (expressions !== undefined) {
substitutions[placeholderName] = expressions[i - 1];
}
}
return {
messageId: metadata.id || computeMsgId(messageString, metadata.meaning || ''),
substitutions,
messageString,
};
}
/**
* Parse the given message part (`cooked` + `raw`) to extract the message metadata from the text.
*
* If the message part has a metadata block this function will extract the `meaning`,
* `description` and `id` (if provided) from the block. These metadata properties are serialized in
* the string delimited by `|` and `@@` respectively.
*
* For example:
*
* ```ts
* $localize `${label}:label:: ${}`
* // or
* $localize `${label}\: ${}`
* `:meaning|description@@id`
* `:meaning|@@id`
* `:meaning|description`
* `description@@id`
* `meaning|`
* `description`
* `@@id`
* ```
*
* **Processing localized strings:**
* @param cooked The cooked version of the message part to parse.
* @param raw The raw version of the message part to parse.
* @returns A object containing any metadata that was parsed from the message part.
*/
function parseMetadata(cooked, raw) {
const { text, block } = splitBlock(cooked, raw);
if (block === undefined) {
return { text, meaning: undefined, description: undefined, id: undefined };
}
else {
const [meaningAndDesc, id] = block.split(ID_SEPARATOR, 2);
let [meaning, description] = meaningAndDesc.split(MEANING_SEPARATOR, 2);
if (description === undefined) {
description = meaning;
meaning = undefined;
}
if (description === '') {
description = undefined;
}
return { text, meaning, description, id };
}
}
/**
* Split a message part (`cooked` + `raw`) into an optional delimited "block" off the front and the
* rest of the text of the message part.
*
* There are three scenarios:
* Blocks appear at the start of message parts. They are delimited by a colon `:` character at the
* start and end of the block.
*
* * **compile-time inlining**: the `$localize` tag is transformed at compile time by a transpiler,
* removing the tag and replacing the template literal string with a translated literal string
* from a collection of translations provided to the transpilation tool.
* If the block is in the first message part then it will be metadata about the whole message:
* meaning, description, id. Otherwise it will be metadata about the immediately preceding
* substitution: placeholder name.
*
* * **run-time evaluation**: the `$localize` tag is a run-time function that replaces and reorders
* the parts (static strings and expressions) of the template literal string with strings from a
* collection of translations loaded at run-time.
* Since blocks are optional, it is possible that the content of a message block actually starts
* with a block marker. In this case the marker must be escaped `\:`.
*
* * **pass-through evaluation**: the `$localize` tag is a run-time function that simply evaluates
* the original template literal string without applying any translations to the parts. This version
* is used during development or where there is no need to translate the localized template
* literals.
* @param cooked The cooked version of the message part to parse.
* @param raw The raw version of the message part to parse.
* @returns An object containing the `text` of the message part and the text of the `block`, if it
* exists.
*/
function splitBlock(cooked, raw) {
// Synthesizing AST nodes that represent template literals using the TypeScript API is problematic
// because it doesn't allow for the raw value of messageParts to be programmatically set.
// The result is that synthesized AST nodes have empty `raw` values.
// Normally we rely upon checking the `raw` value to check whether the `BLOCK_MARKER` was escaped
// in the original source. If the `raw` value is missing then we cannot do this.
// In such a case we fall back on the `cooked` version and assume that the `BLOCK_MARKER` was not
// escaped.
// This should be OK because synthesized nodes only come from the Angular template compiler, which
// always provides full id and placeholder name information so it will never escape `BLOCK_MARKER`
// characters.
if ((raw || cooked).charAt(0) !== BLOCK_MARKER) {
return { text: cooked };
}
else {
const endOfBlock = cooked.indexOf(BLOCK_MARKER, 1);
return {
block: cooked.substring(1, endOfBlock),
text: cooked.substring(endOfBlock + 1),
};
}
}
function computePlaceholderName(index) {
return index === 1 ? 'PH' : `PH_${index - 1}`;
}
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* @param messageParts a collection of the static parts of the template string.
* @param expressions a collection of the values of each placeholder in the template string.
* @returns the translated string, with the `messageParts` and `expressions` interleaved together.
* 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
*/
const $localize = function (messageParts, ...expressions) {
if ($localize.translate) {
// Don't use array expansion here to avoid the compiler adding `__read()` helper unnecessarily.
const translation = $localize.translate(messageParts, expressions);
messageParts = translation[0];
expressions = translation[1];
/**
* Translate the text of the `$localize` tagged-string (i.e. `messageParts` and
* `substitutions`) using the given `translations`.
*
* The tagged-string is parsed to extract its `messageId` which is used to find an appropriate
* `ParsedTranslation`.
*
* If one is found then it is used to translate the message into a new set of `messageParts` and
* `substitutions`.
* The translation may reorder (or remove) substitutions as appropriate.
*
* If no translation matches then an error is thrown.
*/
function translate(translations, messageParts, substitutions) {
const message = parseMessage(messageParts, substitutions);
const translation = translations[message.messageId];
if (translation !== undefined) {
return [
translation.messageParts,
translation.placeholderNames.map(placeholder => message.substitutions[placeholder])
];
}
let message = messageParts[0];
for (let i = 1; i < messageParts.length; i++) {
message += expressions[i - 1] + stripPlaceholderName(messageParts[i], messageParts.raw[i]);
else {
throw new Error(`No translation found for "${message.messageId}" ("${message.messageString}").`);
}
return message;
};
}
/**
* Strip the placeholder name from the start of the `messagePart`, if it is found.
* Parse the `messageParts` and `placeholderNames` out of a target `message`.
*
* Placeholder marker characters (:) may appear after a substitution that does not provide an
* explicit placeholder name. In this case the character must be escaped with a backslash, `\:`.
* We can check for this by looking at the `raw` messagePart, which should still contain the
* backslash.
* Used by `loadTranslations()` to convert target message strings into a structure that is more
* appropriate for doing translation.
*
* If the template literal was synthesized then its raw array will only contain empty strings.
* This is because TS needs the original source code to find the raw text and in the case of
* synthesize AST nodes, there is no source code.
* @param message the message to be parsed.
*/
function parseTranslation(message) {
const parts = message.split(/{\$([^}]*)}/);
const messageParts = [parts[0]];
const placeholderNames = [];
for (let i = 1; i < parts.length - 1; i += 2) {
placeholderNames.push(parts[i]);
messageParts.push(`${parts[i + 1]}`);
}
const rawMessageParts = messageParts.map(part => part.charAt(0) === BLOCK_MARKER ? '\\' + part : part);
return { messageParts: makeTemplateObject(messageParts, rawMessageParts), placeholderNames };
}
/**
* Create the specialized array that is passed to tagged-string tag functions.
*
* The workaround is to assume that the template literal did not contain an escaped placeholder
* name, and fall back on checking the cooked array instead.
* @param cooked The message parts with their escape codes processed.
* @param raw The message parts with their escaped codes as-is.
*/
function makeTemplateObject(cooked, raw) {
Object.defineProperty(cooked, 'raw', { value: raw });
return cooked;
}
/**
* Load translations for `$localize`.
*
* This should be OK because synthesized nodes (from the Angular template compiler) will always
* provide explicit placeholder names and so will never need to escape placeholder name markers.
* The given `translations` are processed and added to a lookup based on their `MessageId`.
* A new translation will overwrite a previous translation if it has the same `MessageId`.
*
* @param messagePart The cooked message part to process.
* @param rawMessagePart The raw message part to check.
* @returns the message part with the placeholder name stripped, if found.
* * If a message is generated by the Angular compiler from an `i18n` marker in a template, the
* `MessageId` is passed through to the `$localize` call as a custom `MessageId`. The `MessageId`
* will match what is extracted into translation files.
*
* * If the translation is from a call to `$localize` in application code, and no custom `MessageId`
* is provided, then the `MessageId` can be generated by passing the tagged string message-parts
* to the `parseMessage()` function (not currently public API).
*
* @publicApi
*
*/
function stripPlaceholderName(messagePart, rawMessagePart) {
return (rawMessagePart || messagePart).charAt(0) === PLACEHOLDER_NAME_MARKER ?
messagePart.substring(messagePart.indexOf(PLACEHOLDER_NAME_MARKER, 1) + 1) :
messagePart;
function loadTranslations(translations) {
// Ensure the translate function exists
if (!$localize.translate) {
$localize.translate = translate$1;
}
if (!$localize.TRANSLATIONS) {
$localize.TRANSLATIONS = {};
}
Object.keys(translations).forEach(key => {
$localize.TRANSLATIONS[key] = parseTranslation(translations[key]);
});
}
/**
* Remove all translations for `$localize`.
*
* @publicApi
*/
function clearTranslations() {
$localize.TRANSLATIONS = {};
}
/**
* Translate the text of the given message, using the loaded translations.
*
* This function may reorder (or remove) substitutions as indicated in the matching translation.
*/
function translate$1(messageParts, substitutions) {
try {
return translate($localize.TRANSLATIONS, messageParts, substitutions);
}
catch (e) {
console.warn(e.message);
return [messageParts, substitutions];
}
}

@@ -137,4 +291,12 @@ /**

*/
// Attach $localize to the global context, as a side-effect of this module.
_global.$localize = $localize;
/**
* @license
* Copyright Google Inc. 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
*/
export { clearTranslations, loadTranslations };
//# sourceMappingURL=localize.js.map
/**
* @license Angular v9.0.0-next.6
* @license Angular v9.0.0-next.7
* (c) 2010-2019 Google LLC. https://angular.io/

@@ -7,2 +7,5 @@ * License: MIT

import { __read } from 'tslib';
import { computeMsgId } from '@angular/compiler';
/**

@@ -15,22 +18,17 @@ * @license

*/
var __globalThis = typeof globalThis !== 'undefined' && globalThis;
var __window = typeof window !== 'undefined' && window;
var __self = typeof self !== 'undefined' && typeof WorkerGlobalScope !== 'undefined' &&
self instanceof WorkerGlobalScope && self;
var __global = typeof global !== 'undefined' && global;
// Always use __globalThis if available; this is the spec-defined global variable across all
// environments.
// Then fallback to __global first; in Node tests both __global and __window may be defined.
var _global = __globalThis || __global || __window || __self;
/**
* @license
* Copyright Google Inc. All Rights Reserved.
* The character used to mark the start and end of a "block" in a `$localize` tagged string.
* A block can indicate metadata about the message or specify a name of a placeholder for a
* substitution expressions.
*
* 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
* For example:
*
* ```ts
* $localize`Hello, ${title}:title:!`;
* $localize`:meaning|description@@id:source message text`;
* ```
*/
var PLACEHOLDER_NAME_MARKER = ':';
var BLOCK_MARKER = ':';
/**
* Tag a template literal string for localization.
* The marker used to separate a message's "meaning" from its "description" in a metadata block.
*

@@ -40,94 +38,240 @@ * For example:

* ```ts
* $localize `some string to localize`
* $localize `:correct|Indicates that the user got the answer correct: Right!`;
* $localize `:movement|Button label for moving to the right: Right!`;
* ```
*/
var MEANING_SEPARATOR = '|';
/**
* The marker used to separate a message's custom "id" from its "description" in a metadata block.
*
* **Naming placeholders**
* For example:
*
* If the template literal string contains expressions then you can optionally name the placeholder
* associated with each expression. Do this by providing the placeholder name wrapped in `:`
* characters directly after the expression. These placeholder names are stripped out of the
* rendered localized string.
*
* For example, to name the `item.length` expression placeholder `itemCount` you write:
*
* ```ts
* $localize `There are ${item.length}:itemCount: items`;
* $localize `:A welcome message on the home page@@myApp-homepage-welcome: Welcome!`;
* ```
*/
var ID_SEPARATOR = '@@';
/**
* Parse a `$localize` tagged string into a structure that can be used for translation.
*
* If you need to use a `:` character directly an expression you must either provide a name or you
* can escape the `:` by preceding it with a backslash:
* See `ParsedMessage` for an example.
*/
function parseMessage(messageParts, expressions) {
var substitutions = {};
var metadata = parseMetadata(messageParts[0], messageParts.raw[0]);
var messageString = metadata.text;
for (var i = 1; i < messageParts.length; i++) {
var _a = splitBlock(messageParts[i], messageParts.raw[i]), messagePart = _a.text, _b = _a.block, placeholderName = _b === void 0 ? computePlaceholderName(i) : _b;
messageString += "{$" + placeholderName + "}" + messagePart;
if (expressions !== undefined) {
substitutions[placeholderName] = expressions[i - 1];
}
}
return {
messageId: metadata.id || computeMsgId(messageString, metadata.meaning || ''),
substitutions: substitutions,
messageString: messageString,
};
}
/**
* Parse the given message part (`cooked` + `raw`) to extract the message metadata from the text.
*
* If the message part has a metadata block this function will extract the `meaning`,
* `description` and `id` (if provided) from the block. These metadata properties are serialized in
* the string delimited by `|` and `@@` respectively.
*
* For example:
*
* ```ts
* $localize `${label}:label:: ${}`
* // or
* $localize `${label}\: ${}`
* `:meaning|description@@id`
* `:meaning|@@id`
* `:meaning|description`
* `description@@id`
* `meaning|`
* `description`
* `@@id`
* ```
*
* **Processing localized strings:**
* @param cooked The cooked version of the message part to parse.
* @param raw The raw version of the message part to parse.
* @returns A object containing any metadata that was parsed from the message part.
*/
function parseMetadata(cooked, raw) {
var _a = splitBlock(cooked, raw), text = _a.text, block = _a.block;
if (block === undefined) {
return { text: text, meaning: undefined, description: undefined, id: undefined };
}
else {
var _b = __read(block.split(ID_SEPARATOR, 2), 2), meaningAndDesc = _b[0], id = _b[1];
var _c = __read(meaningAndDesc.split(MEANING_SEPARATOR, 2), 2), meaning = _c[0], description = _c[1];
if (description === undefined) {
description = meaning;
meaning = undefined;
}
if (description === '') {
description = undefined;
}
return { text: text, meaning: meaning, description: description, id: id };
}
}
/**
* Split a message part (`cooked` + `raw`) into an optional delimited "block" off the front and the
* rest of the text of the message part.
*
* There are three scenarios:
* Blocks appear at the start of message parts. They are delimited by a colon `:` character at the
* start and end of the block.
*
* * **compile-time inlining**: the `$localize` tag is transformed at compile time by a transpiler,
* removing the tag and replacing the template literal string with a translated literal string
* from a collection of translations provided to the transpilation tool.
* If the block is in the first message part then it will be metadata about the whole message:
* meaning, description, id. Otherwise it will be metadata about the immediately preceding
* substitution: placeholder name.
*
* * **run-time evaluation**: the `$localize` tag is a run-time function that replaces and reorders
* the parts (static strings and expressions) of the template literal string with strings from a
* collection of translations loaded at run-time.
* Since blocks are optional, it is possible that the content of a message block actually starts
* with a block marker. In this case the marker must be escaped `\:`.
*
* * **pass-through evaluation**: the `$localize` tag is a run-time function that simply evaluates
* the original template literal string without applying any translations to the parts. This version
* is used during development or where there is no need to translate the localized template
* literals.
* @param cooked The cooked version of the message part to parse.
* @param raw The raw version of the message part to parse.
* @returns An object containing the `text` of the message part and the text of the `block`, if it
* exists.
*/
function splitBlock(cooked, raw) {
// Synthesizing AST nodes that represent template literals using the TypeScript API is problematic
// because it doesn't allow for the raw value of messageParts to be programmatically set.
// The result is that synthesized AST nodes have empty `raw` values.
// Normally we rely upon checking the `raw` value to check whether the `BLOCK_MARKER` was escaped
// in the original source. If the `raw` value is missing then we cannot do this.
// In such a case we fall back on the `cooked` version and assume that the `BLOCK_MARKER` was not
// escaped.
// This should be OK because synthesized nodes only come from the Angular template compiler, which
// always provides full id and placeholder name information so it will never escape `BLOCK_MARKER`
// characters.
if ((raw || cooked).charAt(0) !== BLOCK_MARKER) {
return { text: cooked };
}
else {
var endOfBlock = cooked.indexOf(BLOCK_MARKER, 1);
return {
block: cooked.substring(1, endOfBlock),
text: cooked.substring(endOfBlock + 1),
};
}
}
function computePlaceholderName(index) {
return index === 1 ? 'PH' : "PH_" + (index - 1);
}
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* @param messageParts a collection of the static parts of the template string.
* @param expressions a collection of the values of each placeholder in the template string.
* @returns the translated string, with the `messageParts` and `expressions` interleaved together.
* 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 $localize = function (messageParts) {
var expressions = [];
for (var _i = 1; _i < arguments.length; _i++) {
expressions[_i - 1] = arguments[_i];
/**
* Translate the text of the `$localize` tagged-string (i.e. `messageParts` and
* `substitutions`) using the given `translations`.
*
* The tagged-string is parsed to extract its `messageId` which is used to find an appropriate
* `ParsedTranslation`.
*
* If one is found then it is used to translate the message into a new set of `messageParts` and
* `substitutions`.
* The translation may reorder (or remove) substitutions as appropriate.
*
* If no translation matches then an error is thrown.
*/
function translate(translations, messageParts, substitutions) {
var message = parseMessage(messageParts, substitutions);
var translation = translations[message.messageId];
if (translation !== undefined) {
return [
translation.messageParts,
translation.placeholderNames.map(function (placeholder) { return message.substitutions[placeholder]; })
];
}
if ($localize.translate) {
// Don't use array expansion here to avoid the compiler adding `__read()` helper unnecessarily.
var translation = $localize.translate(messageParts, expressions);
messageParts = translation[0];
expressions = translation[1];
else {
throw new Error("No translation found for \"" + message.messageId + "\" (\"" + message.messageString + "\").");
}
var message = messageParts[0];
for (var i = 1; i < messageParts.length; i++) {
message += expressions[i - 1] + stripPlaceholderName(messageParts[i], messageParts.raw[i]);
}
/**
* Parse the `messageParts` and `placeholderNames` out of a target `message`.
*
* Used by `loadTranslations()` to convert target message strings into a structure that is more
* appropriate for doing translation.
*
* @param message the message to be parsed.
*/
function parseTranslation(message) {
var parts = message.split(/{\$([^}]*)}/);
var messageParts = [parts[0]];
var placeholderNames = [];
for (var i = 1; i < parts.length - 1; i += 2) {
placeholderNames.push(parts[i]);
messageParts.push("" + parts[i + 1]);
}
return message;
};
var rawMessageParts = messageParts.map(function (part) { return part.charAt(0) === BLOCK_MARKER ? '\\' + part : part; });
return { messageParts: makeTemplateObject(messageParts, rawMessageParts), placeholderNames: placeholderNames };
}
/**
* Strip the placeholder name from the start of the `messagePart`, if it is found.
* Create the specialized array that is passed to tagged-string tag functions.
*
* Placeholder marker characters (:) may appear after a substitution that does not provide an
* explicit placeholder name. In this case the character must be escaped with a backslash, `\:`.
* We can check for this by looking at the `raw` messagePart, which should still contain the
* backslash.
* @param cooked The message parts with their escape codes processed.
* @param raw The message parts with their escaped codes as-is.
*/
function makeTemplateObject(cooked, raw) {
Object.defineProperty(cooked, 'raw', { value: raw });
return cooked;
}
/**
* Load translations for `$localize`.
*
* If the template literal was synthesized then its raw array will only contain empty strings.
* This is because TS needs the original source code to find the raw text and in the case of
* synthesize AST nodes, there is no source code.
* The given `translations` are processed and added to a lookup based on their `MessageId`.
* A new translation will overwrite a previous translation if it has the same `MessageId`.
*
* The workaround is to assume that the template literal did not contain an escaped placeholder
* name, and fall back on checking the cooked array instead.
* * If a message is generated by the Angular compiler from an `i18n` marker in a template, the
* `MessageId` is passed through to the `$localize` call as a custom `MessageId`. The `MessageId`
* will match what is extracted into translation files.
*
* This should be OK because synthesized nodes (from the Angular template compiler) will always
* provide explicit placeholder names and so will never need to escape placeholder name markers.
* * If the translation is from a call to `$localize` in application code, and no custom `MessageId`
* is provided, then the `MessageId` can be generated by passing the tagged string message-parts
* to the `parseMessage()` function (not currently public API).
*
* @param messagePart The cooked message part to process.
* @param rawMessagePart The raw message part to check.
* @returns the message part with the placeholder name stripped, if found.
* @publicApi
*
*/
function stripPlaceholderName(messagePart, rawMessagePart) {
return (rawMessagePart || messagePart).charAt(0) === PLACEHOLDER_NAME_MARKER ?
messagePart.substring(messagePart.indexOf(PLACEHOLDER_NAME_MARKER, 1) + 1) :
messagePart;
function loadTranslations(translations) {
// Ensure the translate function exists
if (!$localize.translate) {
$localize.translate = translate$1;
}
if (!$localize.TRANSLATIONS) {
$localize.TRANSLATIONS = {};
}
Object.keys(translations).forEach(function (key) {
$localize.TRANSLATIONS[key] = parseTranslation(translations[key]);
});
}
/**
* Remove all translations for `$localize`.
*
* @publicApi
*/
function clearTranslations() {
$localize.TRANSLATIONS = {};
}
/**
* Translate the text of the given message, using the loaded translations.
*
* This function may reorder (or remove) substitutions as indicated in the matching translation.
*/
function translate$1(messageParts, substitutions) {
try {
return translate($localize.TRANSLATIONS, messageParts, substitutions);
}
catch (e) {
console.warn(e.message);
return [messageParts, substitutions];
}
}

@@ -141,4 +285,12 @@ /**

*/
// Attach $localize to the global context, as a side-effect of this module.
_global.$localize = $localize;
/**
* @license
* Copyright Google Inc. 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
*/
export { clearTranslations, loadTranslations };
//# sourceMappingURL=localize.js.map

@@ -1,63 +0,8 @@

import { LocalizeFn, TranslateFn } from './src/localize';
export { LocalizeFn, TranslateFn };
declare global {
/**
* Tag a template literal string for localization.
*
* For example:
*
* ```ts
* $localize `some string to localize`
* ```
*
* **Naming placeholders**
*
* If the template literal string contains expressions then you can optionally name the
* placeholder
* associated with each expression. Do this by providing the placeholder name wrapped in `:`
* characters directly after the expression. These placeholder names are stripped out of the
* rendered localized string.
*
* For example, to name the `item.length` expression placeholder `itemCount` you write:
*
* ```ts
* $localize `There are ${item.length}:itemCount: items`;
* ```
*
* If you need to use a `:` character directly an expression you must either provide a name or you
* can escape the `:` by preceding it with a backslash:
*
* For example:
*
* ```ts
* $localize `${label}:label:: ${}`
* // or
* $localize `${label}\: ${}`
* ```
*
* **Processing localized strings:**
*
* There are three scenarios:
*
* * **compile-time inlining**: the `$localize` tag is transformed at compile time by a
* transpiler,
* removing the tag and replacing the template literal string with a translated literal string
* from a collection of translations provided to the transpilation tool.
*
* * **run-time evaluation**: the `$localize` tag is a run-time function that replaces and
* reorders
* the parts (static strings and expressions) of the template literal string with strings from a
* collection of translations loaded at run-time.
*
* * **pass-through evaluation**: the `$localize` tag is a run-time function that simply evaluates
* the original template literal string without applying any translations to the parts. This
* version
* is used during development or where there is no need to translate the localized template
* literals.
*
* @param messageParts a collection of the static parts of the template string.
* @param expressions a collection of the values of each placeholder in the template string.
* @returns the translated string, with the `messageParts` and `expressions` interleaved together.
*/
const $localize: LocalizeFn;
}
/**
* @license
* Copyright Google Inc. 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
*/
export * from './localize';
{
"name": "@angular/localize",
"version": "9.0.0-next.6",
"version": "9.0.0-next.7",
"description": "Angular - library for localizing messages",

@@ -8,4 +8,4 @@ "main": "./bundles/localize.umd.js",

"es2015": "./fesm2015/localize.js",
"esm5": "./esm5/localize.js",
"esm2015": "./esm2015/localize.js",
"esm5": "./esm5/index.js",
"esm2015": "./esm2015/index.js",
"fesm5": "./fesm5/localize.js",

@@ -41,3 +41,7 @@ "fesm2015": "./fesm2015/localize.js",

},
"sideEffects": true,
"sideEffects": [
"**/init/index.js",
"**/init.js",
"**/localize-init.umd.js"
],
"engines": {

@@ -44,0 +48,0 @@ "node": ">=8.0"

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc