🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

@angular/localize

Package Overview
Dependencies
Maintainers
2
Versions
777
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
22.0.0-next.2
to
22.0.0-next.3
+672
tools/bundles/chunk-7PXQZPIU.js
import {createRequire as __cjsCompatRequire} from 'module';
const require = __cjsCompatRequire(import.meta.url);
import {
Diagnostics,
buildCodeFrameError,
buildLocalizeReplacement,
isBabelParseError,
isLocalize,
makeParsedTranslation,
parseTranslation,
translate,
unwrapMessagePartsFromLocalizeCall,
unwrapMessagePartsFromTemplateLiteral,
unwrapSubstitutionsFromLocalizeCall
} from "./chunk-BNVRZOYA.js";
// packages/localize/tools/src/translate/source_files/es2015_translate_plugin.js
import { getFileSystem } from "@angular/compiler-cli/private/localize";
function makeEs2015TranslatePlugin(diagnostics, translations, { missingTranslation = "error", localizeName = "$localize" } = {}, fs = getFileSystem()) {
return {
visitor: {
TaggedTemplateExpression(path, state) {
try {
const tag = path.get("tag");
if (isLocalize(tag, localizeName)) {
const [messageParts] = unwrapMessagePartsFromTemplateLiteral(path.get("quasi").get("quasis"), fs);
const translated = translate(diagnostics, translations, messageParts, path.node.quasi.expressions, missingTranslation);
path.replaceWith(buildLocalizeReplacement(translated[0], translated[1]));
}
} catch (e) {
if (isBabelParseError(e)) {
throw buildCodeFrameError(fs, path, state.file, e);
} else {
throw e;
}
}
}
}
};
}
// packages/localize/tools/src/translate/source_files/es5_translate_plugin.js
import { getFileSystem as getFileSystem2 } from "@angular/compiler-cli/private/localize";
function makeEs5TranslatePlugin(diagnostics, translations, { missingTranslation = "error", localizeName = "$localize" } = {}, fs = getFileSystem2()) {
return {
visitor: {
CallExpression(callPath, state) {
try {
const calleePath = callPath.get("callee");
if (isLocalize(calleePath, localizeName)) {
const [messageParts] = unwrapMessagePartsFromLocalizeCall(callPath, fs);
const [expressions] = unwrapSubstitutionsFromLocalizeCall(callPath, fs);
const translated = translate(diagnostics, translations, messageParts, expressions, missingTranslation);
callPath.replaceWith(buildLocalizeReplacement(translated[0], translated[1]));
}
} catch (e) {
if (isBabelParseError(e)) {
diagnostics.error(buildCodeFrameError(fs, callPath, state.file, e));
} else {
throw e;
}
}
}
}
};
}
// packages/localize/tools/src/translate/source_files/locale_plugin.js
import { types as t } from "@babel/core";
function makeLocalePlugin(locale, { localizeName = "$localize" } = {}) {
return {
visitor: {
MemberExpression(expression) {
const obj = expression.get("object");
if (!isLocalize(obj, localizeName)) {
return;
}
const property = expression.get("property");
if (!property.isIdentifier({ name: "locale" })) {
return;
}
if (expression.parentPath.isAssignmentExpression() && expression.parentPath.get("left") === expression) {
return;
}
const parent = expression.parentPath;
if (parent.isLogicalExpression({ operator: "&&" }) && parent.get("right") === expression) {
const left = parent.get("left");
if (isLocalizeGuard(left, localizeName)) {
parent.replaceWith(expression);
} else if (left.isLogicalExpression({ operator: "&&" }) && isLocalizeGuard(left.get("right"), localizeName)) {
left.replaceWith(left.get("left"));
}
}
expression.replaceWith(t.stringLiteral(locale));
}
}
};
}
function isLocalizeGuard(expression, localizeName) {
if (!expression.isBinaryExpression() || !(expression.node.operator === "!==" || expression.node.operator === "!=")) {
return false;
}
const left = expression.get("left");
const right = expression.get("right");
return left.isUnaryExpression({ operator: "typeof" }) && isLocalize(left.get("argument"), localizeName) && right.isStringLiteral({ value: "undefined" }) || right.isUnaryExpression({ operator: "typeof" }) && isLocalize(right.get("argument"), localizeName) && left.isStringLiteral({ value: "undefined" });
}
// packages/localize/tools/src/translate/translation_files/translation_parsers/arb_translation_parser.js
var ArbTranslationParser = class {
analyze(_filePath, contents) {
const diagnostics = new Diagnostics();
if (!contents.includes('"@@locale"')) {
return { canParse: false, diagnostics };
}
try {
return { canParse: true, diagnostics, hint: this.tryParseArbFormat(contents) };
} catch {
diagnostics.warn("File is not valid JSON.");
return { canParse: false, diagnostics };
}
}
parse(_filePath, contents, arb = this.tryParseArbFormat(contents)) {
const bundle = {
locale: arb["@@locale"],
translations: {},
diagnostics: new Diagnostics()
};
for (const messageId of Object.keys(arb)) {
if (messageId.startsWith("@")) {
continue;
}
const targetMessage = arb[messageId];
bundle.translations[messageId] = parseTranslation(targetMessage);
}
return bundle;
}
tryParseArbFormat(contents) {
const json = JSON.parse(contents);
if (typeof json["@@locale"] !== "string") {
throw new Error("Missing @@locale property.");
}
return json;
}
};
// packages/localize/tools/src/translate/translation_files/translation_parsers/simple_json_translation_parser.js
import { extname } from "path";
var SimpleJsonTranslationParser = class {
analyze(filePath, contents) {
const diagnostics = new Diagnostics();
if (extname(filePath) !== ".json" || !(contents.includes('"locale"') && contents.includes('"translations"'))) {
diagnostics.warn("File does not have .json extension.");
return { canParse: false, diagnostics };
}
try {
const json = JSON.parse(contents);
if (json.locale === void 0) {
diagnostics.warn('Required "locale" property missing.');
return { canParse: false, diagnostics };
}
if (typeof json.locale !== "string") {
diagnostics.warn('The "locale" property is not a string.');
return { canParse: false, diagnostics };
}
if (json.translations === void 0) {
diagnostics.warn('Required "translations" property missing.');
return { canParse: false, diagnostics };
}
if (typeof json.translations !== "object") {
diagnostics.warn('The "translations" is not an object.');
return { canParse: false, diagnostics };
}
return { canParse: true, diagnostics, hint: json };
} catch (e) {
diagnostics.warn("File is not valid JSON.");
return { canParse: false, diagnostics };
}
}
parse(_filePath, contents, json) {
const { locale: parsedLocale, translations } = json || JSON.parse(contents);
const parsedTranslations = {};
for (const messageId in translations) {
const targetMessage = translations[messageId];
parsedTranslations[messageId] = parseTranslation(targetMessage);
}
return { locale: parsedLocale, translations: parsedTranslations, diagnostics: new Diagnostics() };
}
};
// packages/localize/tools/src/translate/translation_files/translation_parsers/xliff1_translation_parser.js
import { ParseErrorLevel as ParseErrorLevel2, visitAll as visitAll2 } from "@angular/compiler";
// packages/localize/tools/src/translate/translation_files/base_visitor.js
var BaseVisitor = class {
visitElement(_element, _context) {
}
visitAttribute(_attribute, _context) {
}
visitText(_text, _context) {
}
visitComment(_comment, _context) {
}
visitExpansion(_expansion, _context) {
}
visitExpansionCase(_expansionCase, _context) {
}
visitBlock(_block, _context) {
}
visitBlockParameter(_parameter, _context) {
}
visitLetDeclaration(_decl, _context) {
}
visitComponent(_component, _context) {
}
visitDirective(_directive, _context) {
}
};
// packages/localize/tools/src/translate/translation_files/message_serialization/message_serializer.js
import { Element as Element2, ParseError as ParseError2, visitAll } from "@angular/compiler";
// packages/localize/tools/src/translate/translation_files/translation_parsers/translation_utils.js
import { Element, ParseError, ParseErrorLevel, XmlParser } from "@angular/compiler";
function getAttrOrThrow(element, attrName) {
const attrValue = getAttribute(element, attrName);
if (attrValue === void 0) {
throw new ParseError(element.sourceSpan, `Missing required "${attrName}" attribute:`);
}
return attrValue;
}
function getAttribute(element, attrName) {
const attr = element.attrs.find((a) => a.name === attrName);
return attr !== void 0 ? attr.value : void 0;
}
function parseInnerRange(element) {
const xmlParser = new XmlParser();
const xml = xmlParser.parse(element.sourceSpan.start.file.content, element.sourceSpan.start.file.url, { tokenizeExpansionForms: true, range: getInnerRange(element) });
return xml;
}
function getInnerRange(element) {
const start = element.startSourceSpan.end;
const end = element.endSourceSpan.start;
return {
startPos: start.offset,
startLine: start.line,
startCol: start.col,
endPos: end.offset
};
}
function canParseXml(filePath, contents, rootNodeName, attributes) {
const diagnostics = new Diagnostics();
const xmlParser = new XmlParser();
const xml = xmlParser.parse(contents, filePath);
if (xml.rootNodes.length === 0 || xml.errors.some((error) => error.level === ParseErrorLevel.ERROR)) {
xml.errors.forEach((e) => addParseError(diagnostics, e));
return { canParse: false, diagnostics };
}
const rootElements = xml.rootNodes.filter(isNamedElement(rootNodeName));
const rootElement = rootElements[0];
if (rootElement === void 0) {
diagnostics.warn(`The XML file does not contain a <${rootNodeName}> root node.`);
return { canParse: false, diagnostics };
}
for (const attrKey of Object.keys(attributes)) {
const attr = rootElement.attrs.find((attr2) => attr2.name === attrKey);
if (attr === void 0 || attr.value !== attributes[attrKey]) {
addParseDiagnostic(diagnostics, rootElement.sourceSpan, `The <${rootNodeName}> node does not have the required attribute: ${attrKey}="${attributes[attrKey]}".`, ParseErrorLevel.WARNING);
return { canParse: false, diagnostics };
}
}
if (rootElements.length > 1) {
xml.errors.push(new ParseError(xml.rootNodes[1].sourceSpan, "Unexpected root node. XLIFF 1.2 files should only have a single <xliff> root node.", ParseErrorLevel.WARNING));
}
return { canParse: true, diagnostics, hint: { element: rootElement, errors: xml.errors } };
}
function isNamedElement(name) {
function predicate(node) {
return node instanceof Element && node.name === name;
}
return predicate;
}
function addParseDiagnostic(diagnostics, sourceSpan, message, level) {
addParseError(diagnostics, new ParseError(sourceSpan, message, level));
}
function addParseError(diagnostics, parseError) {
if (parseError.level === ParseErrorLevel.ERROR) {
diagnostics.error(parseError.toString());
} else {
diagnostics.warn(parseError.toString());
}
}
function addErrorsToBundle(bundle, errors) {
for (const error of errors) {
addParseError(bundle.diagnostics, error);
}
}
// packages/localize/tools/src/translate/translation_files/message_serialization/message_serializer.js
var MessageSerializer = class extends BaseVisitor {
renderer;
config;
constructor(renderer, config) {
super();
this.renderer = renderer;
this.config = config;
}
serialize(nodes) {
this.renderer.startRender();
visitAll(this, nodes);
this.renderer.endRender();
return this.renderer.message;
}
visitElement(element) {
if (this.config.placeholder && element.name === this.config.placeholder.elementName) {
const name = getAttrOrThrow(element, this.config.placeholder.nameAttribute);
const body = this.config.placeholder.bodyAttribute && getAttribute(element, this.config.placeholder.bodyAttribute);
this.visitPlaceholder(name, body);
} else if (this.config.placeholderContainer && element.name === this.config.placeholderContainer.elementName) {
const start = getAttrOrThrow(element, this.config.placeholderContainer.startAttribute);
const end = getAttrOrThrow(element, this.config.placeholderContainer.endAttribute);
this.visitPlaceholderContainer(start, element.children, end);
} else if (this.config.inlineElements.indexOf(element.name) !== -1) {
visitAll(this, element.children);
} else {
throw new ParseError2(element.sourceSpan, `Invalid element found in message.`);
}
}
visitText(text) {
this.renderer.text(text.value);
}
visitExpansion(expansion) {
this.renderer.startIcu();
this.renderer.text(`${expansion.switchValue}, ${expansion.type},`);
visitAll(this, expansion.cases);
this.renderer.endIcu();
}
visitExpansionCase(expansionCase) {
this.renderer.text(` ${expansionCase.value} {`);
this.renderer.startContainer();
visitAll(this, expansionCase.expression);
this.renderer.closeContainer();
this.renderer.text(`}`);
}
visitContainedNodes(nodes) {
this.renderer.startContainer();
visitAll(this, nodes);
this.renderer.closeContainer();
}
visitPlaceholder(name, body) {
this.renderer.placeholder(name, body);
}
visitPlaceholderContainer(startName, children, closeName) {
this.renderer.startPlaceholder(startName);
this.visitContainedNodes(children);
this.renderer.closePlaceholder(closeName);
}
isPlaceholderContainer(node) {
return node instanceof Element2 && node.name === this.config.placeholderContainer.elementName;
}
};
// packages/localize/tools/src/translate/translation_files/message_serialization/target_message_renderer.js
var TargetMessageRenderer = class {
current = { messageParts: [], placeholderNames: [], text: "" };
icuDepth = 0;
get message() {
const { messageParts, placeholderNames } = this.current;
return makeParsedTranslation(messageParts, placeholderNames);
}
startRender() {
}
endRender() {
this.storeMessagePart();
}
text(text) {
this.current.text += text;
}
placeholder(name, body) {
this.renderPlaceholder(name);
}
startPlaceholder(name) {
this.renderPlaceholder(name);
}
closePlaceholder(name) {
this.renderPlaceholder(name);
}
startContainer() {
}
closeContainer() {
}
startIcu() {
this.icuDepth++;
this.text("{");
}
endIcu() {
this.icuDepth--;
this.text("}");
}
normalizePlaceholderName(name) {
return name.replace(/-/g, "_");
}
renderPlaceholder(name) {
name = this.normalizePlaceholderName(name);
if (this.icuDepth > 0) {
this.text(`{${name}}`);
} else {
this.storeMessagePart();
this.current.placeholderNames.push(name);
}
}
storeMessagePart() {
this.current.messageParts.push(this.current.text);
this.current.text = "";
}
};
// packages/localize/tools/src/translate/translation_files/translation_parsers/serialize_translation_message.js
function serializeTranslationMessage(element, config) {
const { rootNodes, errors: parseErrors } = parseInnerRange(element);
try {
const serializer = new MessageSerializer(new TargetMessageRenderer(), config);
const translation = serializer.serialize(rootNodes);
return { translation, parseErrors, serializeErrors: [] };
} catch (e) {
return { translation: null, parseErrors, serializeErrors: [e] };
}
}
// packages/localize/tools/src/translate/translation_files/translation_parsers/xliff1_translation_parser.js
var Xliff1TranslationParser = class {
analyze(filePath, contents) {
return canParseXml(filePath, contents, "xliff", { version: "1.2" });
}
parse(filePath, contents, hint) {
return this.extractBundle(hint);
}
extractBundle({ element, errors }) {
const diagnostics = new Diagnostics();
errors.forEach((e) => addParseError(diagnostics, e));
if (element.children.length === 0) {
addParseDiagnostic(diagnostics, element.sourceSpan, "Missing expected <file> element", ParseErrorLevel2.WARNING);
return { locale: void 0, translations: {}, diagnostics };
}
const files = element.children.filter(isNamedElement("file"));
if (files.length === 0) {
addParseDiagnostic(diagnostics, element.sourceSpan, "No <file> elements found in <xliff>", ParseErrorLevel2.WARNING);
} else if (files.length > 1) {
addParseDiagnostic(diagnostics, files[1].sourceSpan, "More than one <file> element found in <xliff>", ParseErrorLevel2.WARNING);
}
const bundle = { locale: void 0, translations: {}, diagnostics };
const translationVisitor = new XliffTranslationVisitor();
const localesFound = /* @__PURE__ */ new Set();
for (const file of files) {
const locale = getAttribute(file, "target-language");
if (locale !== void 0) {
localesFound.add(locale);
bundle.locale = locale;
}
visitAll2(translationVisitor, file.children, bundle);
}
if (localesFound.size > 1) {
addParseDiagnostic(diagnostics, element.sourceSpan, `More than one locale found in translation file: ${JSON.stringify(Array.from(localesFound))}. Using "${bundle.locale}"`, ParseErrorLevel2.WARNING);
}
return bundle;
}
};
var XliffTranslationVisitor = class extends BaseVisitor {
visitElement(element, bundle) {
if (element.name === "trans-unit") {
this.visitTransUnitElement(element, bundle);
} else {
visitAll2(this, element.children, bundle);
}
}
visitTransUnitElement(element, bundle) {
const id = getAttribute(element, "id");
if (id === void 0) {
addParseDiagnostic(bundle.diagnostics, element.sourceSpan, `Missing required "id" attribute on <trans-unit> element.`, ParseErrorLevel2.ERROR);
return;
}
if (bundle.translations[id] !== void 0) {
addParseDiagnostic(bundle.diagnostics, element.sourceSpan, `Duplicated translations for message "${id}"`, ParseErrorLevel2.ERROR);
return;
}
let targetMessage = element.children.find(isNamedElement("target"));
if (targetMessage === void 0) {
addParseDiagnostic(bundle.diagnostics, element.sourceSpan, "Missing <target> element", ParseErrorLevel2.WARNING);
targetMessage = element.children.find(isNamedElement("source"));
if (targetMessage === void 0) {
addParseDiagnostic(bundle.diagnostics, element.sourceSpan, "Missing required element: one of <target> or <source> is required", ParseErrorLevel2.ERROR);
return;
}
}
const { translation, parseErrors, serializeErrors } = serializeTranslationMessage(targetMessage, {
inlineElements: ["g", "bx", "ex", "bpt", "ept", "ph", "it", "mrk"],
placeholder: { elementName: "x", nameAttribute: "id" }
});
if (translation !== null) {
bundle.translations[id] = translation;
}
addErrorsToBundle(bundle, parseErrors);
addErrorsToBundle(bundle, serializeErrors);
}
};
// packages/localize/tools/src/translate/translation_files/translation_parsers/xliff2_translation_parser.js
import { Element as Element3, ParseErrorLevel as ParseErrorLevel3, visitAll as visitAll3 } from "@angular/compiler";
var Xliff2TranslationParser = class {
analyze(filePath, contents) {
return canParseXml(filePath, contents, "xliff", { version: "2.0" });
}
parse(filePath, contents, hint) {
return this.extractBundle(hint);
}
extractBundle({ element, errors }) {
const diagnostics = new Diagnostics();
errors.forEach((e) => addParseError(diagnostics, e));
const locale = getAttribute(element, "trgLang");
const files = element.children.filter(isFileElement);
if (files.length === 0) {
addParseDiagnostic(diagnostics, element.sourceSpan, "No <file> elements found in <xliff>", ParseErrorLevel3.WARNING);
} else if (files.length > 1) {
addParseDiagnostic(diagnostics, files[1].sourceSpan, "More than one <file> element found in <xliff>", ParseErrorLevel3.WARNING);
}
const bundle = { locale, translations: {}, diagnostics };
const translationVisitor = new Xliff2TranslationVisitor();
for (const file of files) {
visitAll3(translationVisitor, file.children, { bundle });
}
return bundle;
}
};
var Xliff2TranslationVisitor = class extends BaseVisitor {
visitElement(element, { bundle, unit }) {
if (element.name === "unit") {
this.visitUnitElement(element, bundle);
} else if (element.name === "segment") {
this.visitSegmentElement(element, bundle, unit);
} else {
visitAll3(this, element.children, { bundle, unit });
}
}
visitUnitElement(element, bundle) {
const externalId = getAttribute(element, "id");
if (externalId === void 0) {
addParseDiagnostic(bundle.diagnostics, element.sourceSpan, `Missing required "id" attribute on <trans-unit> element.`, ParseErrorLevel3.ERROR);
return;
}
if (bundle.translations[externalId] !== void 0) {
addParseDiagnostic(bundle.diagnostics, element.sourceSpan, `Duplicated translations for message "${externalId}"`, ParseErrorLevel3.ERROR);
return;
}
visitAll3(this, element.children, { bundle, unit: externalId });
}
visitSegmentElement(element, bundle, unit) {
if (unit === void 0) {
addParseDiagnostic(bundle.diagnostics, element.sourceSpan, "Invalid <segment> element: should be a child of a <unit> element.", ParseErrorLevel3.ERROR);
return;
}
let targetMessage = element.children.find(isNamedElement("target"));
if (targetMessage === void 0) {
addParseDiagnostic(bundle.diagnostics, element.sourceSpan, "Missing <target> element", ParseErrorLevel3.WARNING);
targetMessage = element.children.find(isNamedElement("source"));
if (targetMessage === void 0) {
addParseDiagnostic(bundle.diagnostics, element.sourceSpan, "Missing required element: one of <target> or <source> is required", ParseErrorLevel3.ERROR);
return;
}
}
const { translation, parseErrors, serializeErrors } = serializeTranslationMessage(targetMessage, {
inlineElements: ["cp", "sc", "ec", "mrk", "sm", "em"],
placeholder: { elementName: "ph", nameAttribute: "equiv", bodyAttribute: "disp" },
placeholderContainer: {
elementName: "pc",
startAttribute: "equivStart",
endAttribute: "equivEnd"
}
});
if (translation !== null) {
bundle.translations[unit] = translation;
}
addErrorsToBundle(bundle, parseErrors);
addErrorsToBundle(bundle, serializeErrors);
}
};
function isFileElement(node) {
return node instanceof Element3 && node.name === "file";
}
// packages/localize/tools/src/translate/translation_files/translation_parsers/xtb_translation_parser.js
import { ParseErrorLevel as ParseErrorLevel4, visitAll as visitAll4 } from "@angular/compiler";
import { extname as extname2 } from "path";
var XtbTranslationParser = class {
analyze(filePath, contents) {
const extension = extname2(filePath);
if (extension !== ".xtb" && extension !== ".xmb") {
const diagnostics = new Diagnostics();
diagnostics.warn("Must have xtb or xmb extension.");
return { canParse: false, diagnostics };
}
return canParseXml(filePath, contents, "translationbundle", {});
}
parse(filePath, contents, hint) {
return this.extractBundle(hint);
}
extractBundle({ element, errors }) {
const langAttr = element.attrs.find((attr) => attr.name === "lang");
const bundle = {
locale: langAttr && langAttr.value,
translations: {},
diagnostics: new Diagnostics()
};
errors.forEach((e) => addParseError(bundle.diagnostics, e));
const bundleVisitor = new XtbVisitor();
visitAll4(bundleVisitor, element.children, bundle);
return bundle;
}
};
var XtbVisitor = class extends BaseVisitor {
visitElement(element, bundle) {
switch (element.name) {
case "translation":
const id = getAttribute(element, "id");
if (id === void 0) {
addParseDiagnostic(bundle.diagnostics, element.sourceSpan, `Missing required "id" attribute on <translation> element.`, ParseErrorLevel4.ERROR);
return;
}
if (bundle.translations[id] !== void 0) {
addParseDiagnostic(bundle.diagnostics, element.sourceSpan, `Duplicated translations for message "${id}"`, ParseErrorLevel4.ERROR);
return;
}
const { translation, parseErrors, serializeErrors } = serializeTranslationMessage(element, {
inlineElements: [],
placeholder: { elementName: "ph", nameAttribute: "name" }
});
if (parseErrors.length) {
bundle.diagnostics.warn(computeParseWarning(id, parseErrors));
} else if (translation !== null) {
bundle.translations[id] = translation;
}
addErrorsToBundle(bundle, serializeErrors);
break;
default:
addParseDiagnostic(bundle.diagnostics, element.sourceSpan, `Unexpected <${element.name}> tag.`, ParseErrorLevel4.ERROR);
}
}
};
function computeParseWarning(id, errors) {
const msg = errors.map((e) => e.toString()).join("\n");
return `Could not parse message with id "${id}" - perhaps it has an unrecognised ICU format?
` + msg;
}
export {
makeEs2015TranslatePlugin,
makeEs5TranslatePlugin,
makeLocalePlugin,
ArbTranslationParser,
SimpleJsonTranslationParser,
Xliff1TranslationParser,
Xliff2TranslationParser,
XtbTranslationParser
};
/**
* @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.dev/license
*/
//# sourceMappingURL=chunk-7PXQZPIU.js.map
{
"version": 3,
"sources": ["../src/translate/source_files/es2015_translate_plugin.ts", "../src/translate/source_files/es5_translate_plugin.ts", "../src/translate/source_files/locale_plugin.ts", "../src/translate/translation_files/translation_parsers/arb_translation_parser.ts", "../src/translate/translation_files/translation_parsers/simple_json_translation_parser.ts", "../src/translate/translation_files/translation_parsers/xliff1_translation_parser.ts", "../src/translate/translation_files/base_visitor.ts", "../src/translate/translation_files/message_serialization/message_serializer.ts", "../src/translate/translation_files/translation_parsers/translation_utils.ts", "../src/translate/translation_files/message_serialization/target_message_renderer.ts", "../src/translate/translation_files/translation_parsers/serialize_translation_message.ts", "../src/translate/translation_files/translation_parsers/xliff2_translation_parser.ts", "../src/translate/translation_files/translation_parsers/xtb_translation_parser.ts"],
"mappings": ";;;;;;;;;;;;;;;;;;;AAOA,SAAQ,qBAAsC;AAqBxC,SAAU,0BACd,aACA,cACA,EAAC,qBAAqB,SAAS,eAAe,YAAW,IAA4B,CAAA,GACrF,KAAuB,cAAa,GAAE;AAEtC,SAAO;IACL,SAAS;MACP,yBAAyB,MAA4C,OAAK;AACxE,YAAI;AACF,gBAAM,MAAM,KAAK,IAAI,KAAK;AAC1B,cAAI,WAAW,KAAK,YAAY,GAAG;AACjC,kBAAM,CAAC,YAAY,IAAI,sCACrB,KAAK,IAAI,OAAO,EAAE,IAAI,QAAQ,GAC9B,EAAE;AAEJ,kBAAM,aAAa,UACjB,aACA,cACA,cACA,KAAK,KAAK,MAAM,aAChB,kBAAkB;AAEpB,iBAAK,YAAY,yBAAyB,WAAW,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC;UACzE;QACF,SAAS,GAAG;AACV,cAAI,kBAAkB,CAAC,GAAG;AAIxB,kBAAM,oBAAoB,IAAI,MAAM,MAAM,MAAM,CAAC;UACnD,OAAO;AACL,kBAAM;UACR;QACF;MACF;;;AAGN;;;AC3DA,SAAQ,iBAAAA,sBAAsC;AAsBxC,SAAU,uBACd,aACA,cACA,EAAC,qBAAq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AAM,MAAM,OAAO,IAAI,CAAC,MAAM,EAAE,SAAQ,CAAE,EAAE,KAAK,IAAI;AACrD,SACE,oCAAoC,EAAE;IAAqD;AAE/F;",
"names": ["getFileSystem", "getFileSystem", "ParseErrorLevel", "visitAll", "Element", "ParseError", "attr", "ParseError", "Element", "ParseErrorLevel", "visitAll", "Element", "ParseErrorLevel", "visitAll", "ParseErrorLevel", "visitAll", "Element", "ParseErrorLevel", "visitAll", "extname", "extname", "visitAll", "ParseErrorLevel"]
}
import {createRequire as __cjsCompatRequire} from 'module';
const require = __cjsCompatRequire(import.meta.url);
// packages/localize/tools/src/diagnostics.js
var Diagnostics = class {
messages = [];
get hasErrors() {
return this.messages.some((m) => m.type === "error");
}
add(type, message) {
if (type !== "ignore") {
this.messages.push({ type, message });
}
}
warn(message) {
this.messages.push({ type: "warning", message });
}
error(message) {
this.messages.push({ type: "error", message });
}
merge(other) {
this.messages.push(...other.messages);
}
formatDiagnostics(message) {
const errors = this.messages.filter((d) => d.type === "error").map((d) => " - " + d.message);
const warnings = this.messages.filter((d) => d.type === "warning").map((d) => " - " + d.message);
if (errors.length) {
message += "\nERRORS:\n" + errors.join("\n");
}
if (warnings.length) {
message += "\nWARNINGS:\n" + warnings.join("\n");
}
return message;
}
};
// packages/localize/tools/src/source_file_utils.js
import { getFileSystem } from "@angular/compiler-cli/private/localize";
// packages/localize/src/utils/src/constants.js
var BLOCK_MARKER = ":";
var MEANING_SEPARATOR = "|";
var ID_SEPARATOR = "@@";
var LEGACY_ID_INDICATOR = "\u241F";
// packages/compiler/src/i18n/digest.js
var textEncoder;
var _SerializerVisitor = class {
visitText(text, context) {
return text.value;
}
visitContainer(container, context) {
return `[${container.children.map((child) => child.visit(this)).join(", ")}]`;
}
visitIcu(icu, context) {
const strCases = Object.keys(icu.cases).map((k) => `${k} {${icu.cases[k].visit(this)}}`);
return `{${icu.expression}, ${icu.type}, ${strCases.join(", ")}}`;
}
visitTagPlaceholder(ph, context) {
return ph.isVoid ? `<ph tag name="${ph.startName}"/>` : `<ph tag name="${ph.startName}">${ph.children.map((child) => child.visit(this)).join(", ")}</ph name="${ph.closeName}">`;
}
visitPlaceholder(ph, context) {
return ph.value ? `<ph name="${ph.name}">${ph.value}</ph>` : `<ph name="${ph.name}"/>`;
}
visitIcuPlaceholder(ph, context) {
return `<ph icu name="${ph.name}">${ph.value.visit(this)}</ph>`;
}
visitBlockPlaceholder(ph, context) {
return `<ph block name="${ph.startName}">${ph.children.map((child) => child.visit(this)).join(", ")}</ph name="${ph.closeName}">`;
}
};
var serializerVisitor = new _SerializerVisitor();
function fingerprint(str) {
textEncoder ??= new TextEncoder();
const utf8 = textEncoder.encode(str);
const view = new DataView(utf8.buffer, utf8.byteOffset, utf8.byteLength);
let hi = hash32(view, utf8.length, 0);
let lo = hash32(view, utf8.length, 102072);
if (hi == 0 && (lo == 0 || lo == 1)) {
hi = hi ^ 319790063;
lo = lo ^ -1801410264;
}
return BigInt.asUintN(32, BigInt(hi)) << BigInt(32) | BigInt.asUintN(32, BigInt(lo));
}
function computeMsgId(msg, meaning = "") {
let msgFingerprint = fingerprint(msg);
if (meaning) {
msgFingerprint = BigInt.asUintN(64, msgFingerprint << BigInt(1)) | msgFingerprint >> BigInt(63) & BigInt(1);
msgFingerprint += fingerprint(meaning);
}
return BigInt.asUintN(63, msgFingerprint).toString();
}
function hash32(view, length, c) {
let a = 2654435769, b = 2654435769;
let index = 0;
const end = length - 12;
for (; index <= end; index += 12) {
a += view.getUint32(index, true);
b += view.getUint32(index + 4, true);
c += view.getUint32(index + 8, true);
const res = mix(a, b, c);
a = res[0], b = res[1], c = res[2];
}
const remainder = length - index;
c += length;
if (remainder >= 4) {
a += view.getUint32(index, true);
index += 4;
if (remainder >= 8) {
b += view.getUint32(index, true);
index += 4;
if (remainder >= 9) {
c += view.getUint8(index++) << 8;
}
if (remainder >= 10) {
c += view.getUint8(index++) << 16;
}
if (remainder === 11) {
c += view.getUint8(index++) << 24;
}
} else {
if (remainder >= 5) {
b += view.getUint8(index++);
}
if (remainder >= 6) {
b += view.getUint8(index++) << 8;
}
if (remainder === 7) {
b += view.getUint8(index++) << 16;
}
}
} else {
if (remainder >= 1) {
a += view.getUint8(index++);
}
if (remainder >= 2) {
a += view.getUint8(index++) << 8;
}
if (remainder === 3) {
a += view.getUint8(index++) << 16;
}
}
return mix(a, b, c)[2];
}
function mix(a, b, c) {
a -= b;
a -= c;
a ^= c >>> 13;
b -= c;
b -= a;
b ^= a << 8;
c -= a;
c -= b;
c ^= b >>> 13;
a -= b;
a -= c;
a ^= c >>> 12;
b -= c;
b -= a;
b ^= a << 16;
c -= a;
c -= b;
c ^= b >>> 5;
a -= b;
a -= c;
a ^= c >>> 3;
b -= c;
b -= a;
b ^= a << 10;
c -= a;
c -= b;
c ^= b >>> 15;
return [a, b, c];
}
var Endian;
(function(Endian2) {
Endian2[Endian2["Little"] = 0] = "Little";
Endian2[Endian2["Big"] = 1] = "Big";
})(Endian || (Endian = {}));
// packages/localize/src/utils/src/messages.js
function parseMessage(messageParts, expressions, location, messagePartLocations, expressionLocations = []) {
const substitutions = {};
const substitutionLocations = {};
const associatedMessageIds = {};
const metadata = parseMetadata(messageParts[0], messageParts.raw[0]);
const cleanedMessageParts = [metadata.text];
const placeholderNames = [];
let messageString = metadata.text;
for (let i = 1; i < messageParts.length; i++) {
const { messagePart, placeholderName = computePlaceholderName(i), associatedMessageId } = parsePlaceholder(messageParts[i], messageParts.raw[i]);
messageString += `{$${placeholderName}}${messagePart}`;
if (expressions !== void 0) {
substitutions[placeholderName] = expressions[i - 1];
substitutionLocations[placeholderName] = expressionLocations[i - 1];
}
placeholderNames.push(placeholderName);
if (associatedMessageId !== void 0) {
associatedMessageIds[placeholderName] = associatedMessageId;
}
cleanedMessageParts.push(messagePart);
}
const messageId = metadata.customId || computeMsgId(messageString, metadata.meaning || "");
const legacyIds = metadata.legacyIds ? metadata.legacyIds.filter((id) => id !== messageId) : [];
return {
id: messageId,
legacyIds,
substitutions,
substitutionLocations,
text: messageString,
customId: metadata.customId,
meaning: metadata.meaning || "",
description: metadata.description || "",
messageParts: cleanedMessageParts,
messagePartLocations,
placeholderNames,
associatedMessageIds,
location
};
}
function parseMetadata(cooked, raw) {
const { text: messageString, block } = splitBlock(cooked, raw);
if (block === void 0) {
return { text: messageString };
} else {
const [meaningDescAndId, ...legacyIds] = block.split(LEGACY_ID_INDICATOR);
const [meaningAndDesc, customId] = meaningDescAndId.split(ID_SEPARATOR, 2);
let [meaning, description] = meaningAndDesc.split(MEANING_SEPARATOR, 2);
if (description === void 0) {
description = meaning;
meaning = void 0;
}
if (description === "") {
description = void 0;
}
return { text: messageString, meaning, description, customId, legacyIds };
}
}
function parsePlaceholder(cooked, raw) {
const { text: messagePart, block } = splitBlock(cooked, raw);
if (block === void 0) {
return { messagePart };
} else {
const [placeholderName, associatedMessageId] = block.split(ID_SEPARATOR);
return { messagePart, placeholderName, associatedMessageId };
}
}
function splitBlock(cooked, raw) {
if (raw.charAt(0) !== BLOCK_MARKER) {
return { text: cooked };
} else {
const endOfBlock = findEndOfBlock(cooked, raw);
return {
block: cooked.substring(1, endOfBlock),
text: cooked.substring(endOfBlock + 1)
};
}
}
function computePlaceholderName(index) {
return index === 1 ? "PH" : `PH_${index - 1}`;
}
function findEndOfBlock(cooked, raw) {
for (let cookedIndex = 1, rawIndex = 1; cookedIndex < cooked.length; cookedIndex++, rawIndex++) {
if (raw[rawIndex] === "\\") {
rawIndex++;
} else if (cooked[cookedIndex] === BLOCK_MARKER) {
return cookedIndex;
}
}
throw new Error(`Unterminated $localize metadata block in "${raw}".`);
}
// packages/localize/src/utils/src/translations.js
var MissingTranslationError = class extends Error {
parsedMessage;
type = "MissingTranslationError";
constructor(parsedMessage) {
super(`No translation found for ${describeMessage(parsedMessage)}.`);
this.parsedMessage = parsedMessage;
}
};
function isMissingTranslationError(e) {
return e.type === "MissingTranslationError";
}
function translate(translations, messageParts, substitutions) {
const message = parseMessage(messageParts, substitutions);
let translation = translations[message.id];
if (message.legacyIds !== void 0) {
for (let i = 0; i < message.legacyIds.length && translation === void 0; i++) {
translation = translations[message.legacyIds[i]];
}
}
if (translation === void 0) {
throw new MissingTranslationError(message);
}
return [
translation.messageParts,
translation.placeholderNames.map((placeholder) => {
if (message.substitutions.hasOwnProperty(placeholder)) {
return message.substitutions[placeholder];
} else {
throw new Error(`There is a placeholder name mismatch with the translation provided for the message ${describeMessage(message)}.
The translation contains a placeholder with name ${placeholder}, which does not exist in the message.`);
}
})
];
}
function parseTranslation(messageString) {
const parts = messageString.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 {
text: messageString,
messageParts: makeTemplateObject(messageParts, rawMessageParts),
placeholderNames
};
}
function makeParsedTranslation(messageParts, placeholderNames = []) {
let messageString = messageParts[0];
for (let i = 0; i < placeholderNames.length; i++) {
messageString += `{$${placeholderNames[i]}}${messageParts[i + 1]}`;
}
return {
text: messageString,
messageParts: makeTemplateObject(messageParts, messageParts),
placeholderNames
};
}
function makeTemplateObject(cooked, raw) {
Object.defineProperty(cooked, "raw", { value: raw });
return cooked;
}
function describeMessage(message) {
const meaningString = message.meaning && ` - "${message.meaning}"`;
const legacy = message.legacyIds && message.legacyIds.length > 0 ? ` [${message.legacyIds.map((l) => `"${l}"`).join(", ")}]` : "";
return `"${message.id}"${legacy} ("${message.text}"${meaningString})`;
}
// packages/localize/tools/src/source_file_utils.js
import { types as t } from "@babel/core";
function isLocalize(expression, localizeName) {
return isNamedIdentifier(expression, localizeName) && isGlobalIdentifier(expression);
}
function isNamedIdentifier(expression, name) {
return expression.isIdentifier() && expression.node.name === name;
}
function isGlobalIdentifier(identifier) {
return !identifier.scope || !identifier.scope.hasBinding(identifier.node.name);
}
function buildLocalizeReplacement(messageParts, substitutions) {
let mappedString = t.stringLiteral(messageParts[0]);
for (let i = 1; i < messageParts.length; i++) {
mappedString = t.binaryExpression("+", mappedString, wrapInParensIfNecessary(substitutions[i - 1]));
mappedString = t.binaryExpression("+", mappedString, t.stringLiteral(messageParts[i]));
}
return mappedString;
}
function unwrapMessagePartsFromLocalizeCall(call, fs = getFileSystem()) {
let cooked = call.get("arguments")[0];
if (cooked === void 0) {
throw new BabelParseError(call.node, "`$localize` called without any arguments.");
}
if (!cooked.isExpression()) {
throw new BabelParseError(cooked.node, "Unexpected argument to `$localize` (expected an array).");
}
let raw = cooked;
if (cooked.isLogicalExpression() && cooked.node.operator === "||" && cooked.get("left").isIdentifier()) {
const right = cooked.get("right");
if (right.isAssignmentExpression()) {
cooked = right.get("right");
if (!cooked.isExpression()) {
throw new BabelParseError(cooked.node, 'Unexpected "makeTemplateObject()" function (expected an expression).');
}
} else if (right.isSequenceExpression()) {
const expressions = right.get("expressions");
if (expressions.length > 2) {
const [first, second] = expressions;
if (first.isAssignmentExpression()) {
cooked = first.get("right");
if (!cooked.isExpression()) {
throw new BabelParseError(first.node, "Unexpected cooked value, expected an expression.");
}
if (second.isAssignmentExpression()) {
raw = second.get("right");
if (!raw.isExpression()) {
throw new BabelParseError(second.node, "Unexpected raw value, expected an expression.");
}
} else {
raw = cooked;
}
}
}
}
}
if (cooked.isCallExpression()) {
let call2 = cooked;
if (call2.get("arguments").length === 0) {
call2 = unwrapLazyLoadHelperCall(call2);
}
cooked = call2.get("arguments")[0];
if (!cooked.isExpression()) {
throw new BabelParseError(cooked.node, 'Unexpected `cooked` argument to the "makeTemplateObject()" function (expected an expression).');
}
const arg2 = call2.get("arguments")[1];
if (arg2 && !arg2.isExpression()) {
throw new BabelParseError(arg2.node, 'Unexpected `raw` argument to the "makeTemplateObject()" function (expected an expression).');
}
raw = arg2 !== void 0 ? arg2 : cooked;
}
const [cookedStrings] = unwrapStringLiteralArray(cooked, fs);
const [rawStrings, rawLocations] = unwrapStringLiteralArray(raw, fs);
return [makeTemplateObject(cookedStrings, rawStrings), rawLocations];
}
function unwrapSubstitutionsFromLocalizeCall(call, fs = getFileSystem()) {
const expressions = call.get("arguments").splice(1);
if (!isArrayOfExpressions(expressions)) {
const badExpression = expressions.find((expression) => !expression.isExpression());
throw new BabelParseError(badExpression.node, "Invalid substitutions for `$localize` (expected all substitution arguments to be expressions).");
}
return [
expressions.map((path) => path.node),
expressions.map((expression) => getLocation(fs, expression))
];
}
function unwrapMessagePartsFromTemplateLiteral(elements, fs = getFileSystem()) {
const cooked = elements.map((q) => {
if (q.node.value.cooked === void 0) {
throw new BabelParseError(q.node, `Unexpected undefined message part in "${elements.map((q2) => q2.node.value.cooked)}"`);
}
return q.node.value.cooked;
});
const raw = elements.map((q) => q.node.value.raw);
const locations = elements.map((q) => getLocation(fs, q));
return [makeTemplateObject(cooked, raw), locations];
}
function unwrapExpressionsFromTemplateLiteral(quasi, fs = getFileSystem()) {
return [
quasi.node.expressions,
quasi.get("expressions").map((e) => getLocation(fs, e))
];
}
function wrapInParensIfNecessary(expression) {
if (t.isBinaryExpression(expression)) {
return t.parenthesizedExpression(expression);
} else {
return expression;
}
}
function unwrapStringLiteralArray(array, fs = getFileSystem()) {
if (!isStringLiteralArray(array.node)) {
throw new BabelParseError(array.node, "Unexpected messageParts for `$localize` (expected an array of strings).");
}
const elements = array.get("elements");
return [elements.map((str) => str.node.value), elements.map((str) => getLocation(fs, str))];
}
function unwrapLazyLoadHelperCall(call) {
const callee = call.get("callee");
if (!callee.isIdentifier()) {
throw new BabelParseError(callee.node, "Unexpected lazy-load helper call (expected a call of the form `_templateObject()`).");
}
const lazyLoadBinding = call.scope.getBinding(callee.node.name);
if (!lazyLoadBinding) {
throw new BabelParseError(callee.node, "Missing declaration for lazy-load helper function");
}
const lazyLoadFn = lazyLoadBinding.path;
if (!lazyLoadFn.isFunctionDeclaration()) {
throw new BabelParseError(lazyLoadFn.node, "Unexpected expression (expected a function declaration");
}
const returnedNode = getReturnedExpression(lazyLoadFn);
if (returnedNode.isCallExpression()) {
return returnedNode;
}
if (returnedNode.isIdentifier()) {
const identifierName = returnedNode.node.name;
const declaration = returnedNode.scope.getBinding(identifierName);
if (declaration === void 0) {
throw new BabelParseError(returnedNode.node, "Missing declaration for return value from helper.");
}
if (!declaration.path.isVariableDeclarator()) {
throw new BabelParseError(declaration.path.node, "Unexpected helper return value declaration (expected a variable declaration).");
}
const initializer = declaration.path.get("init");
if (!initializer.isCallExpression()) {
throw new BabelParseError(declaration.path.node, "Unexpected return value from helper (expected a call expression).");
}
if (lazyLoadBinding.references === 1) {
lazyLoadFn.remove();
}
return initializer;
}
return call;
}
function getReturnedExpression(fn) {
const bodyStatements = fn.get("body").get("body");
for (const statement of bodyStatements) {
if (statement.isReturnStatement()) {
const argument = statement.get("argument");
if (argument.isSequenceExpression()) {
const expressions = argument.get("expressions");
return Array.isArray(expressions) ? expressions[expressions.length - 1] : expressions;
} else if (argument.isExpression()) {
return argument;
} else {
throw new BabelParseError(statement.node, "Invalid return argument in helper function (expected an expression).");
}
}
}
throw new BabelParseError(fn.node, "Missing return statement in helper function.");
}
function isStringLiteralArray(node) {
return t.isArrayExpression(node) && node.elements.every((element) => t.isStringLiteral(element));
}
function isArrayOfExpressions(paths) {
return paths.every((element) => element.isExpression());
}
function translate2(diagnostics, translations, messageParts, substitutions, missingTranslation) {
try {
return translate(translations, messageParts, substitutions);
} catch (e) {
if (isMissingTranslationError(e)) {
diagnostics.add(missingTranslation, e.message);
return [
makeTemplateObject(e.parsedMessage.messageParts, e.parsedMessage.messageParts),
substitutions
];
} else {
diagnostics.error(e.message);
return [messageParts, substitutions];
}
}
}
var BabelParseError = class extends Error {
node;
type = "BabelParseError";
constructor(node, message) {
super(message);
this.node = node;
}
};
function isBabelParseError(e) {
return e.type === "BabelParseError";
}
function buildCodeFrameError(fs, path, file, e) {
let filename = file.opts.filename;
if (filename) {
filename = fs.resolve(filename);
let cwd = file.opts.cwd;
if (cwd) {
cwd = fs.resolve(cwd);
filename = fs.relative(cwd, filename);
}
} else {
filename = "(unknown file)";
}
const { message } = file.hub.buildError(e.node, e.message);
return `${filename}: ${message}`;
}
function getLocation(fs, startPath, endPath) {
const startLocation = startPath.node.loc;
const file = getFileFromPath(fs, startPath);
if (!startLocation || !file) {
return void 0;
}
const endLocation = endPath && getFileFromPath(fs, endPath) === file && endPath.node.loc || startLocation;
return {
start: getLineAndColumn(startLocation.start),
end: getLineAndColumn(endLocation.end),
file,
text: startPath.getSource() || void 0
};
}
function serializeLocationPosition(location) {
const endLineString = location.end !== void 0 && location.end.line !== location.start.line ? `,${location.end.line + 1}` : "";
return `${location.start.line + 1}${endLineString}`;
}
function getFileFromPath(fs, path) {
const opts = (path?.hub).file?.opts;
const filename = opts?.filename;
if (!filename || !opts.cwd) {
return null;
}
const relativePath = fs.relative(opts.cwd, filename);
const root = opts.generatorOpts?.sourceRoot ?? opts.cwd;
const absPath = fs.resolve(root, relativePath);
return absPath;
}
function getLineAndColumn(loc) {
return { line: loc.line - 1, column: loc.column };
}
export {
Diagnostics,
parseMessage,
parseTranslation,
makeParsedTranslation,
isLocalize,
isNamedIdentifier,
isGlobalIdentifier,
buildLocalizeReplacement,
unwrapMessagePartsFromLocalizeCall,
unwrapSubstitutionsFromLocalizeCall,
unwrapMessagePartsFromTemplateLiteral,
unwrapExpressionsFromTemplateLiteral,
translate2 as translate,
isBabelParseError,
buildCodeFrameError,
getLocation,
serializeLocationPosition
};
/**
* @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.dev/license
*/
//# sourceMappingURL=chunk-BNVRZOYA.js.map
{
"version": 3,
"sources": ["../src/diagnostics.ts", "../src/source_file_utils.ts", "../../src/utils/src/constants.ts", "../../../compiler/src/i18n/digest.ts", "../../src/utils/src/messages.ts", "../../src/utils/src/translations.ts"],
"mappings": ";;;;;;AAmBM,IAAO,cAAP,MAAkB;EACb,WAA2D,CAAA;EACpE,IAAI,YAAS;AACX,WAAO,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,OAAO,KAAK,eAAe,cAAc,KAAK;AACpD,QAAM,UAAU,GAAG,QAAQ,MAAM,YAAY;AAC7C,SAAO;AACT;AAEA,SAAS,iBAAiB,KAAmC;AAE3D,SAAO,EAAC,MAAM,IAAI,OAAO,GAAG,QAAQ,IAAI,OAAM;AAChD;",
"names": ["Endian", "call", "q", "translate"]
}
import {createRequire as __cjsCompatRequire} from 'module';
const require = __cjsCompatRequire(import.meta.url);
import {
Diagnostics,
buildCodeFrameError,
getLocation,
isBabelParseError,
isGlobalIdentifier,
isNamedIdentifier,
parseMessage,
serializeLocationPosition,
unwrapExpressionsFromTemplateLiteral,
unwrapMessagePartsFromLocalizeCall,
unwrapMessagePartsFromTemplateLiteral,
unwrapSubstitutionsFromLocalizeCall
} from "./chunk-BNVRZOYA.js";
// packages/localize/tools/src/extract/duplicates.js
function checkDuplicateMessages(fs, messages, duplicateMessageHandling, basePath) {
const diagnostics = new Diagnostics();
if (duplicateMessageHandling === "ignore")
return diagnostics;
const messageMap = /* @__PURE__ */ new Map();
for (const message of messages) {
if (messageMap.has(message.id)) {
messageMap.get(message.id).push(message);
} else {
messageMap.set(message.id, [message]);
}
}
for (const duplicates of messageMap.values()) {
if (duplicates.length <= 1)
continue;
if (duplicates.every((message) => message.text === duplicates[0].text))
continue;
const diagnosticMessage = `Duplicate messages with id "${duplicates[0].id}":
` + duplicates.map((message) => serializeMessage(fs, basePath, message)).join("\n");
diagnostics.add(duplicateMessageHandling, diagnosticMessage);
}
return diagnostics;
}
function serializeMessage(fs, basePath, message) {
if (message.location === void 0) {
return ` - "${message.text}"`;
} else {
const locationFile = fs.relative(basePath, message.location.file);
const locationPosition = serializeLocationPosition(message.location);
return ` - "${message.text}" : ${locationFile}:${locationPosition}`;
}
}
// packages/localize/tools/src/extract/extraction.js
import { SourceFileLoader } from "@angular/compiler-cli/private/localize";
import { transformSync } from "@babel/core";
// packages/localize/tools/src/extract/source_files/es2015_extract_plugin.js
function makeEs2015ExtractPlugin(fs, messages, localizeName = "$localize") {
return {
visitor: {
TaggedTemplateExpression(path) {
const tag = path.get("tag");
if (isNamedIdentifier(tag, localizeName) && isGlobalIdentifier(tag)) {
const quasiPath = path.get("quasi");
const [messageParts, messagePartLocations] = unwrapMessagePartsFromTemplateLiteral(quasiPath.get("quasis"), fs);
const [expressions, expressionLocations] = unwrapExpressionsFromTemplateLiteral(quasiPath, fs);
const location = getLocation(fs, quasiPath);
const message = parseMessage(messageParts, expressions, location, messagePartLocations, expressionLocations);
messages.push(message);
}
}
}
};
}
// packages/localize/tools/src/extract/source_files/es5_extract_plugin.js
function makeEs5ExtractPlugin(fs, messages, localizeName = "$localize") {
return {
visitor: {
CallExpression(callPath, state) {
try {
const calleePath = callPath.get("callee");
if (isNamedIdentifier(calleePath, localizeName) && isGlobalIdentifier(calleePath)) {
const [messageParts, messagePartLocations] = unwrapMessagePartsFromLocalizeCall(callPath, fs);
const [expressions, expressionLocations] = unwrapSubstitutionsFromLocalizeCall(callPath, fs);
const [messagePartsArg, expressionsArg] = callPath.get("arguments");
const location = getLocation(fs, messagePartsArg, expressionsArg);
const message = parseMessage(messageParts, expressions, location, messagePartLocations, expressionLocations);
messages.push(message);
}
} catch (e) {
if (isBabelParseError(e)) {
throw buildCodeFrameError(fs, callPath, state.file, e);
} else {
throw e;
}
}
}
}
};
}
// packages/localize/tools/src/extract/extraction.js
var MessageExtractor = class {
fs;
logger;
basePath;
useSourceMaps;
localizeName;
loader;
constructor(fs, logger, { basePath, useSourceMaps = true, localizeName = "$localize" }) {
this.fs = fs;
this.logger = logger;
this.basePath = basePath;
this.useSourceMaps = useSourceMaps;
this.localizeName = localizeName;
this.loader = new SourceFileLoader(this.fs, this.logger, { webpack: basePath });
}
extractMessages(filename) {
const messages = [];
const sourceCode = this.fs.readFile(this.fs.resolve(this.basePath, filename));
if (sourceCode.includes(this.localizeName)) {
transformSync(sourceCode, {
sourceRoot: this.basePath,
filename,
plugins: [
makeEs2015ExtractPlugin(this.fs, messages, this.localizeName),
makeEs5ExtractPlugin(this.fs, messages, this.localizeName)
],
code: false,
ast: false
});
if (this.useSourceMaps && messages.length > 0) {
this.updateSourceLocations(filename, sourceCode, messages);
}
}
return messages;
}
/**
* Update the location of each message to point to the source-mapped original source location, if
* available.
*/
updateSourceLocations(filename, contents, messages) {
const sourceFile = this.loader.loadSourceFile(this.fs.resolve(this.basePath, filename), contents);
if (sourceFile === null) {
return;
}
for (const message of messages) {
if (message.location !== void 0) {
message.location = this.getOriginalLocation(sourceFile, message.location);
if (message.messagePartLocations) {
message.messagePartLocations = message.messagePartLocations.map((location) => location && this.getOriginalLocation(sourceFile, location));
}
if (message.substitutionLocations) {
const placeholderNames = Object.keys(message.substitutionLocations);
for (const placeholderName of placeholderNames) {
const location = message.substitutionLocations[placeholderName];
message.substitutionLocations[placeholderName] = location && this.getOriginalLocation(sourceFile, location);
}
}
}
}
}
/**
* Find the original location using source-maps if available.
*
* @param sourceFile The generated `sourceFile` that contains the `location`.
* @param location The location within the generated `sourceFile` that needs mapping.
*
* @returns A new location that refers to the original source location mapped from the given
* `location` in the generated `sourceFile`.
*/
getOriginalLocation(sourceFile, location) {
const originalStart = sourceFile.getOriginalLocation(location.start.line, location.start.column);
if (originalStart === null) {
return location;
}
const originalEnd = sourceFile.getOriginalLocation(location.end.line, location.end.column);
const start = { line: originalStart.line, column: originalStart.column };
const end = originalEnd !== null && originalEnd.file === originalStart.file ? { line: originalEnd.line, column: originalEnd.column } : start;
const originalSourceFile = sourceFile.sources.find((sf) => sf?.sourcePath === originalStart.file);
const startPos = originalSourceFile.startOfLinePositions[start.line] + start.column;
const endPos = originalSourceFile.startOfLinePositions[end.line] + end.column;
const text = originalSourceFile.contents.substring(startPos, endPos).trim();
return { file: originalStart.file, start, end, text };
}
};
// packages/localize/tools/src/extract/translation_files/utils.js
function consolidateMessages(messages, getMessageId2) {
const messageGroups = /* @__PURE__ */ new Map();
for (const message of messages) {
const id = getMessageId2(message);
if (!messageGroups.has(id)) {
messageGroups.set(id, [message]);
} else {
messageGroups.get(id).push(message);
}
}
for (const messages2 of messageGroups.values()) {
messages2.sort(compareLocations);
}
return Array.from(messageGroups.values()).sort((a1, a2) => compareLocations(a1[0], a2[0]));
}
function hasLocation(message) {
return message.location !== void 0;
}
function compareLocations({ location: location1 }, { location: location2 }) {
if (location1 === location2) {
return 0;
}
if (location1 === void 0) {
return -1;
}
if (location2 === void 0) {
return 1;
}
if (location1.file !== location2.file) {
return location1.file < location2.file ? -1 : 1;
}
if (location1.start.line !== location2.start.line) {
return location1.start.line < location2.start.line ? -1 : 1;
}
if (location1.start.column !== location2.start.column) {
return location1.start.column < location2.start.column ? -1 : 1;
}
return 0;
}
// packages/localize/tools/src/extract/translation_files/arb_translation_serializer.js
var ArbTranslationSerializer = class {
sourceLocale;
basePath;
fs;
constructor(sourceLocale, basePath, fs) {
this.sourceLocale = sourceLocale;
this.basePath = basePath;
this.fs = fs;
}
serialize(messages) {
const messageGroups = consolidateMessages(messages, (message) => getMessageId(message));
let output = `{
"@@locale": ${JSON.stringify(this.sourceLocale)}`;
for (const duplicateMessages of messageGroups) {
const message = duplicateMessages[0];
const id = getMessageId(message);
output += this.serializeMessage(id, message);
output += this.serializeMeta(id, message.description, message.meaning, duplicateMessages.filter(hasLocation).map((m) => m.location));
}
output += "\n}";
return output;
}
serializeMessage(id, message) {
return `,
${JSON.stringify(id)}: ${JSON.stringify(message.text)}`;
}
serializeMeta(id, description, meaning, locations) {
const meta = [];
if (description) {
meta.push(`
"description": ${JSON.stringify(description)}`);
}
if (meaning) {
meta.push(`
"x-meaning": ${JSON.stringify(meaning)}`);
}
if (locations.length > 0) {
let locationStr = `
"x-locations": [`;
for (let i = 0; i < locations.length; i++) {
locationStr += (i > 0 ? ",\n" : "\n") + this.serializeLocation(locations[i]);
}
locationStr += "\n ]";
meta.push(locationStr);
}
return meta.length > 0 ? `,
${JSON.stringify("@" + id)}: {${meta.join(",")}
}` : "";
}
serializeLocation({ file, start, end }) {
return [
` {`,
` "file": ${JSON.stringify(this.fs.relative(this.basePath, file))},`,
` "start": { "line": "${start.line}", "column": "${start.column}" },`,
` "end": { "line": "${end.line}", "column": "${end.column}" }`,
` }`
].join("\n");
}
};
function getMessageId(message) {
return message.customId || message.id;
}
// packages/localize/tools/src/extract/translation_files/json_translation_serializer.js
var SimpleJsonTranslationSerializer = class {
sourceLocale;
constructor(sourceLocale) {
this.sourceLocale = sourceLocale;
}
serialize(messages) {
const fileObj = { locale: this.sourceLocale, translations: {} };
for (const [message] of consolidateMessages(messages, (message2) => message2.id)) {
fileObj.translations[message.id] = message.text;
}
return JSON.stringify(fileObj, null, 2);
}
};
// packages/localize/tools/src/extract/translation_files/legacy_message_id_migration_serializer.js
var LegacyMessageIdMigrationSerializer = class {
_diagnostics;
constructor(_diagnostics) {
this._diagnostics = _diagnostics;
}
serialize(messages) {
let hasMessages = false;
const mapping = messages.reduce((output, message) => {
if (shouldMigrate(message)) {
for (const legacyId of message.legacyIds) {
if (output.hasOwnProperty(legacyId)) {
this._diagnostics.warn(`Detected duplicate legacy ID ${legacyId}.`);
}
output[legacyId] = message.id;
hasMessages = true;
}
}
return output;
}, {});
if (!hasMessages) {
this._diagnostics.warn("Could not find any legacy message IDs in source files while generating the legacy message migration file.");
}
return JSON.stringify(mapping, null, 2);
}
};
function shouldMigrate(message) {
return !message.customId && !!message.legacyIds && message.legacyIds.length > 0;
}
// packages/localize/tools/src/extract/translation_files/format_options.js
function validateOptions(name, validOptions, options) {
const validOptionsMap = new Map(validOptions);
for (const option in options) {
if (!validOptionsMap.has(option)) {
throw new Error(`Invalid format option for ${name}: "${option}".
Allowed options are ${JSON.stringify(Array.from(validOptionsMap.keys()))}.`);
}
const validOptionValues = validOptionsMap.get(option);
const optionValue = options[option];
if (!validOptionValues.includes(optionValue)) {
throw new Error(`Invalid format option value for ${name}: "${option}".
Allowed option values are ${JSON.stringify(validOptionValues)} but received "${optionValue}".`);
}
}
}
function parseFormatOptions(optionString = "{}") {
return JSON.parse(optionString);
}
// packages/localize/tools/src/extract/translation_files/xliff1_translation_serializer.js
import { getFileSystem } from "@angular/compiler-cli/private/localize";
// packages/localize/tools/src/extract/translation_files/icu_parsing.js
function extractIcuPlaceholders(text) {
const state = new StateStack();
const pieces = new IcuPieces();
const braces = /[{}]/g;
let lastPos = 0;
let match;
while (match = braces.exec(text)) {
if (match[0] == "{") {
state.enterBlock();
} else {
state.leaveBlock();
}
if (state.getCurrent() === "placeholder") {
const name = tryParsePlaceholder(text, braces.lastIndex);
if (name) {
pieces.addText(text.substring(lastPos, braces.lastIndex - 1));
pieces.addPlaceholder(name);
braces.lastIndex += name.length + 1;
state.leaveBlock();
} else {
pieces.addText(text.substring(lastPos, braces.lastIndex));
state.nestedIcu();
}
} else {
pieces.addText(text.substring(lastPos, braces.lastIndex));
}
lastPos = braces.lastIndex;
}
pieces.addText(text.substring(lastPos));
return pieces.toArray();
}
var IcuPieces = class {
pieces = [""];
/**
* Add the given `text` to the current "static text" piece.
*
* Sequential calls to `addText()` will append to the current text piece.
*/
addText(text) {
this.pieces[this.pieces.length - 1] += text;
}
/**
* Add the given placeholder `name` to the stored pieces.
*/
addPlaceholder(name) {
this.pieces.push(name);
this.pieces.push("");
}
/**
* Return the stored pieces as an array of strings.
*
* Even values are static strings (e.g. 0, 2, 4, etc)
* Odd values are placeholder names (e.g. 1, 3, 5, etc)
*/
toArray() {
return this.pieces;
}
};
var StateStack = class {
stack = [];
/**
* Update the state upon entering a block.
*
* The new state is computed from the current state and added to the stack.
*/
enterBlock() {
const current = this.getCurrent();
switch (current) {
case "icu":
this.stack.push("case");
break;
case "case":
this.stack.push("placeholder");
break;
case "placeholder":
this.stack.push("case");
break;
default:
this.stack.push("icu");
break;
}
}
/**
* Update the state upon leaving a block.
*
* The previous state is popped off the stack.
*/
leaveBlock() {
return this.stack.pop();
}
/**
* Update the state upon arriving at a nested ICU.
*
* In this case, the current state of "placeholder" is incorrect, so this is popped off and the
* correct "icu" state is stored.
*/
nestedIcu() {
const current = this.stack.pop();
assert(current === "placeholder", "A nested ICU must replace a placeholder but got " + current);
this.stack.push("icu");
}
/**
* Get the current (most recent) state from the stack.
*/
getCurrent() {
return this.stack[this.stack.length - 1];
}
};
function tryParsePlaceholder(text, start) {
for (let i = start; i < text.length; i++) {
if (text[i] === ",") {
break;
}
if (text[i] === "}") {
return text.substring(start, i);
}
}
return null;
}
function assert(test, message) {
if (!test) {
throw new Error("Assertion failure: " + message);
}
}
// packages/localize/tools/src/extract/translation_files/xml_file.js
var XmlFile = class {
output = '<?xml version="1.0" encoding="UTF-8" ?>\n';
indent = "";
elements = [];
preservingWhitespace = false;
toString() {
return this.output;
}
startTag(name, attributes = {}, { selfClosing = false, preserveWhitespace } = {}) {
if (!this.preservingWhitespace) {
this.output += this.indent;
}
this.output += `<${name}`;
for (const [attrName, attrValue] of Object.entries(attributes)) {
if (attrValue) {
this.output += ` ${attrName}="${escapeXml(attrValue)}"`;
}
}
if (selfClosing) {
this.output += "/>";
} else {
this.output += ">";
this.elements.push(name);
this.incIndent();
}
if (preserveWhitespace !== void 0) {
this.preservingWhitespace = preserveWhitespace;
}
if (!this.preservingWhitespace) {
this.output += `
`;
}
return this;
}
endTag(name, { preserveWhitespace } = {}) {
const expectedTag = this.elements.pop();
if (expectedTag !== name) {
throw new Error(`Unexpected closing tag: "${name}", expected: "${expectedTag}"`);
}
this.decIndent();
if (!this.preservingWhitespace) {
this.output += this.indent;
}
this.output += `</${name}>`;
if (preserveWhitespace !== void 0) {
this.preservingWhitespace = preserveWhitespace;
}
if (!this.preservingWhitespace) {
this.output += `
`;
}
return this;
}
text(str) {
this.output += escapeXml(str);
return this;
}
rawText(str) {
this.output += str;
return this;
}
incIndent() {
this.indent = this.indent + " ";
}
decIndent() {
this.indent = this.indent.slice(0, -2);
}
};
var _ESCAPED_CHARS = [
[/&/g, "&amp;"],
[/"/g, "&quot;"],
[/'/g, "&apos;"],
[/</g, "&lt;"],
[/>/g, "&gt;"]
];
function escapeXml(text) {
return _ESCAPED_CHARS.reduce((text2, entry) => text2.replace(entry[0], entry[1]), text);
}
// packages/localize/tools/src/extract/translation_files/xliff1_translation_serializer.js
var LEGACY_XLIFF_MESSAGE_LENGTH = 40;
var Xliff1TranslationSerializer = class {
sourceLocale;
basePath;
useLegacyIds;
formatOptions;
fs;
constructor(sourceLocale, basePath, useLegacyIds, formatOptions = {}, fs = getFileSystem()) {
this.sourceLocale = sourceLocale;
this.basePath = basePath;
this.useLegacyIds = useLegacyIds;
this.formatOptions = formatOptions;
this.fs = fs;
validateOptions("Xliff1TranslationSerializer", [["xml:space", ["preserve"]]], formatOptions);
}
serialize(messages) {
const messageGroups = consolidateMessages(messages, (message) => this.getMessageId(message));
const xml = new XmlFile();
xml.startTag("xliff", { "version": "1.2", "xmlns": "urn:oasis:names:tc:xliff:document:1.2" });
xml.startTag("file", {
"source-language": this.sourceLocale,
"datatype": "plaintext",
"original": "ng2.template",
...this.formatOptions
});
xml.startTag("body");
for (const duplicateMessages of messageGroups) {
const message = duplicateMessages[0];
const id = this.getMessageId(message);
xml.startTag("trans-unit", { id, datatype: "html" });
xml.startTag("source", {}, { preserveWhitespace: true });
this.serializeMessage(xml, message);
xml.endTag("source", { preserveWhitespace: false });
for (const { location } of duplicateMessages.filter(hasLocation)) {
this.serializeLocation(xml, location);
}
if (message.description) {
this.serializeNote(xml, "description", message.description);
}
if (message.meaning) {
this.serializeNote(xml, "meaning", message.meaning);
}
xml.endTag("trans-unit");
}
xml.endTag("body");
xml.endTag("file");
xml.endTag("xliff");
return xml.toString();
}
serializeMessage(xml, message) {
const length = message.messageParts.length - 1;
for (let i = 0; i < length; i++) {
this.serializeTextPart(xml, message.messageParts[i]);
const name = message.placeholderNames[i];
const location = message.substitutionLocations?.[name];
const associatedMessageId = message.associatedMessageIds && message.associatedMessageIds[name];
this.serializePlaceholder(xml, name, location?.text, associatedMessageId);
}
this.serializeTextPart(xml, message.messageParts[length]);
}
serializeTextPart(xml, text) {
const pieces = extractIcuPlaceholders(text);
const length = pieces.length - 1;
for (let i = 0; i < length; i += 2) {
xml.text(pieces[i]);
this.serializePlaceholder(xml, pieces[i + 1], void 0, void 0);
}
xml.text(pieces[length]);
}
serializePlaceholder(xml, id, text, associatedId) {
const attrs = { id };
const ctype = getCtypeForPlaceholder(id);
if (ctype !== null) {
attrs["ctype"] = ctype;
}
if (text !== void 0) {
attrs["equiv-text"] = text;
}
if (associatedId !== void 0) {
attrs["xid"] = associatedId;
}
xml.startTag("x", attrs, { selfClosing: true });
}
serializeNote(xml, name, value) {
xml.startTag("note", { priority: "1", from: name }, { preserveWhitespace: true });
xml.text(value);
xml.endTag("note", { preserveWhitespace: false });
}
serializeLocation(xml, location) {
xml.startTag("context-group", { purpose: "location" });
this.renderContext(xml, "sourcefile", this.fs.relative(this.basePath, location.file));
const endLineString = location.end !== void 0 && location.end.line !== location.start.line ? `,${location.end.line + 1}` : "";
this.renderContext(xml, "linenumber", `${location.start.line + 1}${endLineString}`);
xml.endTag("context-group");
}
renderContext(xml, type, value) {
xml.startTag("context", { "context-type": type }, { preserveWhitespace: true });
xml.text(value);
xml.endTag("context", { preserveWhitespace: false });
}
/**
* Get the id for the given `message`.
*
* If there was a custom id provided, use that.
*
* If we have requested legacy message ids, then try to return the appropriate id
* from the list of legacy ids that were extracted.
*
* Otherwise return the canonical message id.
*
* An Xliff 1.2 legacy message id is a hex encoded SHA-1 string, which is 40 characters long. See
* https://csrc.nist.gov/csrc/media/publications/fips/180/4/final/documents/fips180-4-draft-aug2014.pdf
*/
getMessageId(message) {
return message.customId || this.useLegacyIds && message.legacyIds !== void 0 && message.legacyIds.find((id) => id.length === LEGACY_XLIFF_MESSAGE_LENGTH) || message.id;
}
};
function getCtypeForPlaceholder(placeholder) {
const tag = placeholder.replace(/^(START_|CLOSE_)/, "");
switch (tag) {
case "LINE_BREAK":
return "lb";
case "TAG_IMG":
return "image";
default:
const element = tag.startsWith("TAG_") ? tag.replace(/^TAG_(.+)/, (_, tagName) => tagName.toLowerCase()) : TAG_MAP[tag];
if (element === void 0) {
return null;
}
return `x-${element}`;
}
}
var TAG_MAP = {
"LINK": "a",
"BOLD_TEXT": "b",
"EMPHASISED_TEXT": "em",
"HEADING_LEVEL1": "h1",
"HEADING_LEVEL2": "h2",
"HEADING_LEVEL3": "h3",
"HEADING_LEVEL4": "h4",
"HEADING_LEVEL5": "h5",
"HEADING_LEVEL6": "h6",
"HORIZONTAL_RULE": "hr",
"ITALIC_TEXT": "i",
"LIST_ITEM": "li",
"MEDIA_LINK": "link",
"ORDERED_LIST": "ol",
"PARAGRAPH": "p",
"QUOTATION": "q",
"STRIKETHROUGH_TEXT": "s",
"SMALL_TEXT": "small",
"SUBSTRIPT": "sub",
"SUPERSCRIPT": "sup",
"TABLE_BODY": "tbody",
"TABLE_CELL": "td",
"TABLE_FOOTER": "tfoot",
"TABLE_HEADER_CELL": "th",
"TABLE_HEADER": "thead",
"TABLE_ROW": "tr",
"MONOSPACED_TEXT": "tt",
"UNDERLINED_TEXT": "u",
"UNORDERED_LIST": "ul"
};
// packages/localize/tools/src/extract/translation_files/xliff2_translation_serializer.js
import { getFileSystem as getFileSystem2 } from "@angular/compiler-cli/private/localize";
var MAX_LEGACY_XLIFF_2_MESSAGE_LENGTH = 20;
var Xliff2TranslationSerializer = class {
sourceLocale;
basePath;
useLegacyIds;
formatOptions;
fs;
currentPlaceholderId = 0;
constructor(sourceLocale, basePath, useLegacyIds, formatOptions = {}, fs = getFileSystem2()) {
this.sourceLocale = sourceLocale;
this.basePath = basePath;
this.useLegacyIds = useLegacyIds;
this.formatOptions = formatOptions;
this.fs = fs;
validateOptions("Xliff1TranslationSerializer", [["xml:space", ["preserve"]]], formatOptions);
}
serialize(messages) {
const messageGroups = consolidateMessages(messages, (message) => this.getMessageId(message));
const xml = new XmlFile();
xml.startTag("xliff", {
"version": "2.0",
"xmlns": "urn:oasis:names:tc:xliff:document:2.0",
"srcLang": this.sourceLocale
});
xml.startTag("file", { "id": "ngi18n", "original": "ng.template", ...this.formatOptions });
for (const duplicateMessages of messageGroups) {
const message = duplicateMessages[0];
const id = this.getMessageId(message);
xml.startTag("unit", { id });
const messagesWithLocations = duplicateMessages.filter(hasLocation);
if (message.meaning || message.description || messagesWithLocations.length) {
xml.startTag("notes");
for (const { location: { file, start, end } } of messagesWithLocations) {
const endLineString = end !== void 0 && end.line !== start.line ? `,${end.line + 1}` : "";
this.serializeNote(xml, "location", `${this.fs.relative(this.basePath, file)}:${start.line + 1}${endLineString}`);
}
if (message.description) {
this.serializeNote(xml, "description", message.description);
}
if (message.meaning) {
this.serializeNote(xml, "meaning", message.meaning);
}
xml.endTag("notes");
}
xml.startTag("segment");
xml.startTag("source", {}, { preserveWhitespace: true });
this.serializeMessage(xml, message);
xml.endTag("source", { preserveWhitespace: false });
xml.endTag("segment");
xml.endTag("unit");
}
xml.endTag("file");
xml.endTag("xliff");
return xml.toString();
}
serializeMessage(xml, message) {
this.currentPlaceholderId = 0;
const length = message.messageParts.length - 1;
for (let i = 0; i < length; i++) {
this.serializeTextPart(xml, message.messageParts[i]);
const name = message.placeholderNames[i];
const associatedMessageId = message.associatedMessageIds && message.associatedMessageIds[name];
this.serializePlaceholder(xml, name, message.substitutionLocations, associatedMessageId);
}
this.serializeTextPart(xml, message.messageParts[length]);
}
serializeTextPart(xml, text) {
const pieces = extractIcuPlaceholders(text);
const length = pieces.length - 1;
for (let i = 0; i < length; i += 2) {
xml.text(pieces[i]);
this.serializePlaceholder(xml, pieces[i + 1], void 0, void 0);
}
xml.text(pieces[length]);
}
serializePlaceholder(xml, placeholderName, substitutionLocations, associatedMessageId) {
const text = substitutionLocations?.[placeholderName]?.text;
if (placeholderName.startsWith("START_")) {
const closingPlaceholderName = placeholderName.replace(/^START/, "CLOSE").replace(/_\d+$/, "");
const closingText = substitutionLocations?.[closingPlaceholderName]?.text;
const attrs = {
id: `${this.currentPlaceholderId++}`,
equivStart: placeholderName,
equivEnd: closingPlaceholderName
};
const type = getTypeForPlaceholder(placeholderName);
if (type !== null) {
attrs["type"] = type;
}
if (text !== void 0) {
attrs["dispStart"] = text;
}
if (closingText !== void 0) {
attrs["dispEnd"] = closingText;
}
xml.startTag("pc", attrs);
} else if (placeholderName.startsWith("CLOSE_")) {
xml.endTag("pc");
} else {
const attrs = {
id: `${this.currentPlaceholderId++}`,
equiv: placeholderName
};
const type = getTypeForPlaceholder(placeholderName);
if (type !== null) {
attrs["type"] = type;
}
if (text !== void 0) {
attrs["disp"] = text;
}
if (associatedMessageId !== void 0) {
attrs["subFlows"] = associatedMessageId;
}
xml.startTag("ph", attrs, { selfClosing: true });
}
}
serializeNote(xml, name, value) {
xml.startTag("note", { category: name }, { preserveWhitespace: true });
xml.text(value);
xml.endTag("note", { preserveWhitespace: false });
}
/**
* Get the id for the given `message`.
*
* If there was a custom id provided, use that.
*
* If we have requested legacy message ids, then try to return the appropriate id
* from the list of legacy ids that were extracted.
*
* Otherwise return the canonical message id.
*
* An Xliff 2.0 legacy message id is a 64 bit number encoded as a decimal string, which will have
* at most 20 digits, since 2^65-1 = 36,893,488,147,419,103,231. This digest is based on:
* https://github.com/google/closure-compiler/blob/master/src/com/google/javascript/jscomp/GoogleJsMessageIdGenerator.java
*/
getMessageId(message) {
return message.customId || this.useLegacyIds && message.legacyIds !== void 0 && message.legacyIds.find((id) => id.length <= MAX_LEGACY_XLIFF_2_MESSAGE_LENGTH && !/[^0-9]/.test(id)) || message.id;
}
};
function getTypeForPlaceholder(placeholder) {
const tag = placeholder.replace(/^(START_|CLOSE_)/, "").replace(/_\d+$/, "");
switch (tag) {
case "BOLD_TEXT":
case "EMPHASISED_TEXT":
case "ITALIC_TEXT":
case "LINE_BREAK":
case "STRIKETHROUGH_TEXT":
case "UNDERLINED_TEXT":
return "fmt";
case "TAG_IMG":
return "image";
case "LINK":
return "link";
default:
return /^(START_|CLOSE_)/.test(placeholder) ? "other" : null;
}
}
// packages/localize/tools/src/extract/translation_files/xmb_translation_serializer.js
import { getFileSystem as getFileSystem3 } from "@angular/compiler-cli/private/localize";
var XMB_HANDLER = "angular";
var XmbTranslationSerializer = class {
basePath;
useLegacyIds;
fs;
constructor(basePath, useLegacyIds, fs = getFileSystem3()) {
this.basePath = basePath;
this.useLegacyIds = useLegacyIds;
this.fs = fs;
}
serialize(messages) {
const messageGroups = consolidateMessages(messages, (message) => this.getMessageId(message));
const xml = new XmlFile();
xml.rawText(`<!DOCTYPE messagebundle [
<!ELEMENT messagebundle (msg)*>
<!ATTLIST messagebundle class CDATA #IMPLIED>
<!ELEMENT msg (#PCDATA|ph|source)*>
<!ATTLIST msg id CDATA #IMPLIED>
<!ATTLIST msg seq CDATA #IMPLIED>
<!ATTLIST msg name CDATA #IMPLIED>
<!ATTLIST msg desc CDATA #IMPLIED>
<!ATTLIST msg meaning CDATA #IMPLIED>
<!ATTLIST msg obsolete (obsolete) #IMPLIED>
<!ATTLIST msg xml:space (default|preserve) "default">
<!ATTLIST msg is_hidden CDATA #IMPLIED>
<!ELEMENT source (#PCDATA)>
<!ELEMENT ph (#PCDATA|ex)*>
<!ATTLIST ph name CDATA #REQUIRED>
<!ELEMENT ex (#PCDATA)>
]>
`);
xml.startTag("messagebundle", {
"handler": XMB_HANDLER
});
for (const duplicateMessages of messageGroups) {
const message = duplicateMessages[0];
const id = this.getMessageId(message);
xml.startTag("msg", { id, desc: message.description, meaning: message.meaning }, { preserveWhitespace: true });
if (message.location) {
this.serializeLocation(xml, message.location);
}
this.serializeMessage(xml, message);
xml.endTag("msg", { preserveWhitespace: false });
}
xml.endTag("messagebundle");
return xml.toString();
}
serializeLocation(xml, location) {
xml.startTag("source");
const endLineString = location.end !== void 0 && location.end.line !== location.start.line ? `,${location.end.line + 1}` : "";
xml.text(`${this.fs.relative(this.basePath, location.file)}:${location.start.line}${endLineString}`);
xml.endTag("source");
}
serializeMessage(xml, message) {
const length = message.messageParts.length - 1;
for (let i = 0; i < length; i++) {
this.serializeTextPart(xml, message.messageParts[i]);
xml.startTag("ph", { name: message.placeholderNames[i] }, { selfClosing: true });
}
this.serializeTextPart(xml, message.messageParts[length]);
}
serializeTextPart(xml, text) {
const pieces = extractIcuPlaceholders(text);
const length = pieces.length - 1;
for (let i = 0; i < length; i += 2) {
xml.text(pieces[i]);
xml.startTag("ph", { name: pieces[i + 1] }, { selfClosing: true });
}
xml.text(pieces[length]);
}
/**
* Get the id for the given `message`.
*
* If there was a custom id provided, use that.
*
* If we have requested legacy message ids, then try to return the appropriate id
* from the list of legacy ids that were extracted.
*
* Otherwise return the canonical message id.
*
* An XMB legacy message id is a 64 bit number encoded as a decimal string, which will have
* at most 20 digits, since 2^65-1 = 36,893,488,147,419,103,231. This digest is based on:
* https://github.com/google/closure-compiler/blob/master/src/com/google/javascript/jscomp/GoogleJsMessageIdGenerator.java
*/
getMessageId(message) {
return message.customId || this.useLegacyIds && message.legacyIds !== void 0 && message.legacyIds.find((id) => id.length <= 20 && !/[^0-9]/.test(id)) || message.id;
}
};
export {
checkDuplicateMessages,
MessageExtractor,
ArbTranslationSerializer,
SimpleJsonTranslationSerializer,
LegacyMessageIdMigrationSerializer,
parseFormatOptions,
Xliff1TranslationSerializer,
Xliff2TranslationSerializer,
XmbTranslationSerializer
};
/**
* @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.dev/license
*/
//# sourceMappingURL=chunk-VVP7L7WP.js.map
{
"version": 3,
"sources": ["../src/extract/duplicates.ts", "../src/extract/extraction.ts", "../src/extract/source_files/es2015_extract_plugin.ts", "../src/extract/source_files/es5_extract_plugin.ts", "../src/extract/translation_files/utils.ts", "../src/extract/translation_files/arb_translation_serializer.ts", "../src/extract/translation_files/json_translation_serializer.ts", "../src/extract/translation_files/legacy_message_id_migration_serializer.ts", "../src/extract/translation_files/format_options.ts", "../src/extract/translation_files/xliff1_translation_serializer.ts", "../src/extract/translation_files/icu_parsing.ts", "../src/extract/translation_files/xml_file.ts", "../src/extract/translation_files/xliff2_translation_serializer.ts", "../src/extract/translation_files/xmb_translation_serializer.ts"],
"mappings":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,SAAS,IAAI,OAAO,CAAC,KACzB;AACN,QAAI,KACF,GAAG,KAAK,GAAG,SAAS,KAAK,UAAU,SAAS,IAAI,CAAC,IAAI,SAAS,MAAM,IAAI,GAAG,aAAa,EAAE;AAE5F,QAAI,OAAO,QAAQ;EACrB;EAEQ,iBAAiB,KAAc,SAAuB;AAC5D,UAAM,SAAS,QAAQ,aAAa,SAAS;AAC7C,aAAS,IAAI,GAAG,IAAI,QAAQ,KAAK;AAC/B,WAAK,kBAAkB,KAAK,QAAQ,aAAa,CAAC,CAAC;AACnD,UAAI,SAAS,MAAM,EAAC,MAAM,QAAQ,iBAAiB,CAAC,EAAC,GAAG,EAAC,aAAa,KAAI,CAAC;IAC7E;AACA,SAAK,kBAAkB,KAAK,QAAQ,aAAa,MAAM,CAAC;EAC1D;EAEQ,kBAAkB,KAAc,MAAY;AAClD,UAAM,SAAS,uBAAuB,IAAI;AAC1C,UAAM,SAAS,OAAO,SAAS;AAC/B,aAAS,IAAI,GAAG,IAAI,QAAQ,KAAK,GAAG;AAClC,UAAI,KAAK,OAAO,CAAC,CAAC;AAClB,UAAI,SAAS,MAAM,EAAC,MAAM,OAAO,IAAI,CAAC,EAAC,GAAG,EAAC,aAAa,KAAI,CAAC;IAC/D;AACA,QAAI,KAAK,OAAO,MAAM,CAAC;EACzB;;;;;;;;;;;;;;;EAgBQ,aAAa,SAAuB;AAC1C,WACE,QAAQ,YACP,KAAK,gBACJ,QAAQ,cAAc,UACtB,QAAQ,UAAU,KAAK,CAAC,OAAO,GAAG,UAAU,MAAM,CAAC,SAAS,KAAK,EAAE,CAAC,KACtE,QAAQ;EAEZ;;",
"names": ["getMessageId", "messages", "message", "text", "getFileSystem", "getFileSystem", "getFileSystem", "getFileSystem"]
}
{
"version": 3,
"sources": ["../index.ts"],
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAWA,SAAQ,kBAAkB,qBAAoB;AAC9C,cAAc,IAAI,iBAAiB,CAAC;",
"names": []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ACA,OAAO,iBAAiB;AAAA,EACvB,MAAM;AAAA,EACN,SAAS;AAAA,EACT,UACE;AACJ,CAAC,EACA,OAAO,gBAAgB;AAAA,EACtB,MAAM;AAAA,EACN,SAAS;AAAA,EACT,UACE;AACJ,CAAC,EACA,OAAO,KAAK;AAAA,EACX,OAAO;AAAA,EACP,UAAU;AAAA,EACV,SAAS,CAAC,SAAS,WAAW,QAAQ;AAAA,EACtC,SAAS;AAAA,EACT,MAAM;AACR,CAAC,EACA,OAAO,EACP,KAAK,EACL,UAAU;AAEb,IAAM,aAAa,IAAI,iBAAiB;AACxC,cAAc,UAAU;AAExB,IAAM,WAAW,QAAQ;AACzB,IAAM,kBAAkB,SAAS,QAAQ,GAAG,EAAC,KAAK,SAAQ,CAAC;AAC3D,IAAM,WAAW,QAAQ;AACzB,IAAM,SAAS,IAAI,cAAc,WAAW,SAAS,QAAQ,IAAI,SAAS,IAAI;AAC9E,IAAM,2BAA2B,QAAQ;AACzC,IAAM,gBAAgB,mBAAmB,QAAQ,aAAa;AAC9D,IAAM,SAAS,QAAQ;AAEvB,oBAAoB;AAAA,EAClB;AAAA,EACA;AAAA,EACA,cAAc,QAAQ;AAAA,EACtB;AAAA,EACA,YAAY,QAAQ;AAAA,EACpB;AAAA,EACA,eAAe,QAAQ;AAAA,EACvB,cAAc,WAAW,oBAAoB,QAAQ;AAAA,EACrD;AAAA,EACA;AAAA,EACA;AACF,CAAC;",
"names": ["rootPath", "sourceFilePaths", "format", "logger", "duplicateMessageHandling", "formatOptions"]
}
{
"version": 3,
"sources": ["../../../src/migrate/cli.ts", "../../../src/migrate/index.ts", "../../../src/migrate/migrate.ts"],
"mappings": ";;;;;;;AASA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAQ,gBAAe;AACvB,OAAO,WAAW;;;ACRlB,SAAQ,qBAA4B;;;ACM9B,SAAU,YAAY,YAAoB,SAAyB;AACvE,QAAM,YAAY,OAAO,KAAK,OAAO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AAQ;AACzB,IAAM,uBAAuB,SAAS,QAAQ,GAAG,EAAC,KAAK,UAAU,WAAW,KAAI,CAAC;AACjF,IAAM,SAAS,IAAI,cAAc,SAAS,IAAI;AAE9C,aAAa,EAAC,UAAU,sBAAsB,iBAAiB,QAAQ,GAAG,OAAM,CAAC;AACjF,QAAQ,KAAK,CAAC;",
"names": ["rootPath", "translationFilePaths", "logger", "fs"]
}
{
"version": 3,
"sources": ["../../../src/translate/cli.ts", "../../../src/translate/output_path.ts", "../../../src/translate/index.ts", "../../../src/translate/asset_files/asset_translation_handler.ts", "../../../src/translate/source_files/source_file_translation_handler.ts", "../../../src/translate/translation_files/translation_loader.ts", "../../../src/translate/translator.ts"],
"mappings": ";;;;;;;;;;;;;;;;;;;;AAQA,SAAQ,kBAAkB,qBAAoB;AAC9C,SAAQ,gBAAe;AACvB,OAAO,WAAW;;;ACcZ,SAAU,gBAAgBA,KAAsB,cAA4B;AAChF,QAAM,CAAC,KAAK,IAAI,IAAI,aAAa,MAAM,YAAY;AACnD,SAAO,SAAS,SACZ,CAAC,SAAS,iBAAiBA,IAAG,KAAK,KAAK,YAAY,IACpD,CAAC,QAAQ,iBAAiBA,IAAG,KAAK,MAAM,SAAS,MAAM,YAAY;AACzE;;;ACtBA,SAAQ,eAAe,oBAAmB;;;ACA1C,SACE,oBAIK;AASD,IAAO,0BAAP,MAA8B;EACd;EAApB,YAAoBC,KAAc;AAAd,SAAA,KAAAA;EAAiB;EAErC,aAAa,mBAAiD,WAAqB;AACjF,WAAO;EACT;EAEA,UACEC,cACA,aACA,kBACA,UACAC,eACA,cACAC,eAAqB;AAErB,eAAW,eAAe,cAAc;AACtC,WAAK,eACHF,cACAC,eACA,YAAY,QACZ,kBACA,QAAQ;IAEZ;AACA,QAAIC,kBAAiB,QAAW;AAC9B,WAAK,eAAeF,cAAaC,eAAcC,eAAc,kBAAkB,QAAQ;IACzF;EACF;EAEQ,eACNF,cACAC,eACA,QACA,kBACA,UAAoB;AAEpB,QAA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;AAED,YAAY,SAAS,QAAQ,CAAC,MAAM,QAAQ,KAAK,GAAG,EAAE,IAAI,KAAK,EAAE,OAAO,EAAE,CAAC;AAC3E,QAAQ,KAAK,YAAY,YAAY,IAAI,CAAC;AAO1C,SAAS,sBAAsBE,OAAuC;AACpE,SAAOA,MAAK;AAAA,IAAI,CAAC,QACf,IAAI,WAAW,GAAG,KAAK,IAAI,SAAS,GAAG,IACnC,IACG,MAAM,GAAG,EAAE,EACX,MAAM,GAAG,EACT,IAAI,CAACC,SAAQA,KAAI,KAAK,CAAC,IAC1B;AAAA,EACN;AACF;",
"names": ["fs", "fs", "diagnostics", "outputPathFn", "sourceLocale", "absoluteFrom", "fs", "diagnostics", "outputPathFn", "sourceLocale", "options", "absoluteFrom", "fs", "duplicateTranslation", "diagnostics", "translationFilePaths", "translationFileLocales", "fs", "diagnostics", "outputPathFn", "sourceLocale", "sourceRootPath", "sourceFilePaths", "translationFilePaths", "translationFileLocales", "outputPathFn", "diagnostics", "missingTranslation", "duplicateTranslation", "sourceLocale", "fs", "args", "arg"]
}
+1
-1
/**
* @license Angular v22.0.0-next.2
* @license Angular v22.0.0-next.3
* (c) 2010-2026 Google LLC. https://angular.dev/

@@ -4,0 +4,0 @@ * License: MIT

@@ -1,1 +0,1 @@

{"version":3,"file":"_localize-chunk.mjs","sources":["../../../../../k8-fastbuild-ST-fdfa778d11ba/bin/packages/localize/src/utils/src/constants.ts","../../../../../k8-fastbuild-ST-fdfa778d11ba/bin/packages/compiler/src/i18n/digest.ts","../../../../../k8-fastbuild-ST-fdfa778d11ba/bin/packages/localize/src/utils/src/messages.ts","../../../../../k8-fastbuild-ST-fdfa778d11ba/bin/packages/localize/src/localize/src/localize.ts"],"sourcesContent":["/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\n/**\n * The character used to mark the start and end of a \"block\" in a `$localize` tagged string.\n * A block can indicate metadata about the message or specify a name of a placeholder for a\n * substitution expressions.\n *\n * For example:\n *\n * ```ts\n * $localize`Hello, ${title}:title:!`;\n * $localize`:meaning|description@@id:source message text`;\n * ```\n */\nexport const BLOCK_MARKER = ':';\n\n/**\n * The marker used to separate a message's \"meaning\" from its \"description\" in a metadata block.\n *\n * For example:\n *\n * ```ts\n * $localize `:correct|Indicates that the user got the answer correct: Right!`;\n * $localize `:movement|Button label for moving to the right: Right!`;\n * ```\n */\nexport const MEANING_SEPARATOR = '|';\n\n/**\n * The marker used to separate a message's custom \"id\" from its \"description\" in a metadata block.\n *\n * For example:\n *\n * ```ts\n * $localize `:A welcome message on the home page@@myApp-homepage-welcome: Welcome!`;\n * ```\n */\nexport const ID_SEPARATOR = '@@';\n\n/**\n * The marker used to separate legacy message ids from the rest of a metadata block.\n *\n * For example:\n *\n * ```ts\n * $localize `:@@custom-id␟2df64767cd895a8fabe3e18b94b5b6b6f9e2e3f0: Welcome!`;\n * ```\n *\n * Note that this character is the \"symbol for the unit separator\" (␟) not the \"unit separator\n * character\" itself, since that has no visual representation. See https://graphemica.com/%E2%90%9F.\n *\n * Here is some background for the original \"unit separator character\":\n * https://stackoverflow.com/questions/8695118/whats-the-file-group-record-unit-separator-control-characters-and-its-usage\n */\nexport const LEGACY_ID_INDICATOR = '\\u241F';\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {Byte} from '../util';\n\nimport * as i18n from './i18n_ast';\n\n/**\n * A lazily created TextEncoder instance for converting strings into UTF-8 bytes\n */\nlet textEncoder: TextEncoder | undefined;\n\n/**\n * Return the message id or compute it using the XLIFF1 digest.\n */\nexport function digest(message: i18n.Message): string {\n return message.id || computeDigest(message);\n}\n\n/**\n * Compute the message id using the XLIFF1 digest.\n */\nexport function computeDigest(message: i18n.Message): string {\n return sha1(serializeNodes(message.nodes).join('') + `[${message.meaning}]`);\n}\n\n/**\n * Return the message id or compute it using the XLIFF2/XMB/$localize digest.\n */\nexport function decimalDigest(message: i18n.Message): string {\n return message.id || computeDecimalDigest(message);\n}\n\n/**\n * Compute the message id using the XLIFF2/XMB/$localize digest.\n */\nexport function computeDecimalDigest(message: i18n.Message): string {\n const visitor = new _SerializerIgnoreIcuExpVisitor();\n const parts = message.nodes.map((a) => a.visit(visitor, null));\n return computeMsgId(parts.join(''), message.meaning);\n}\n\n/**\n * Serialize the i18n ast to something xml-like in order to generate an UID.\n *\n * The visitor is also used in the i18n parser tests\n *\n * @internal\n */\nclass _SerializerVisitor implements i18n.Visitor {\n visitText(text: i18n.Text, context: any): any {\n return text.value;\n }\n\n visitContainer(container: i18n.Container, context: any): any {\n return `[${container.children.map((child) => child.visit(this)).join(', ')}]`;\n }\n\n visitIcu(icu: i18n.Icu, context: any): any {\n const strCases = Object.keys(icu.cases).map(\n (k: string) => `${k} {${icu.cases[k].visit(this)}}`,\n );\n return `{${icu.expression}, ${icu.type}, ${strCases.join(', ')}}`;\n }\n\n visitTagPlaceholder(ph: i18n.TagPlaceholder, context: any): any {\n return ph.isVoid\n ? `<ph tag name=\"${ph.startName}\"/>`\n : `<ph tag name=\"${ph.startName}\">${ph.children\n .map((child) => child.visit(this))\n .join(', ')}</ph name=\"${ph.closeName}\">`;\n }\n\n visitPlaceholder(ph: i18n.Placeholder, context: any): any {\n return ph.value ? `<ph name=\"${ph.name}\">${ph.value}</ph>` : `<ph name=\"${ph.name}\"/>`;\n }\n\n visitIcuPlaceholder(ph: i18n.IcuPlaceholder, context?: any): any {\n return `<ph icu name=\"${ph.name}\">${ph.value.visit(this)}</ph>`;\n }\n\n visitBlockPlaceholder(ph: i18n.BlockPlaceholder, context: any): any {\n return `<ph block name=\"${ph.startName}\">${ph.children\n .map((child) => child.visit(this))\n .join(', ')}</ph name=\"${ph.closeName}\">`;\n }\n}\n\nconst serializerVisitor = new _SerializerVisitor();\n\nexport function serializeNodes(nodes: i18n.Node[]): string[] {\n return nodes.map((a) => a.visit(serializerVisitor, null));\n}\n\n/**\n * Serialize the i18n ast to something xml-like in order to generate an UID.\n *\n * Ignore the ICU expressions so that message IDs stays identical if only the expression changes.\n *\n * @internal\n */\nclass _SerializerIgnoreIcuExpVisitor extends _SerializerVisitor {\n override visitIcu(icu: i18n.Icu): string {\n let strCases = Object.keys(icu.cases).map((k: string) => `${k} {${icu.cases[k].visit(this)}}`);\n // Do not take the expression into account\n return `{${icu.type}, ${strCases.join(', ')}}`;\n }\n}\n\n/**\n * Compute the SHA1 of the given string\n *\n * see https://csrc.nist.gov/publications/fips/fips180-4/fips-180-4.pdf\n *\n * WARNING: this function has not been designed not tested with security in mind.\n * DO NOT USE IT IN A SECURITY SENSITIVE CONTEXT.\n */\nexport function sha1(str: string): string {\n textEncoder ??= new TextEncoder();\n const utf8 = [...textEncoder.encode(str)];\n const words32 = bytesToWords32(utf8, Endian.Big);\n const len = utf8.length * 8;\n\n const w = new Uint32Array(80);\n let a = 0x67452301,\n b = 0xefcdab89,\n c = 0x98badcfe,\n d = 0x10325476,\n e = 0xc3d2e1f0;\n\n words32[len >> 5] |= 0x80 << (24 - (len % 32));\n words32[(((len + 64) >> 9) << 4) + 15] = len;\n\n for (let i = 0; i < words32.length; i += 16) {\n const h0 = a,\n h1 = b,\n h2 = c,\n h3 = d,\n h4 = e;\n\n for (let j = 0; j < 80; j++) {\n if (j < 16) {\n w[j] = words32[i + j];\n } else {\n w[j] = rol32(w[j - 3] ^ w[j - 8] ^ w[j - 14] ^ w[j - 16], 1);\n }\n\n const fkVal = fk(j, b, c, d);\n const f = fkVal[0];\n const k = fkVal[1];\n const temp = [rol32(a, 5), f, e, k, w[j]].reduce(add32);\n e = d;\n d = c;\n c = rol32(b, 30);\n b = a;\n a = temp;\n }\n a = add32(a, h0);\n b = add32(b, h1);\n c = add32(c, h2);\n d = add32(d, h3);\n e = add32(e, h4);\n }\n\n // Convert the output parts to a 160-bit hexadecimal string\n return toHexU32(a) + toHexU32(b) + toHexU32(c) + toHexU32(d) + toHexU32(e);\n}\n\n/**\n * Convert and format a number as a string representing a 32-bit unsigned hexadecimal number.\n * @param value The value to format as a string.\n * @returns A hexadecimal string representing the value.\n */\nfunction toHexU32(value: number): string {\n // unsigned right shift of zero ensures an unsigned 32-bit number\n return (value >>> 0).toString(16).padStart(8, '0');\n}\n\nfunction fk(index: number, b: number, c: number, d: number): [number, number] {\n if (index < 20) {\n return [(b & c) | (~b & d), 0x5a827999];\n }\n\n if (index < 40) {\n return [b ^ c ^ d, 0x6ed9eba1];\n }\n\n if (index < 60) {\n return [(b & c) | (b & d) | (c & d), 0x8f1bbcdc];\n }\n\n return [b ^ c ^ d, 0xca62c1d6];\n}\n\n/**\n * Compute the fingerprint of the given string\n *\n * The output is 64 bit number encoded as a decimal string\n *\n * based on:\n * https://github.com/google/closure-compiler/blob/master/src/com/google/javascript/jscomp/GoogleJsMessageIdGenerator.java\n */\nexport function fingerprint(str: string): bigint {\n textEncoder ??= new TextEncoder();\n const utf8 = textEncoder.encode(str);\n const view = new DataView(utf8.buffer, utf8.byteOffset, utf8.byteLength);\n\n let hi = hash32(view, utf8.length, 0);\n let lo = hash32(view, utf8.length, 102072);\n\n if (hi == 0 && (lo == 0 || lo == 1)) {\n hi = hi ^ 0x130f9bef;\n lo = lo ^ -0x6b5f56d8;\n }\n\n return (BigInt.asUintN(32, BigInt(hi)) << BigInt(32)) | BigInt.asUintN(32, BigInt(lo));\n}\n\nexport function computeMsgId(msg: string, meaning: string = ''): string {\n let msgFingerprint = fingerprint(msg);\n\n if (meaning) {\n // Rotate the 64-bit message fingerprint one bit to the left and then add the meaning\n // fingerprint.\n msgFingerprint =\n BigInt.asUintN(64, msgFingerprint << BigInt(1)) |\n ((msgFingerprint >> BigInt(63)) & BigInt(1));\n msgFingerprint += fingerprint(meaning);\n }\n\n return BigInt.asUintN(63, msgFingerprint).toString();\n}\n\nfunction hash32(view: DataView, length: number, c: number): number {\n let a = 0x9e3779b9,\n b = 0x9e3779b9;\n let index = 0;\n\n const end = length - 12;\n for (; index <= end; index += 12) {\n a += view.getUint32(index, true);\n b += view.getUint32(index + 4, true);\n c += view.getUint32(index + 8, true);\n const res = mix(a, b, c);\n ((a = res[0]), (b = res[1]), (c = res[2]));\n }\n\n const remainder = length - index;\n\n // the first byte of c is reserved for the length\n c += length;\n\n if (remainder >= 4) {\n a += view.getUint32(index, true);\n index += 4;\n\n if (remainder >= 8) {\n b += view.getUint32(index, true);\n index += 4;\n\n // Partial 32-bit word for c\n if (remainder >= 9) {\n c += view.getUint8(index++) << 8;\n }\n if (remainder >= 10) {\n c += view.getUint8(index++) << 16;\n }\n if (remainder === 11) {\n c += view.getUint8(index++) << 24;\n }\n } else {\n // Partial 32-bit word for b\n if (remainder >= 5) {\n b += view.getUint8(index++);\n }\n if (remainder >= 6) {\n b += view.getUint8(index++) << 8;\n }\n if (remainder === 7) {\n b += view.getUint8(index++) << 16;\n }\n }\n } else {\n // Partial 32-bit word for a\n if (remainder >= 1) {\n a += view.getUint8(index++);\n }\n if (remainder >= 2) {\n a += view.getUint8(index++) << 8;\n }\n if (remainder === 3) {\n a += view.getUint8(index++) << 16;\n }\n }\n\n return mix(a, b, c)[2];\n}\n\nfunction mix(a: number, b: number, c: number): [number, number, number] {\n a -= b;\n a -= c;\n a ^= c >>> 13;\n b -= c;\n b -= a;\n b ^= a << 8;\n c -= a;\n c -= b;\n c ^= b >>> 13;\n a -= b;\n a -= c;\n a ^= c >>> 12;\n b -= c;\n b -= a;\n b ^= a << 16;\n c -= a;\n c -= b;\n c ^= b >>> 5;\n a -= b;\n a -= c;\n a ^= c >>> 3;\n b -= c;\n b -= a;\n b ^= a << 10;\n c -= a;\n c -= b;\n c ^= b >>> 15;\n return [a, b, c];\n}\n\n// Utils\n\nenum Endian {\n Little,\n Big,\n}\n\nfunction add32(a: number, b: number): number {\n return add32to64(a, b)[1];\n}\n\nfunction add32to64(a: number, b: number): [number, number] {\n const low = (a & 0xffff) + (b & 0xffff);\n const high = (a >>> 16) + (b >>> 16) + (low >>> 16);\n return [high >>> 16, (high << 16) | (low & 0xffff)];\n}\n\n// Rotate a 32b number left `count` position\nfunction rol32(a: number, count: number): number {\n return (a << count) | (a >>> (32 - count));\n}\n\nfunction bytesToWords32(bytes: Byte[], endian: Endian): number[] {\n const size = (bytes.length + 3) >>> 2;\n const words32 = [];\n\n for (let i = 0; i < size; i++) {\n words32[i] = wordAt(bytes, i * 4, endian);\n }\n\n return words32;\n}\n\nfunction byteAt(bytes: Byte[], index: number): Byte {\n return index >= bytes.length ? 0 : bytes[index];\n}\n\nfunction wordAt(bytes: Byte[], index: number, endian: Endian): number {\n let word = 0;\n if (endian === Endian.Big) {\n for (let i = 0; i < 4; i++) {\n word += byteAt(bytes, index + i) << (24 - 8 * i);\n }\n } else {\n for (let i = 0; i < 4; i++) {\n word += byteAt(bytes, index + i) << (8 * i);\n }\n }\n return word;\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n// This module specifier is intentionally a relative path to allow bundling the code directly\n// into the package.\n// @ng_package: ignore-cross-repo-import\nimport {computeMsgId} from '../../../../compiler/src/i18n/digest';\n\nimport {BLOCK_MARKER, ID_SEPARATOR, LEGACY_ID_INDICATOR, MEANING_SEPARATOR} from './constants';\n\n/**\n * Re-export this helper function so that users of `@angular/localize` don't need to actively import\n * from `@angular/compiler`.\n */\nexport {computeMsgId};\n\n/**\n * A string containing a translation source message.\n *\n * I.E. the message that indicates what will be translated from.\n *\n * Uses `{$placeholder-name}` to indicate a placeholder.\n */\nexport type SourceMessage = string;\n\n/**\n * A string containing a translation target message.\n *\n * I.E. the message that indicates what will be translated to.\n *\n * Uses `{$placeholder-name}` to indicate a placeholder.\n *\n * @publicApi\n */\nexport type TargetMessage = string;\n\n/**\n * A string that uniquely identifies a message, to be used for matching translations.\n *\n * @publicApi\n */\nexport type MessageId = string;\n\n/**\n * Declares a copy of the `AbsoluteFsPath` branded type in `@angular/compiler-cli` to avoid an\n * import into `@angular/compiler-cli`. The compiler-cli's declaration files are not necessarily\n * compatible with web environments that use `@angular/localize`, and would inadvertently include\n * `typescript` declaration files in any compilation unit that uses `@angular/localize` (which\n * increases parsing time and memory usage during builds) using a default import that only\n * type-checks when `allowSyntheticDefaultImports` is enabled.\n *\n * @see https://github.com/angular/angular/issues/45179\n */\ntype AbsoluteFsPathLocalizeCopy = string & {_brand: 'AbsoluteFsPath'};\n\n/**\n * The location of the message in the source file.\n *\n * The `line` and `column` values for the `start` and `end` properties are zero-based.\n */\nexport interface SourceLocation {\n start: {line: number; column: number};\n end: {line: number; column: number};\n file: AbsoluteFsPathLocalizeCopy;\n text?: string;\n}\n\n/**\n * Additional information that can be associated with a message.\n */\nexport interface MessageMetadata {\n /**\n * A human readable rendering of the message\n */\n text: string;\n /**\n * Legacy message ids, if provided.\n *\n * In legacy message formats the message id can only be computed directly from the original\n * template source.\n *\n * Since this information is not available in `$localize` calls, the legacy message ids may be\n * attached by the compiler to the `$localize` metablock so it can be used if needed at the point\n * of translation if the translations are encoded using the legacy message id.\n */\n legacyIds?: string[];\n /**\n * The id of the `message` if a custom one was specified explicitly.\n *\n * This id overrides any computed or legacy ids.\n */\n customId?: string;\n /**\n * The meaning of the `message`, used to distinguish identical `messageString`s.\n */\n meaning?: string;\n /**\n * The description of the `message`, used to aid translation.\n */\n description?: string;\n /**\n * The location of the message in the source.\n */\n location?: SourceLocation;\n}\n\n/**\n * Information parsed from a `$localize` tagged string that is used to translate it.\n *\n * For example:\n *\n * ```ts\n * const name = 'Jo Bloggs';\n * $localize`Hello ${name}:title@@ID:!`;\n * ```\n *\n * May be parsed into:\n *\n * ```ts\n * {\n * id: '6998194507597730591',\n * substitutions: { title: 'Jo Bloggs' },\n * messageString: 'Hello {$title}!',\n * placeholderNames: ['title'],\n * associatedMessageIds: { title: 'ID' },\n * }\n * ```\n */\nexport interface ParsedMessage extends MessageMetadata {\n /**\n * The key used to look up the appropriate translation target.\n */\n id: MessageId;\n /**\n * A mapping of placeholder names to substitution values.\n */\n substitutions: Record<string, any>;\n /**\n * An optional mapping of placeholder names to associated MessageIds.\n * This can be used to match ICU placeholders to the message that contains the ICU.\n */\n associatedMessageIds?: Record<string, MessageId>;\n /**\n * An optional mapping of placeholder names to source locations\n */\n substitutionLocations?: Record<string, SourceLocation | undefined>;\n /**\n * The static parts of the message.\n */\n messageParts: string[];\n /**\n * An optional mapping of message parts to source locations\n */\n messagePartLocations?: (SourceLocation | undefined)[];\n /**\n * The names of the placeholders that will be replaced with substitutions.\n */\n placeholderNames: string[];\n}\n\n/**\n * Parse a `$localize` tagged string into a structure that can be used for translation or\n * extraction.\n *\n * See `ParsedMessage` for an example.\n */\nexport function parseMessage(\n messageParts: TemplateStringsArray,\n expressions?: readonly any[],\n location?: SourceLocation,\n messagePartLocations?: (SourceLocation | undefined)[],\n expressionLocations: (SourceLocation | undefined)[] = [],\n): ParsedMessage {\n const substitutions: {[placeholderName: string]: any} = {};\n const substitutionLocations: {[placeholderName: string]: SourceLocation | undefined} = {};\n const associatedMessageIds: {[placeholderName: string]: MessageId} = {};\n const metadata = parseMetadata(messageParts[0], messageParts.raw[0]);\n const cleanedMessageParts: string[] = [metadata.text];\n const placeholderNames: string[] = [];\n let messageString = metadata.text;\n for (let i = 1; i < messageParts.length; i++) {\n const {\n messagePart,\n placeholderName = computePlaceholderName(i),\n associatedMessageId,\n } = parsePlaceholder(messageParts[i], messageParts.raw[i]);\n messageString += `{$${placeholderName}}${messagePart}`;\n if (expressions !== undefined) {\n substitutions[placeholderName] = expressions[i - 1];\n substitutionLocations[placeholderName] = expressionLocations[i - 1];\n }\n placeholderNames.push(placeholderName);\n if (associatedMessageId !== undefined) {\n associatedMessageIds[placeholderName] = associatedMessageId;\n }\n cleanedMessageParts.push(messagePart);\n }\n const messageId = metadata.customId || computeMsgId(messageString, metadata.meaning || '');\n const legacyIds = metadata.legacyIds ? metadata.legacyIds.filter((id) => id !== messageId) : [];\n return {\n id: messageId,\n legacyIds,\n substitutions,\n substitutionLocations,\n text: messageString,\n customId: metadata.customId,\n meaning: metadata.meaning || '',\n description: metadata.description || '',\n messageParts: cleanedMessageParts,\n messagePartLocations,\n placeholderNames,\n associatedMessageIds,\n location,\n };\n}\n\n/**\n * Parse the given message part (`cooked` + `raw`) to extract the message metadata from the text.\n *\n * If the message part has a metadata block this function will extract the `meaning`,\n * `description`, `customId` and `legacyId` (if provided) from the block. These metadata properties\n * are serialized in the string delimited by `|`, `@@` and `␟` respectively.\n *\n * (Note that `␟` is the `LEGACY_ID_INDICATOR` - see `constants.ts`.)\n *\n * For example:\n *\n * ```ts\n * `:meaning|description@@custom-id:`\n * `:meaning|@@custom-id:`\n * `:meaning|description:`\n * `:description@@custom-id:`\n * `:meaning|:`\n * `:description:`\n * `:@@custom-id:`\n * `:meaning|description@@custom-id␟legacy-id-1␟legacy-id-2:`\n * ```\n *\n * @param cooked The cooked version of the message part to parse.\n * @param raw The raw version of the message part to parse.\n * @returns A object containing any metadata that was parsed from the message part.\n */\nexport function parseMetadata(cooked: string, raw: string): MessageMetadata {\n const {text: messageString, block} = splitBlock(cooked, raw);\n if (block === undefined) {\n return {text: messageString};\n } else {\n const [meaningDescAndId, ...legacyIds] = block.split(LEGACY_ID_INDICATOR);\n const [meaningAndDesc, customId] = meaningDescAndId.split(ID_SEPARATOR, 2);\n let [meaning, description]: (string | undefined)[] = meaningAndDesc.split(MEANING_SEPARATOR, 2);\n if (description === undefined) {\n description = meaning;\n meaning = undefined;\n }\n if (description === '') {\n description = undefined;\n }\n return {text: messageString, meaning, description, customId, legacyIds};\n }\n}\n\n/**\n * Parse the given message part (`cooked` + `raw`) to extract any placeholder metadata from the\n * text.\n *\n * If the message part has a metadata block this function will extract the `placeholderName` and\n * `associatedMessageId` (if provided) from the block.\n *\n * These metadata properties are serialized in the string delimited by `@@`.\n *\n * For example:\n *\n * ```ts\n * `:placeholder-name@@associated-id:`\n * ```\n *\n * @param cooked The cooked version of the message part to parse.\n * @param raw The raw version of the message part to parse.\n * @returns A object containing the metadata (`placeholderName` and `associatedMessageId`) of the\n * preceding placeholder, along with the static text that follows.\n */\nexport function parsePlaceholder(\n cooked: string,\n raw: string,\n): {messagePart: string; placeholderName?: string; associatedMessageId?: string} {\n const {text: messagePart, block} = splitBlock(cooked, raw);\n if (block === undefined) {\n return {messagePart};\n } else {\n const [placeholderName, associatedMessageId] = block.split(ID_SEPARATOR);\n return {messagePart, placeholderName, associatedMessageId};\n }\n}\n\n/**\n * Split a message part (`cooked` + `raw`) into an optional delimited \"block\" off the front and the\n * rest of the text of the message part.\n *\n * Blocks appear at the start of message parts. They are delimited by a colon `:` character at the\n * start and end of the block.\n *\n * If the block is in the first message part then it will be metadata about the whole message:\n * meaning, description, id. Otherwise it will be metadata about the immediately preceding\n * substitution: placeholder name.\n *\n * Since blocks are optional, it is possible that the content of a message block actually starts\n * with a block marker. In this case the marker must be escaped `\\:`.\n *\n * @param cooked The cooked version of the message part to parse.\n * @param raw The raw version of the message part to parse.\n * @returns An object containing the `text` of the message part and the text of the `block`, if it\n * exists.\n * @throws an error if the `block` is unterminated\n */\nexport function splitBlock(cooked: string, raw: string): {text: string; block?: string} {\n if (raw.charAt(0) !== BLOCK_MARKER) {\n return {text: cooked};\n } else {\n const endOfBlock = findEndOfBlock(cooked, raw);\n return {\n block: cooked.substring(1, endOfBlock),\n text: cooked.substring(endOfBlock + 1),\n };\n }\n}\n\nfunction computePlaceholderName(index: number) {\n return index === 1 ? 'PH' : `PH_${index - 1}`;\n}\n\n/**\n * Find the end of a \"marked block\" indicated by the first non-escaped colon.\n *\n * @param cooked The cooked string (where escaped chars have been processed)\n * @param raw The raw string (where escape sequences are still in place)\n *\n * @returns the index of the end of block marker\n * @throws an error if the block is unterminated\n */\nexport function findEndOfBlock(cooked: string, raw: string): number {\n for (let cookedIndex = 1, rawIndex = 1; cookedIndex < cooked.length; cookedIndex++, rawIndex++) {\n if (raw[rawIndex] === '\\\\') {\n rawIndex++;\n } else if (cooked[cookedIndex] === BLOCK_MARKER) {\n return cookedIndex;\n }\n }\n throw new Error(`Unterminated $localize metadata block in \"${raw}\".`);\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {findEndOfBlock} from '../../utils';\n\n/** @docs-private */\nexport interface LocalizeFn {\n (messageParts: TemplateStringsArray, ...expressions: readonly any[]): string;\n\n /**\n * A function that converts an input \"message with expressions\" into a translated \"message with\n * expressions\".\n *\n * The conversion may be done in place, modifying the array passed to the function, so\n * don't assume that this has no side-effects.\n *\n * The expressions must be passed in since it might be they need to be reordered for\n * different translations.\n */\n translate?: TranslateFn;\n /**\n * The current locale of the translated messages.\n *\n * The compile-time translation inliner is able to replace the following code:\n *\n * ```ts\n * typeof $localize !== \"undefined\" && $localize.locale\n * ```\n *\n * with a string literal of the current locale. E.g.\n *\n * ```\n * \"fr\"\n * ```\n */\n locale?: string;\n}\n\n/** @docs-private */\nexport interface TranslateFn {\n (\n messageParts: TemplateStringsArray,\n expressions: readonly any[],\n ): [TemplateStringsArray, readonly any[]];\n}\n\n/**\n * Tag a template literal string for localization.\n *\n * For example:\n *\n * ```ts\n * $localize `some string to localize`\n * ```\n *\n * **Providing meaning, description and id**\n *\n * You can optionally specify one or more of `meaning`, `description` and `id` for a localized\n * string by pre-pending it with a colon delimited block of the form:\n *\n * ```ts\n * $localize`:meaning|description@@id:source message text`;\n *\n * $localize`:meaning|:source message text`;\n * $localize`:description:source message text`;\n * $localize`:@@id:source message text`;\n * ```\n *\n * This format is the same as that used for `i18n` markers in Angular templates. See the\n * [Angular i18n guide](guide/i18n/prepare#mark-text-in-component-template).\n *\n * **Naming placeholders**\n *\n * If the template literal string contains expressions, then the expressions will be automatically\n * associated with placeholder names for you.\n *\n * For example:\n *\n * ```ts\n * $localize `Hi ${name}! There are ${items.length} items.`;\n * ```\n *\n * will generate a message-source of `Hi {$PH}! There are {$PH_1} items`.\n *\n * The recommended practice is to name the placeholder associated with each expression though.\n *\n * Do this by providing the placeholder name wrapped in `:` characters directly after the\n * expression. These placeholder names are stripped out of the rendered localized string.\n *\n * For example, to name the `items.length` expression placeholder `itemCount` you write:\n *\n * ```ts\n * $localize `There are ${items.length}:itemCount: items`;\n * ```\n *\n * **Escaping colon markers**\n *\n * If you need to use a `:` character directly at the start of a tagged string that has no\n * metadata block, or directly after a substitution expression that has no name you must escape\n * the `:` by preceding it with a backslash:\n *\n * For example:\n *\n * ```ts\n * // message has a metadata block so no need to escape colon\n * $localize `:some description::this message starts with a colon (:)`;\n * // no metadata block so the colon must be escaped\n * $localize `\\:this message starts with a colon (:)`;\n * ```\n *\n * ```ts\n * // named substitution so no need to escape colon\n * $localize `${label}:label:: ${}`\n * // anonymous substitution so colon must be escaped\n * $localize `${label}\\: ${}`\n * ```\n *\n * **Processing localized strings:**\n *\n * There are three scenarios:\n *\n * * **compile-time inlining**: the `$localize` tag is transformed at compile time by a\n * transpiler, removing the tag and replacing the template literal string with a translated\n * literal string from a collection of translations provided to the transpilation tool.\n *\n * * **run-time evaluation**: the `$localize` tag is a run-time function that replaces and\n * reorders the parts (static strings and expressions) of the template literal string with strings\n * from a collection of translations loaded at run-time.\n *\n * * **pass-through evaluation**: the `$localize` tag is a run-time function that simply evaluates\n * the original template literal string without applying any translations to the parts. This\n * version is used during development or where there is no need to translate the localized\n * template literals.\n *\n * @param messageParts a collection of the static parts of the template string.\n * @param expressions a collection of the values of each placeholder in the template string.\n * @returns the translated string, with the `messageParts` and `expressions` interleaved together.\n *\n * @publicApi\n */\nexport const $localize: LocalizeFn = function (\n messageParts: TemplateStringsArray,\n ...expressions: readonly any[]\n) {\n if ($localize.translate) {\n // Don't use array expansion here to avoid the compiler adding `__read()` helper unnecessarily.\n const translation = $localize.translate(messageParts, expressions);\n messageParts = translation[0];\n expressions = translation[1];\n }\n let message = stripBlock(messageParts[0], messageParts.raw[0]);\n for (let i = 1; i < messageParts.length; i++) {\n message += expressions[i - 1] + stripBlock(messageParts[i], messageParts.raw[i]);\n }\n return message;\n};\n\nconst BLOCK_MARKER = ':';\n\n/**\n * Strip a delimited \"block\" from the start of the `messagePart`, if it is found.\n *\n * If a marker character (:) actually appears in the content at the start of a tagged string or\n * after a substitution expression, where a block has not been provided the character must be\n * escaped with a backslash, `\\:`. This function checks for this by looking at the `raw`\n * messagePart, which should still contain the backslash.\n *\n * @param messagePart The cooked message part to process.\n * @param rawMessagePart The raw message part to check.\n * @returns the message part with the placeholder name stripped, if found.\n * @throws an error if the block is unterminated\n */\nfunction stripBlock(messagePart: string, rawMessagePart: string) {\n return rawMessagePart.charAt(0) === BLOCK_MARKER\n ? messagePart.substring(findEndOfBlock(messagePart, rawMessagePart) + 1)\n : messagePart;\n}\n"],"names":["BLOCK_MARKER","MEANING_SEPARATOR","ID_SEPARATOR","LEGACY_ID_INDICATOR","textEncoder","fingerprint","str","TextEncoder","utf8","encode","view","DataView","buffer","byteOffset","byteLength","hi","hash32","length","lo","BigInt","asUintN","computeMsgId","msg","meaning","msgFingerprint","toString","c","a","b","index","end","getUint32","res","mix","remainder","getUint8","Endian","parseMessage","messageParts","expressions","location","messagePartLocations","expressionLocations","substitutions","substitutionLocations","associatedMessageIds","metadata","parseMetadata","raw","cleanedMessageParts","text","placeholderNames","messageString","i","messagePart","placeholderName","computePlaceholderName","associatedMessageId","parsePlaceholder","undefined","push","messageId","customId","legacyIds","filter","id","description","cooked","block","splitBlock","meaningDescAndId","split","meaningAndDesc","charAt","endOfBlock","findEndOfBlock","substring","cookedIndex","rawIndex","Error","$localize","translate","translation","message","stripBlock","rawMessagePart"],"mappings":";;;;;;AAoBO,MAAMA,cAAY,GAAG;AAYrB,MAAMC,iBAAiB,GAAG,GAAG;AAW7B,MAAMC,YAAY,GAAG,IAAI;AAiBzB,MAAMC,mBAAmB,GAAG,QAAQ;;AC7C3C,IAAIC,WAAoC;AAgMlC,SAAUC,WAAWA,CAACC,GAAW,EAAA;A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5C,WAAW,CAACc,CAAC,GAAG,CAAC,CAAC,GAAG+B,UAAU,CAAC9C,YAAY,CAACe,CAAC,CAAC,EAAEf,YAAY,CAACU,GAAG,CAACK,CAAC,CAAC,CAAC;AAClF;AACA,EAAA,OAAO8B,OAAO;AAChB;AAEA,MAAMnF,YAAY,GAAG,GAAG;AAexB,SAASoF,UAAUA,CAAC9B,WAAmB,EAAE+B,cAAsB,EAAA;EAC7D,OAAOA,cAAc,CAACZ,MAAM,CAAC,CAAC,CAAC,KAAKzE,YAAY,GAC5CsD,WAAW,CAACsB,SAAS,CAACD,cAAc,CAACrB,WAAW,EAAE+B,cAAc,CAAC,GAAG,CAAC,CAAA,GACrE/B,WAAW;AACjB;;;;"}
{"version":3,"file":"_localize-chunk.mjs","sources":["../../../../../darwin_arm64-fastbuild-ST-fdfa778d11ba/bin/packages/localize/src/utils/src/constants.ts","../../../../../darwin_arm64-fastbuild-ST-fdfa778d11ba/bin/packages/compiler/src/i18n/digest.ts","../../../../../darwin_arm64-fastbuild-ST-fdfa778d11ba/bin/packages/localize/src/utils/src/messages.ts","../../../../../darwin_arm64-fastbuild-ST-fdfa778d11ba/bin/packages/localize/src/localize/src/localize.ts"],"sourcesContent":["/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\n/**\n * The character used to mark the start and end of a \"block\" in a `$localize` tagged string.\n * A block can indicate metadata about the message or specify a name of a placeholder for a\n * substitution expressions.\n *\n * For example:\n *\n * ```ts\n * $localize`Hello, ${title}:title:!`;\n * $localize`:meaning|description@@id:source message text`;\n * ```\n */\nexport const BLOCK_MARKER = ':';\n\n/**\n * The marker used to separate a message's \"meaning\" from its \"description\" in a metadata block.\n *\n * For example:\n *\n * ```ts\n * $localize `:correct|Indicates that the user got the answer correct: Right!`;\n * $localize `:movement|Button label for moving to the right: Right!`;\n * ```\n */\nexport const MEANING_SEPARATOR = '|';\n\n/**\n * The marker used to separate a message's custom \"id\" from its \"description\" in a metadata block.\n *\n * For example:\n *\n * ```ts\n * $localize `:A welcome message on the home page@@myApp-homepage-welcome: Welcome!`;\n * ```\n */\nexport const ID_SEPARATOR = '@@';\n\n/**\n * The marker used to separate legacy message ids from the rest of a metadata block.\n *\n * For example:\n *\n * ```ts\n * $localize `:@@custom-id␟2df64767cd895a8fabe3e18b94b5b6b6f9e2e3f0: Welcome!`;\n * ```\n *\n * Note that this character is the \"symbol for the unit separator\" (␟) not the \"unit separator\n * character\" itself, since that has no visual representation. See https://graphemica.com/%E2%90%9F.\n *\n * Here is some background for the original \"unit separator character\":\n * https://stackoverflow.com/questions/8695118/whats-the-file-group-record-unit-separator-control-characters-and-its-usage\n */\nexport const LEGACY_ID_INDICATOR = '\\u241F';\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {Byte} from '../util';\n\nimport * as i18n from './i18n_ast';\n\n/**\n * A lazily created TextEncoder instance for converting strings into UTF-8 bytes\n */\nlet textEncoder: TextEncoder | undefined;\n\n/**\n * Return the message id or compute it using the XLIFF1 digest.\n */\nexport function digest(message: i18n.Message): string {\n return message.id || computeDigest(message);\n}\n\n/**\n * Compute the message id using the XLIFF1 digest.\n */\nexport function computeDigest(message: i18n.Message): string {\n return sha1(serializeNodes(message.nodes).join('') + `[${message.meaning}]`);\n}\n\n/**\n * Return the message id or compute it using the XLIFF2/XMB/$localize digest.\n */\nexport function decimalDigest(message: i18n.Message): string {\n return message.id || computeDecimalDigest(message);\n}\n\n/**\n * Compute the message id using the XLIFF2/XMB/$localize digest.\n */\nexport function computeDecimalDigest(message: i18n.Message): string {\n const visitor = new _SerializerIgnoreIcuExpVisitor();\n const parts = message.nodes.map((a) => a.visit(visitor, null));\n return computeMsgId(parts.join(''), message.meaning);\n}\n\n/**\n * Serialize the i18n ast to something xml-like in order to generate an UID.\n *\n * The visitor is also used in the i18n parser tests\n *\n * @internal\n */\nclass _SerializerVisitor implements i18n.Visitor {\n visitText(text: i18n.Text, context: any): any {\n return text.value;\n }\n\n visitContainer(container: i18n.Container, context: any): any {\n return `[${container.children.map((child) => child.visit(this)).join(', ')}]`;\n }\n\n visitIcu(icu: i18n.Icu, context: any): any {\n const strCases = Object.keys(icu.cases).map(\n (k: string) => `${k} {${icu.cases[k].visit(this)}}`,\n );\n return `{${icu.expression}, ${icu.type}, ${strCases.join(', ')}}`;\n }\n\n visitTagPlaceholder(ph: i18n.TagPlaceholder, context: any): any {\n return ph.isVoid\n ? `<ph tag name=\"${ph.startName}\"/>`\n : `<ph tag name=\"${ph.startName}\">${ph.children\n .map((child) => child.visit(this))\n .join(', ')}</ph name=\"${ph.closeName}\">`;\n }\n\n visitPlaceholder(ph: i18n.Placeholder, context: any): any {\n return ph.value ? `<ph name=\"${ph.name}\">${ph.value}</ph>` : `<ph name=\"${ph.name}\"/>`;\n }\n\n visitIcuPlaceholder(ph: i18n.IcuPlaceholder, context?: any): any {\n return `<ph icu name=\"${ph.name}\">${ph.value.visit(this)}</ph>`;\n }\n\n visitBlockPlaceholder(ph: i18n.BlockPlaceholder, context: any): any {\n return `<ph block name=\"${ph.startName}\">${ph.children\n .map((child) => child.visit(this))\n .join(', ')}</ph name=\"${ph.closeName}\">`;\n }\n}\n\nconst serializerVisitor = new _SerializerVisitor();\n\nexport function serializeNodes(nodes: i18n.Node[]): string[] {\n return nodes.map((a) => a.visit(serializerVisitor, null));\n}\n\n/**\n * Serialize the i18n ast to something xml-like in order to generate an UID.\n *\n * Ignore the ICU expressions so that message IDs stays identical if only the expression changes.\n *\n * @internal\n */\nclass _SerializerIgnoreIcuExpVisitor extends _SerializerVisitor {\n override visitIcu(icu: i18n.Icu): string {\n let strCases = Object.keys(icu.cases).map((k: string) => `${k} {${icu.cases[k].visit(this)}}`);\n // Do not take the expression into account\n return `{${icu.type}, ${strCases.join(', ')}}`;\n }\n}\n\n/**\n * Compute the SHA1 of the given string\n *\n * see https://csrc.nist.gov/publications/fips/fips180-4/fips-180-4.pdf\n *\n * WARNING: this function has not been designed not tested with security in mind.\n * DO NOT USE IT IN A SECURITY SENSITIVE CONTEXT.\n */\nexport function sha1(str: string): string {\n textEncoder ??= new TextEncoder();\n const utf8 = [...textEncoder.encode(str)];\n const words32 = bytesToWords32(utf8, Endian.Big);\n const len = utf8.length * 8;\n\n const w = new Uint32Array(80);\n let a = 0x67452301,\n b = 0xefcdab89,\n c = 0x98badcfe,\n d = 0x10325476,\n e = 0xc3d2e1f0;\n\n words32[len >> 5] |= 0x80 << (24 - (len % 32));\n words32[(((len + 64) >> 9) << 4) + 15] = len;\n\n for (let i = 0; i < words32.length; i += 16) {\n const h0 = a,\n h1 = b,\n h2 = c,\n h3 = d,\n h4 = e;\n\n for (let j = 0; j < 80; j++) {\n if (j < 16) {\n w[j] = words32[i + j];\n } else {\n w[j] = rol32(w[j - 3] ^ w[j - 8] ^ w[j - 14] ^ w[j - 16], 1);\n }\n\n const fkVal = fk(j, b, c, d);\n const f = fkVal[0];\n const k = fkVal[1];\n const temp = [rol32(a, 5), f, e, k, w[j]].reduce(add32);\n e = d;\n d = c;\n c = rol32(b, 30);\n b = a;\n a = temp;\n }\n a = add32(a, h0);\n b = add32(b, h1);\n c = add32(c, h2);\n d = add32(d, h3);\n e = add32(e, h4);\n }\n\n // Convert the output parts to a 160-bit hexadecimal string\n return toHexU32(a) + toHexU32(b) + toHexU32(c) + toHexU32(d) + toHexU32(e);\n}\n\n/**\n * Convert and format a number as a string representing a 32-bit unsigned hexadecimal number.\n * @param value The value to format as a string.\n * @returns A hexadecimal string representing the value.\n */\nfunction toHexU32(value: number): string {\n // unsigned right shift of zero ensures an unsigned 32-bit number\n return (value >>> 0).toString(16).padStart(8, '0');\n}\n\nfunction fk(index: number, b: number, c: number, d: number): [number, number] {\n if (index < 20) {\n return [(b & c) | (~b & d), 0x5a827999];\n }\n\n if (index < 40) {\n return [b ^ c ^ d, 0x6ed9eba1];\n }\n\n if (index < 60) {\n return [(b & c) | (b & d) | (c & d), 0x8f1bbcdc];\n }\n\n return [b ^ c ^ d, 0xca62c1d6];\n}\n\n/**\n * Compute the fingerprint of the given string\n *\n * The output is 64 bit number encoded as a decimal string\n *\n * based on:\n * https://github.com/google/closure-compiler/blob/master/src/com/google/javascript/jscomp/GoogleJsMessageIdGenerator.java\n */\nexport function fingerprint(str: string): bigint {\n textEncoder ??= new TextEncoder();\n const utf8 = textEncoder.encode(str);\n const view = new DataView(utf8.buffer, utf8.byteOffset, utf8.byteLength);\n\n let hi = hash32(view, utf8.length, 0);\n let lo = hash32(view, utf8.length, 102072);\n\n if (hi == 0 && (lo == 0 || lo == 1)) {\n hi = hi ^ 0x130f9bef;\n lo = lo ^ -0x6b5f56d8;\n }\n\n return (BigInt.asUintN(32, BigInt(hi)) << BigInt(32)) | BigInt.asUintN(32, BigInt(lo));\n}\n\nexport function computeMsgId(msg: string, meaning: string = ''): string {\n let msgFingerprint = fingerprint(msg);\n\n if (meaning) {\n // Rotate the 64-bit message fingerprint one bit to the left and then add the meaning\n // fingerprint.\n msgFingerprint =\n BigInt.asUintN(64, msgFingerprint << BigInt(1)) |\n ((msgFingerprint >> BigInt(63)) & BigInt(1));\n msgFingerprint += fingerprint(meaning);\n }\n\n return BigInt.asUintN(63, msgFingerprint).toString();\n}\n\nfunction hash32(view: DataView, length: number, c: number): number {\n let a = 0x9e3779b9,\n b = 0x9e3779b9;\n let index = 0;\n\n const end = length - 12;\n for (; index <= end; index += 12) {\n a += view.getUint32(index, true);\n b += view.getUint32(index + 4, true);\n c += view.getUint32(index + 8, true);\n const res = mix(a, b, c);\n ((a = res[0]), (b = res[1]), (c = res[2]));\n }\n\n const remainder = length - index;\n\n // the first byte of c is reserved for the length\n c += length;\n\n if (remainder >= 4) {\n a += view.getUint32(index, true);\n index += 4;\n\n if (remainder >= 8) {\n b += view.getUint32(index, true);\n index += 4;\n\n // Partial 32-bit word for c\n if (remainder >= 9) {\n c += view.getUint8(index++) << 8;\n }\n if (remainder >= 10) {\n c += view.getUint8(index++) << 16;\n }\n if (remainder === 11) {\n c += view.getUint8(index++) << 24;\n }\n } else {\n // Partial 32-bit word for b\n if (remainder >= 5) {\n b += view.getUint8(index++);\n }\n if (remainder >= 6) {\n b += view.getUint8(index++) << 8;\n }\n if (remainder === 7) {\n b += view.getUint8(index++) << 16;\n }\n }\n } else {\n // Partial 32-bit word for a\n if (remainder >= 1) {\n a += view.getUint8(index++);\n }\n if (remainder >= 2) {\n a += view.getUint8(index++) << 8;\n }\n if (remainder === 3) {\n a += view.getUint8(index++) << 16;\n }\n }\n\n return mix(a, b, c)[2];\n}\n\nfunction mix(a: number, b: number, c: number): [number, number, number] {\n a -= b;\n a -= c;\n a ^= c >>> 13;\n b -= c;\n b -= a;\n b ^= a << 8;\n c -= a;\n c -= b;\n c ^= b >>> 13;\n a -= b;\n a -= c;\n a ^= c >>> 12;\n b -= c;\n b -= a;\n b ^= a << 16;\n c -= a;\n c -= b;\n c ^= b >>> 5;\n a -= b;\n a -= c;\n a ^= c >>> 3;\n b -= c;\n b -= a;\n b ^= a << 10;\n c -= a;\n c -= b;\n c ^= b >>> 15;\n return [a, b, c];\n}\n\n// Utils\n\nenum Endian {\n Little,\n Big,\n}\n\nfunction add32(a: number, b: number): number {\n return add32to64(a, b)[1];\n}\n\nfunction add32to64(a: number, b: number): [number, number] {\n const low = (a & 0xffff) + (b & 0xffff);\n const high = (a >>> 16) + (b >>> 16) + (low >>> 16);\n return [high >>> 16, (high << 16) | (low & 0xffff)];\n}\n\n// Rotate a 32b number left `count` position\nfunction rol32(a: number, count: number): number {\n return (a << count) | (a >>> (32 - count));\n}\n\nfunction bytesToWords32(bytes: Byte[], endian: Endian): number[] {\n const size = (bytes.length + 3) >>> 2;\n const words32 = [];\n\n for (let i = 0; i < size; i++) {\n words32[i] = wordAt(bytes, i * 4, endian);\n }\n\n return words32;\n}\n\nfunction byteAt(bytes: Byte[], index: number): Byte {\n return index >= bytes.length ? 0 : bytes[index];\n}\n\nfunction wordAt(bytes: Byte[], index: number, endian: Endian): number {\n let word = 0;\n if (endian === Endian.Big) {\n for (let i = 0; i < 4; i++) {\n word += byteAt(bytes, index + i) << (24 - 8 * i);\n }\n } else {\n for (let i = 0; i < 4; i++) {\n word += byteAt(bytes, index + i) << (8 * i);\n }\n }\n return word;\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n// This module specifier is intentionally a relative path to allow bundling the code directly\n// into the package.\n// @ng_package: ignore-cross-repo-import\nimport {computeMsgId} from '../../../../compiler/src/i18n/digest';\n\nimport {BLOCK_MARKER, ID_SEPARATOR, LEGACY_ID_INDICATOR, MEANING_SEPARATOR} from './constants';\n\n/**\n * Re-export this helper function so that users of `@angular/localize` don't need to actively import\n * from `@angular/compiler`.\n */\nexport {computeMsgId};\n\n/**\n * A string containing a translation source message.\n *\n * I.E. the message that indicates what will be translated from.\n *\n * Uses `{$placeholder-name}` to indicate a placeholder.\n */\nexport type SourceMessage = string;\n\n/**\n * A string containing a translation target message.\n *\n * I.E. the message that indicates what will be translated to.\n *\n * Uses `{$placeholder-name}` to indicate a placeholder.\n *\n * @publicApi\n */\nexport type TargetMessage = string;\n\n/**\n * A string that uniquely identifies a message, to be used for matching translations.\n *\n * @publicApi\n */\nexport type MessageId = string;\n\n/**\n * Declares a copy of the `AbsoluteFsPath` branded type in `@angular/compiler-cli` to avoid an\n * import into `@angular/compiler-cli`. The compiler-cli's declaration files are not necessarily\n * compatible with web environments that use `@angular/localize`, and would inadvertently include\n * `typescript` declaration files in any compilation unit that uses `@angular/localize` (which\n * increases parsing time and memory usage during builds) using a default import that only\n * type-checks when `allowSyntheticDefaultImports` is enabled.\n *\n * @see https://github.com/angular/angular/issues/45179\n */\ntype AbsoluteFsPathLocalizeCopy = string & {_brand: 'AbsoluteFsPath'};\n\n/**\n * The location of the message in the source file.\n *\n * The `line` and `column` values for the `start` and `end` properties are zero-based.\n */\nexport interface SourceLocation {\n start: {line: number; column: number};\n end: {line: number; column: number};\n file: AbsoluteFsPathLocalizeCopy;\n text?: string;\n}\n\n/**\n * Additional information that can be associated with a message.\n */\nexport interface MessageMetadata {\n /**\n * A human readable rendering of the message\n */\n text: string;\n /**\n * Legacy message ids, if provided.\n *\n * In legacy message formats the message id can only be computed directly from the original\n * template source.\n *\n * Since this information is not available in `$localize` calls, the legacy message ids may be\n * attached by the compiler to the `$localize` metablock so it can be used if needed at the point\n * of translation if the translations are encoded using the legacy message id.\n */\n legacyIds?: string[];\n /**\n * The id of the `message` if a custom one was specified explicitly.\n *\n * This id overrides any computed or legacy ids.\n */\n customId?: string;\n /**\n * The meaning of the `message`, used to distinguish identical `messageString`s.\n */\n meaning?: string;\n /**\n * The description of the `message`, used to aid translation.\n */\n description?: string;\n /**\n * The location of the message in the source.\n */\n location?: SourceLocation;\n}\n\n/**\n * Information parsed from a `$localize` tagged string that is used to translate it.\n *\n * For example:\n *\n * ```ts\n * const name = 'Jo Bloggs';\n * $localize`Hello ${name}:title@@ID:!`;\n * ```\n *\n * May be parsed into:\n *\n * ```ts\n * {\n * id: '6998194507597730591',\n * substitutions: { title: 'Jo Bloggs' },\n * messageString: 'Hello {$title}!',\n * placeholderNames: ['title'],\n * associatedMessageIds: { title: 'ID' },\n * }\n * ```\n */\nexport interface ParsedMessage extends MessageMetadata {\n /**\n * The key used to look up the appropriate translation target.\n */\n id: MessageId;\n /**\n * A mapping of placeholder names to substitution values.\n */\n substitutions: Record<string, any>;\n /**\n * An optional mapping of placeholder names to associated MessageIds.\n * This can be used to match ICU placeholders to the message that contains the ICU.\n */\n associatedMessageIds?: Record<string, MessageId>;\n /**\n * An optional mapping of placeholder names to source locations\n */\n substitutionLocations?: Record<string, SourceLocation | undefined>;\n /**\n * The static parts of the message.\n */\n messageParts: string[];\n /**\n * An optional mapping of message parts to source locations\n */\n messagePartLocations?: (SourceLocation | undefined)[];\n /**\n * The names of the placeholders that will be replaced with substitutions.\n */\n placeholderNames: string[];\n}\n\n/**\n * Parse a `$localize` tagged string into a structure that can be used for translation or\n * extraction.\n *\n * See `ParsedMessage` for an example.\n */\nexport function parseMessage(\n messageParts: TemplateStringsArray,\n expressions?: readonly any[],\n location?: SourceLocation,\n messagePartLocations?: (SourceLocation | undefined)[],\n expressionLocations: (SourceLocation | undefined)[] = [],\n): ParsedMessage {\n const substitutions: {[placeholderName: string]: any} = {};\n const substitutionLocations: {[placeholderName: string]: SourceLocation | undefined} = {};\n const associatedMessageIds: {[placeholderName: string]: MessageId} = {};\n const metadata = parseMetadata(messageParts[0], messageParts.raw[0]);\n const cleanedMessageParts: string[] = [metadata.text];\n const placeholderNames: string[] = [];\n let messageString = metadata.text;\n for (let i = 1; i < messageParts.length; i++) {\n const {\n messagePart,\n placeholderName = computePlaceholderName(i),\n associatedMessageId,\n } = parsePlaceholder(messageParts[i], messageParts.raw[i]);\n messageString += `{$${placeholderName}}${messagePart}`;\n if (expressions !== undefined) {\n substitutions[placeholderName] = expressions[i - 1];\n substitutionLocations[placeholderName] = expressionLocations[i - 1];\n }\n placeholderNames.push(placeholderName);\n if (associatedMessageId !== undefined) {\n associatedMessageIds[placeholderName] = associatedMessageId;\n }\n cleanedMessageParts.push(messagePart);\n }\n const messageId = metadata.customId || computeMsgId(messageString, metadata.meaning || '');\n const legacyIds = metadata.legacyIds ? metadata.legacyIds.filter((id) => id !== messageId) : [];\n return {\n id: messageId,\n legacyIds,\n substitutions,\n substitutionLocations,\n text: messageString,\n customId: metadata.customId,\n meaning: metadata.meaning || '',\n description: metadata.description || '',\n messageParts: cleanedMessageParts,\n messagePartLocations,\n placeholderNames,\n associatedMessageIds,\n location,\n };\n}\n\n/**\n * Parse the given message part (`cooked` + `raw`) to extract the message metadata from the text.\n *\n * If the message part has a metadata block this function will extract the `meaning`,\n * `description`, `customId` and `legacyId` (if provided) from the block. These metadata properties\n * are serialized in the string delimited by `|`, `@@` and `␟` respectively.\n *\n * (Note that `␟` is the `LEGACY_ID_INDICATOR` - see `constants.ts`.)\n *\n * For example:\n *\n * ```ts\n * `:meaning|description@@custom-id:`\n * `:meaning|@@custom-id:`\n * `:meaning|description:`\n * `:description@@custom-id:`\n * `:meaning|:`\n * `:description:`\n * `:@@custom-id:`\n * `:meaning|description@@custom-id␟legacy-id-1␟legacy-id-2:`\n * ```\n *\n * @param cooked The cooked version of the message part to parse.\n * @param raw The raw version of the message part to parse.\n * @returns A object containing any metadata that was parsed from the message part.\n */\nexport function parseMetadata(cooked: string, raw: string): MessageMetadata {\n const {text: messageString, block} = splitBlock(cooked, raw);\n if (block === undefined) {\n return {text: messageString};\n } else {\n const [meaningDescAndId, ...legacyIds] = block.split(LEGACY_ID_INDICATOR);\n const [meaningAndDesc, customId] = meaningDescAndId.split(ID_SEPARATOR, 2);\n let [meaning, description]: (string | undefined)[] = meaningAndDesc.split(MEANING_SEPARATOR, 2);\n if (description === undefined) {\n description = meaning;\n meaning = undefined;\n }\n if (description === '') {\n description = undefined;\n }\n return {text: messageString, meaning, description, customId, legacyIds};\n }\n}\n\n/**\n * Parse the given message part (`cooked` + `raw`) to extract any placeholder metadata from the\n * text.\n *\n * If the message part has a metadata block this function will extract the `placeholderName` and\n * `associatedMessageId` (if provided) from the block.\n *\n * These metadata properties are serialized in the string delimited by `@@`.\n *\n * For example:\n *\n * ```ts\n * `:placeholder-name@@associated-id:`\n * ```\n *\n * @param cooked The cooked version of the message part to parse.\n * @param raw The raw version of the message part to parse.\n * @returns A object containing the metadata (`placeholderName` and `associatedMessageId`) of the\n * preceding placeholder, along with the static text that follows.\n */\nexport function parsePlaceholder(\n cooked: string,\n raw: string,\n): {messagePart: string; placeholderName?: string; associatedMessageId?: string} {\n const {text: messagePart, block} = splitBlock(cooked, raw);\n if (block === undefined) {\n return {messagePart};\n } else {\n const [placeholderName, associatedMessageId] = block.split(ID_SEPARATOR);\n return {messagePart, placeholderName, associatedMessageId};\n }\n}\n\n/**\n * Split a message part (`cooked` + `raw`) into an optional delimited \"block\" off the front and the\n * rest of the text of the message part.\n *\n * Blocks appear at the start of message parts. They are delimited by a colon `:` character at the\n * start and end of the block.\n *\n * If the block is in the first message part then it will be metadata about the whole message:\n * meaning, description, id. Otherwise it will be metadata about the immediately preceding\n * substitution: placeholder name.\n *\n * Since blocks are optional, it is possible that the content of a message block actually starts\n * with a block marker. In this case the marker must be escaped `\\:`.\n *\n * @param cooked The cooked version of the message part to parse.\n * @param raw The raw version of the message part to parse.\n * @returns An object containing the `text` of the message part and the text of the `block`, if it\n * exists.\n * @throws an error if the `block` is unterminated\n */\nexport function splitBlock(cooked: string, raw: string): {text: string; block?: string} {\n if (raw.charAt(0) !== BLOCK_MARKER) {\n return {text: cooked};\n } else {\n const endOfBlock = findEndOfBlock(cooked, raw);\n return {\n block: cooked.substring(1, endOfBlock),\n text: cooked.substring(endOfBlock + 1),\n };\n }\n}\n\nfunction computePlaceholderName(index: number) {\n return index === 1 ? 'PH' : `PH_${index - 1}`;\n}\n\n/**\n * Find the end of a \"marked block\" indicated by the first non-escaped colon.\n *\n * @param cooked The cooked string (where escaped chars have been processed)\n * @param raw The raw string (where escape sequences are still in place)\n *\n * @returns the index of the end of block marker\n * @throws an error if the block is unterminated\n */\nexport function findEndOfBlock(cooked: string, raw: string): number {\n for (let cookedIndex = 1, rawIndex = 1; cookedIndex < cooked.length; cookedIndex++, rawIndex++) {\n if (raw[rawIndex] === '\\\\') {\n rawIndex++;\n } else if (cooked[cookedIndex] === BLOCK_MARKER) {\n return cookedIndex;\n }\n }\n throw new Error(`Unterminated $localize metadata block in \"${raw}\".`);\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {findEndOfBlock} from '../../utils';\n\n/** @docs-private */\nexport interface LocalizeFn {\n (messageParts: TemplateStringsArray, ...expressions: readonly any[]): string;\n\n /**\n * A function that converts an input \"message with expressions\" into a translated \"message with\n * expressions\".\n *\n * The conversion may be done in place, modifying the array passed to the function, so\n * don't assume that this has no side-effects.\n *\n * The expressions must be passed in since it might be they need to be reordered for\n * different translations.\n */\n translate?: TranslateFn;\n /**\n * The current locale of the translated messages.\n *\n * The compile-time translation inliner is able to replace the following code:\n *\n * ```ts\n * typeof $localize !== \"undefined\" && $localize.locale\n * ```\n *\n * with a string literal of the current locale. E.g.\n *\n * ```\n * \"fr\"\n * ```\n */\n locale?: string;\n}\n\n/** @docs-private */\nexport interface TranslateFn {\n (\n messageParts: TemplateStringsArray,\n expressions: readonly any[],\n ): [TemplateStringsArray, readonly any[]];\n}\n\n/**\n * Tag a template literal string for localization.\n *\n * For example:\n *\n * ```ts\n * $localize `some string to localize`\n * ```\n *\n * **Providing meaning, description and id**\n *\n * You can optionally specify one or more of `meaning`, `description` and `id` for a localized\n * string by pre-pending it with a colon delimited block of the form:\n *\n * ```ts\n * $localize`:meaning|description@@id:source message text`;\n *\n * $localize`:meaning|:source message text`;\n * $localize`:description:source message text`;\n * $localize`:@@id:source message text`;\n * ```\n *\n * This format is the same as that used for `i18n` markers in Angular templates. See the\n * [Angular i18n guide](guide/i18n/prepare#mark-text-in-component-template).\n *\n * **Naming placeholders**\n *\n * If the template literal string contains expressions, then the expressions will be automatically\n * associated with placeholder names for you.\n *\n * For example:\n *\n * ```ts\n * $localize `Hi ${name}! There are ${items.length} items.`;\n * ```\n *\n * will generate a message-source of `Hi {$PH}! There are {$PH_1} items`.\n *\n * The recommended practice is to name the placeholder associated with each expression though.\n *\n * Do this by providing the placeholder name wrapped in `:` characters directly after the\n * expression. These placeholder names are stripped out of the rendered localized string.\n *\n * For example, to name the `items.length` expression placeholder `itemCount` you write:\n *\n * ```ts\n * $localize `There are ${items.length}:itemCount: items`;\n * ```\n *\n * **Escaping colon markers**\n *\n * If you need to use a `:` character directly at the start of a tagged string that has no\n * metadata block, or directly after a substitution expression that has no name you must escape\n * the `:` by preceding it with a backslash:\n *\n * For example:\n *\n * ```ts\n * // message has a metadata block so no need to escape colon\n * $localize `:some description::this message starts with a colon (:)`;\n * // no metadata block so the colon must be escaped\n * $localize `\\:this message starts with a colon (:)`;\n * ```\n *\n * ```ts\n * // named substitution so no need to escape colon\n * $localize `${label}:label:: ${}`\n * // anonymous substitution so colon must be escaped\n * $localize `${label}\\: ${}`\n * ```\n *\n * **Processing localized strings:**\n *\n * There are three scenarios:\n *\n * * **compile-time inlining**: the `$localize` tag is transformed at compile time by a\n * transpiler, removing the tag and replacing the template literal string with a translated\n * literal string from a collection of translations provided to the transpilation tool.\n *\n * * **run-time evaluation**: the `$localize` tag is a run-time function that replaces and\n * reorders the parts (static strings and expressions) of the template literal string with strings\n * from a collection of translations loaded at run-time.\n *\n * * **pass-through evaluation**: the `$localize` tag is a run-time function that simply evaluates\n * the original template literal string without applying any translations to the parts. This\n * version is used during development or where there is no need to translate the localized\n * template literals.\n *\n * @param messageParts a collection of the static parts of the template string.\n * @param expressions a collection of the values of each placeholder in the template string.\n * @returns the translated string, with the `messageParts` and `expressions` interleaved together.\n *\n * @publicApi\n */\nexport const $localize: LocalizeFn = function (\n messageParts: TemplateStringsArray,\n ...expressions: readonly any[]\n) {\n if ($localize.translate) {\n // Don't use array expansion here to avoid the compiler adding `__read()` helper unnecessarily.\n const translation = $localize.translate(messageParts, expressions);\n messageParts = translation[0];\n expressions = translation[1];\n }\n let message = stripBlock(messageParts[0], messageParts.raw[0]);\n for (let i = 1; i < messageParts.length; i++) {\n message += expressions[i - 1] + stripBlock(messageParts[i], messageParts.raw[i]);\n }\n return message;\n};\n\nconst BLOCK_MARKER = ':';\n\n/**\n * Strip a delimited \"block\" from the start of the `messagePart`, if it is found.\n *\n * If a marker character (:) actually appears in the content at the start of a tagged string or\n * after a substitution expression, where a block has not been provided the character must be\n * escaped with a backslash, `\\:`. This function checks for this by looking at the `raw`\n * messagePart, which should still contain the backslash.\n *\n * @param messagePart The cooked message part to process.\n * @param rawMessagePart The raw message part to check.\n * @returns the message part with the placeholder name stripped, if found.\n * @throws an error if the block is unterminated\n */\nfunction stripBlock(messagePart: string, rawMessagePart: string) {\n return rawMessagePart.charAt(0) === BLOCK_MARKER\n ? messagePart.substring(findEndOfBlock(messagePart, rawMessagePart) + 1)\n : messagePart;\n}\n"],"names":["BLOCK_MARKER","MEANING_SEPARATOR","ID_SEPARATOR","LEGACY_ID_INDICATOR","textEncoder","fingerprint","str","TextEncoder","utf8","encode","view","DataView","buffer","byteOffset","byteLength","hi","hash32","length","lo","BigInt","asUintN","computeMsgId","msg","meaning","msgFingerprint","toString","c","a","b","index","end","getUint32","res","mix","remainder","getUint8","Endian","parseMessage","messageParts","expressions","location","messagePartLocations","expressionLocations","substitutions","substitutionLocations","associatedMessageIds","metadata","parseMetadata","raw","cleanedMessageParts","text","placeholderNames","messageString","i","messagePart","placeholderName","computePlaceholderName","associatedMessageId","parsePlaceholder","undefined","push","messageId","customId","legacyIds","filter","id","description","cooked","block","splitBlock","meaningDescAndId","split","meaningAndDesc","charAt","endOfBlock","findEndOfBlock","substring","cookedIndex","rawIndex","Error","$localize","translate","translation","message","stripBlock","rawMessagePart"],"mappings":";;;;;;AAoBO,MAAMA,cAAY,GAAG;AAYrB,MAAMC,iBAAiB,GAAG,GAAG;AAW7B,MAAMC,YAAY,GAAG,IAAI;AAiBzB,MAAMC,mBAAmB,GAAG,QAAQ;;AC7C3C,IAAIC,WAAoC;AAgMlC,SAAUC,WAAWA,CAACC,GAAW,EAAA;AACrCF,EAAAA,WAAW,KAAK,IAAIG,WAAW,EAAE;AACjC,EAAA,MAAMC,IAAI,GAAGJ,WAAW,CAACK,MAAM,CAACH,GAAG,CAAC;AACpC,EAAA,MAAMI,IAAI,GAAG,IAAIC,QAAQ,CAACH,IAAI,CAACI,MAAM,EAAEJ,IAAI,CAACK,UAAU,EAAEL,IAAI,CAACM,UAAU,CAAC;EAExE,IAAIC,EAAE,GAAGC,MAAM,CAACN,IAAI,EAAEF,IAAI,CAACS,MAAM,EAAE,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AKzE,YAAY,GAC5CsD,WAAW,CAACsB,SAAS,CAACD,cAAc,CAACrB,WAAW,EAAE+B,cAAc,CAAC,GAAG,CAAC,CAAA,GACrE/B,WAAW;AACjB;;;;"}
/**
* @license Angular v22.0.0-next.2
* @license Angular v22.0.0-next.3
* (c) 2010-2026 Google LLC. https://angular.dev/

@@ -4,0 +4,0 @@ * License: MIT

@@ -1,1 +0,1 @@

{"version":3,"file":"init.mjs","sources":["../../../../../k8-fastbuild-ST-fdfa778d11ba/bin/packages/localize/init/index.ts"],"sourcesContent":["/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\nimport {\n ɵ$localize as $localize,\n ɵLocalizeFn as LocalizeFn,\n ɵTranslateFn as TranslateFn,\n} from '../index';\n\nexport {$localize, LocalizeFn, TranslateFn};\n\n// Attach $localize to the global context, as a side-effect of this module.\n(globalThis as any).$localize = $localize;\n"],"names":["globalThis","$localize"],"mappings":";;;;;;;;AAgBCA,UAAkB,CAACC,SAAS,GAAGA,SAAS;;;;"}
{"version":3,"file":"init.mjs","sources":["../../../../../darwin_arm64-fastbuild-ST-fdfa778d11ba/bin/packages/localize/init/index.ts"],"sourcesContent":["/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\nimport {\n ɵ$localize as $localize,\n ɵLocalizeFn as LocalizeFn,\n ɵTranslateFn as TranslateFn,\n} from '../index';\n\nexport {$localize, LocalizeFn, TranslateFn};\n\n// Attach $localize to the global context, as a side-effect of this module.\n(globalThis as any).$localize = $localize;\n"],"names":["globalThis","$localize"],"mappings":";;;;;;;;AAgBCA,UAAkB,CAACC,SAAS,GAAGA,SAAS;;;;"}
/**
* @license Angular v22.0.0-next.2
* @license Angular v22.0.0-next.3
* (c) 2010-2026 Google LLC. https://angular.dev/

@@ -4,0 +4,0 @@ * License: MIT

@@ -1,1 +0,1 @@

{"version":3,"file":"localize.mjs","sources":["../../../../../k8-fastbuild-ST-fdfa778d11ba/bin/packages/localize/src/utils/src/translations.ts","../../../../../k8-fastbuild-ST-fdfa778d11ba/bin/packages/localize/src/translate.ts"],"sourcesContent":["/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\nimport {BLOCK_MARKER} from './constants';\nimport {MessageId, MessageMetadata, ParsedMessage, parseMessage, TargetMessage} from './messages';\n\n/**\n * A translation message that has been processed to extract the message parts and placeholders.\n */\nexport interface ParsedTranslation extends MessageMetadata {\n messageParts: TemplateStringsArray;\n placeholderNames: string[];\n}\n\n/**\n * The internal structure used by the runtime localization to translate messages.\n */\nexport type ParsedTranslations = Record<MessageId, ParsedTranslation>;\n\nexport class MissingTranslationError extends Error {\n private readonly type = 'MissingTranslationError';\n constructor(readonly parsedMessage: ParsedMessage) {\n super(`No translation found for ${describeMessage(parsedMessage)}.`);\n }\n}\n\nexport function isMissingTranslationError(e: any): e is MissingTranslationError {\n return e.type === 'MissingTranslationError';\n}\n\n/**\n * Translate the text of the `$localize` tagged-string (i.e. `messageParts` and\n * `substitutions`) using the given `translations`.\n *\n * The tagged-string is parsed to extract its `messageId` which is used to find an appropriate\n * `ParsedTranslation`. If this doesn't match and there are legacy ids then try matching a\n * translation using those.\n *\n * If one is found then it is used to translate the message into a new set of `messageParts` and\n * `substitutions`.\n * The translation may reorder (or remove) substitutions as appropriate.\n *\n * If there is no translation with a matching message id then an error is thrown.\n * If a translation contains a placeholder that is not found in the message being translated then an\n * error is thrown.\n */\nexport function translate(\n translations: Record<string, ParsedTranslation>,\n messageParts: TemplateStringsArray,\n substitutions: readonly any[],\n): [TemplateStringsArray, readonly any[]] {\n const message = parseMessage(messageParts, substitutions);\n // Look up the translation using the messageId, and then the legacyId if available.\n let translation = translations[message.id];\n // If the messageId did not match a translation, try matching the legacy ids instead\n if (message.legacyIds !== undefined) {\n for (let i = 0; i < message.legacyIds.length && translation === undefined; i++) {\n translation = translations[message.legacyIds[i]];\n }\n }\n if (translation === undefined) {\n throw new MissingTranslationError(message);\n }\n return [\n translation.messageParts,\n translation.placeholderNames.map((placeholder) => {\n if (message.substitutions.hasOwnProperty(placeholder)) {\n return message.substitutions[placeholder];\n } else {\n throw new Error(\n `There is a placeholder name mismatch with the translation provided for the message ${describeMessage(\n message,\n )}.\\n` +\n `The translation contains a placeholder with name ${placeholder}, which does not exist in the message.`,\n );\n }\n }),\n ];\n}\n\n/**\n * Parse the `messageParts` and `placeholderNames` out of a target `message`.\n *\n * Used by `loadTranslations()` to convert target message strings into a structure that is more\n * appropriate for doing translation.\n *\n * @param message the message to be parsed.\n */\nexport function parseTranslation(messageString: TargetMessage): ParsedTranslation {\n const parts = messageString.split(/{\\$([^}]*)}/);\n const messageParts = [parts[0]];\n const placeholderNames: string[] = [];\n for (let i = 1; i < parts.length - 1; i += 2) {\n placeholderNames.push(parts[i]);\n messageParts.push(`${parts[i + 1]}`);\n }\n const rawMessageParts = messageParts.map((part) =>\n part.charAt(0) === BLOCK_MARKER ? '\\\\' + part : part,\n );\n return {\n text: messageString,\n messageParts: makeTemplateObject(messageParts, rawMessageParts),\n placeholderNames,\n };\n}\n\n/**\n * Create a `ParsedTranslation` from a set of `messageParts` and `placeholderNames`.\n *\n * @param messageParts The message parts to appear in the ParsedTranslation.\n * @param placeholderNames The names of the placeholders to intersperse between the `messageParts`.\n */\nexport function makeParsedTranslation(\n messageParts: string[],\n placeholderNames: string[] = [],\n): ParsedTranslation {\n let messageString = messageParts[0];\n for (let i = 0; i < placeholderNames.length; i++) {\n messageString += `{$${placeholderNames[i]}}${messageParts[i + 1]}`;\n }\n return {\n text: messageString,\n messageParts: makeTemplateObject(messageParts, messageParts),\n placeholderNames,\n };\n}\n\n/**\n * Create the specialized array that is passed to tagged-string tag functions.\n *\n * @param cooked The message parts with their escape codes processed.\n * @param raw The message parts with their escaped codes as-is.\n */\nexport function makeTemplateObject(cooked: string[], raw: string[]): TemplateStringsArray {\n Object.defineProperty(cooked, 'raw', {value: raw});\n return cooked as any;\n}\n\nfunction describeMessage(message: ParsedMessage): string {\n const meaningString = message.meaning && ` - \"${message.meaning}\"`;\n const legacy =\n message.legacyIds && message.legacyIds.length > 0\n ? ` [${message.legacyIds.map((l) => `\"${l}\"`).join(', ')}]`\n : '';\n return `\"${message.id}\"${legacy} (\"${message.text}\"${meaningString})`;\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\nimport {LocalizeFn} from './localize';\nimport {\n MessageId,\n ParsedTranslation,\n parseTranslation,\n TargetMessage,\n translate as _translate,\n} from './utils';\n\n/**\n * We augment the `$localize` object to also store the translations.\n *\n * Note that because the TRANSLATIONS are attached to a global object, they will be shared between\n * all applications that are running in a single page of the browser.\n */\ndeclare const $localize: LocalizeFn & {TRANSLATIONS: Record<MessageId, ParsedTranslation>};\n\n/**\n * Load translations for use by `$localize`, if doing runtime translation.\n *\n * If the `$localize` tagged strings are not going to be replaced at compiled time, it is possible\n * to load a set of translations that will be applied to the `$localize` tagged strings at runtime,\n * in the browser.\n *\n * Loading a new translation will overwrite a previous translation if it has the same `MessageId`.\n *\n * Note that `$localize` messages are only processed once, when the tagged string is first\n * encountered, and does not provide dynamic language changing without refreshing the browser.\n * Loading new translations later in the application life-cycle will not change the translated text\n * of messages that have already been translated.\n *\n * The message IDs and translations are in the same format as that rendered to \"simple JSON\"\n * translation files when extracting messages. In particular, placeholders in messages are rendered\n * using the `{$PLACEHOLDER_NAME}` syntax. For example the message from the following template:\n *\n * ```html\n * <div i18n>pre<span>inner-pre<b>bold</b>inner-post</span>post</div>\n * ```\n *\n * would have the following form in the `translations` map:\n *\n * ```ts\n * {\n * \"2932901491976224757\":\n * \"pre{$START_TAG_SPAN}inner-pre{$START_BOLD_TEXT}bold{$CLOSE_BOLD_TEXT}inner-post{$CLOSE_TAG_SPAN}post\"\n * }\n * ```\n *\n * @param translations A map from message ID to translated message.\n *\n * These messages are processed and added to a lookup based on their `MessageId`.\n *\n * @see {@link clearTranslations} for removing translations loaded using this function.\n * @see {@link /api/localize/init/$localize $localize} for tagging messages as needing to be translated.\n * @publicApi\n */\nexport function loadTranslations(translations: Record<MessageId, TargetMessage>) {\n // Ensure the translate function exists\n if (!$localize.translate) {\n $localize.translate = translate;\n }\n if (!$localize.TRANSLATIONS) {\n $localize.TRANSLATIONS = {};\n }\n Object.keys(translations).forEach((key) => {\n $localize.TRANSLATIONS[key] = parseTranslation(translations[key]);\n });\n}\n\n/**\n * Remove all translations for `$localize`, if doing runtime translation.\n *\n * All translations that had been loading into memory using `loadTranslations()` will be removed.\n *\n * @see {@link loadTranslations} for loading translations at runtime.\n * @see {@link /api/localize/init/$localize $localize} for tagging messages as needing to be translated.\n *\n * @publicApi\n */\nexport function clearTranslations() {\n $localize.translate = undefined;\n $localize.TRANSLATIONS = {};\n}\n\n/**\n * Translate the text of the given message, using the loaded translations.\n *\n * This function may reorder (or remove) substitutions as indicated in the matching translation.\n */\nexport function translate(\n messageParts: TemplateStringsArray,\n substitutions: readonly any[],\n): [TemplateStringsArray, readonly any[]] {\n try {\n return _translate($localize.TRANSLATIONS, messageParts, substitutions);\n } catch (e) {\n console.warn((e as Error).message);\n return [messageParts, substitutions];\n }\n}\n"],"names":["MissingTranslationError","Error","parsedMessage","type","constructor","describeMessage","isMissingTranslationError","e","translate","translations","messageParts","substitutions","message","parseMessage","translation","id","legacyIds","undefined","i","length","placeholderNames","map","placeholder","hasOwnProperty","parseTranslation","messageString","parts","split","push","rawMessageParts","part","charAt","BLOCK_MARKER","text","makeTemplateObject","makeParsedTranslation","cooked","raw","Object","defineProperty","value","meaningString","meaning","legacy","l","join","loadTranslations","$localize","TRANSLATIONS","keys","forEach","key","clearTranslations","_translate","console","warn"],"mappings":";;;;;;;;;AAuBM,MAAOA,uBAAwB,SAA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,IAAAA,SAAS,CAACC,YAAY,GAAG,EAAE;AAC7B;EACAV,MAAM,CAACW,IAAI,CAACxC,YAAY,CAAC,CAACyC,OAAO,CAAEC,GAAG,IAAI;AACxCJ,IAAAA,SAAS,CAACC,YAAY,CAACG,GAAG,CAAC,GAAG3B,gBAAgB,CAACf,YAAY,CAAC0C,GAAG,CAAC,CAAC;AACnE,GAAC,CAAC;AACJ;SAYgBC,iBAAiBA,GAAA;EAC/BL,SAAS,CAACvC,SAAS,GAAGS,SAAS;AAC/B8B,EAAAA,SAAS,CAACC,YAAY,GAAG,EAAE;AAC7B;AAOgB,SAAAxC,SAASA,CACvBE,YAAkC,EAClCC,aAA6B,EAAA;EAE7B,IAAI;IACF,OAAO0C,WAAU,CAACN,SAAS,CAACC,YAAY,EAAEtC,YAAY,EAAEC,aAAa,CAAC;GACvE,CAAC,OAAOJ,CAAC,EAAE;AACV+C,IAAAA,OAAO,CAACC,IAAI,CAAEhD,CAAW,CAACK,OAAO,CAAC;AAClC,IAAA,OAAO,CAACF,YAAY,EAAEC,aAAa,CAAC;AACtC;AACF;;;;"}
{"version":3,"file":"localize.mjs","sources":["../../../../../darwin_arm64-fastbuild-ST-fdfa778d11ba/bin/packages/localize/src/utils/src/translations.ts","../../../../../darwin_arm64-fastbuild-ST-fdfa778d11ba/bin/packages/localize/src/translate.ts"],"sourcesContent":["/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\nimport {BLOCK_MARKER} from './constants';\nimport {MessageId, MessageMetadata, ParsedMessage, parseMessage, TargetMessage} from './messages';\n\n/**\n * A translation message that has been processed to extract the message parts and placeholders.\n */\nexport interface ParsedTranslation extends MessageMetadata {\n messageParts: TemplateStringsArray;\n placeholderNames: string[];\n}\n\n/**\n * The internal structure used by the runtime localization to translate messages.\n */\nexport type ParsedTranslations = Record<MessageId, ParsedTranslation>;\n\nexport class MissingTranslationError extends Error {\n private readonly type = 'MissingTranslationError';\n constructor(readonly parsedMessage: ParsedMessage) {\n super(`No translation found for ${describeMessage(parsedMessage)}.`);\n }\n}\n\nexport function isMissingTranslationError(e: any): e is MissingTranslationError {\n return e.type === 'MissingTranslationError';\n}\n\n/**\n * Translate the text of the `$localize` tagged-string (i.e. `messageParts` and\n * `substitutions`) using the given `translations`.\n *\n * The tagged-string is parsed to extract its `messageId` which is used to find an appropriate\n * `ParsedTranslation`. If this doesn't match and there are legacy ids then try matching a\n * translation using those.\n *\n * If one is found then it is used to translate the message into a new set of `messageParts` and\n * `substitutions`.\n * The translation may reorder (or remove) substitutions as appropriate.\n *\n * If there is no translation with a matching message id then an error is thrown.\n * If a translation contains a placeholder that is not found in the message being translated then an\n * error is thrown.\n */\nexport function translate(\n translations: Record<string, ParsedTranslation>,\n messageParts: TemplateStringsArray,\n substitutions: readonly any[],\n): [TemplateStringsArray, readonly any[]] {\n const message = parseMessage(messageParts, substitutions);\n // Look up the translation using the messageId, and then the legacyId if available.\n let translation = translations[message.id];\n // If the messageId did not match a translation, try matching the legacy ids instead\n if (message.legacyIds !== undefined) {\n for (let i = 0; i < message.legacyIds.length && translation === undefined; i++) {\n translation = translations[message.legacyIds[i]];\n }\n }\n if (translation === undefined) {\n throw new MissingTranslationError(message);\n }\n return [\n translation.messageParts,\n translation.placeholderNames.map((placeholder) => {\n if (message.substitutions.hasOwnProperty(placeholder)) {\n return message.substitutions[placeholder];\n } else {\n throw new Error(\n `There is a placeholder name mismatch with the translation provided for the message ${describeMessage(\n message,\n )}.\\n` +\n `The translation contains a placeholder with name ${placeholder}, which does not exist in the message.`,\n );\n }\n }),\n ];\n}\n\n/**\n * Parse the `messageParts` and `placeholderNames` out of a target `message`.\n *\n * Used by `loadTranslations()` to convert target message strings into a structure that is more\n * appropriate for doing translation.\n *\n * @param message the message to be parsed.\n */\nexport function parseTranslation(messageString: TargetMessage): ParsedTranslation {\n const parts = messageString.split(/{\\$([^}]*)}/);\n const messageParts = [parts[0]];\n const placeholderNames: string[] = [];\n for (let i = 1; i < parts.length - 1; i += 2) {\n placeholderNames.push(parts[i]);\n messageParts.push(`${parts[i + 1]}`);\n }\n const rawMessageParts = messageParts.map((part) =>\n part.charAt(0) === BLOCK_MARKER ? '\\\\' + part : part,\n );\n return {\n text: messageString,\n messageParts: makeTemplateObject(messageParts, rawMessageParts),\n placeholderNames,\n };\n}\n\n/**\n * Create a `ParsedTranslation` from a set of `messageParts` and `placeholderNames`.\n *\n * @param messageParts The message parts to appear in the ParsedTranslation.\n * @param placeholderNames The names of the placeholders to intersperse between the `messageParts`.\n */\nexport function makeParsedTranslation(\n messageParts: string[],\n placeholderNames: string[] = [],\n): ParsedTranslation {\n let messageString = messageParts[0];\n for (let i = 0; i < placeholderNames.length; i++) {\n messageString += `{$${placeholderNames[i]}}${messageParts[i + 1]}`;\n }\n return {\n text: messageString,\n messageParts: makeTemplateObject(messageParts, messageParts),\n placeholderNames,\n };\n}\n\n/**\n * Create the specialized array that is passed to tagged-string tag functions.\n *\n * @param cooked The message parts with their escape codes processed.\n * @param raw The message parts with their escaped codes as-is.\n */\nexport function makeTemplateObject(cooked: string[], raw: string[]): TemplateStringsArray {\n Object.defineProperty(cooked, 'raw', {value: raw});\n return cooked as any;\n}\n\nfunction describeMessage(message: ParsedMessage): string {\n const meaningString = message.meaning && ` - \"${message.meaning}\"`;\n const legacy =\n message.legacyIds && message.legacyIds.length > 0\n ? ` [${message.legacyIds.map((l) => `\"${l}\"`).join(', ')}]`\n : '';\n return `\"${message.id}\"${legacy} (\"${message.text}\"${meaningString})`;\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\nimport {LocalizeFn} from './localize';\nimport {\n MessageId,\n ParsedTranslation,\n parseTranslation,\n TargetMessage,\n translate as _translate,\n} from './utils';\n\n/**\n * We augment the `$localize` object to also store the translations.\n *\n * Note that because the TRANSLATIONS are attached to a global object, they will be shared between\n * all applications that are running in a single page of the browser.\n */\ndeclare const $localize: LocalizeFn & {TRANSLATIONS: Record<MessageId, ParsedTranslation>};\n\n/**\n * Load translations for use by `$localize`, if doing runtime translation.\n *\n * If the `$localize` tagged strings are not going to be replaced at compiled time, it is possible\n * to load a set of translations that will be applied to the `$localize` tagged strings at runtime,\n * in the browser.\n *\n * Loading a new translation will overwrite a previous translation if it has the same `MessageId`.\n *\n * Note that `$localize` messages are only processed once, when the tagged string is first\n * encountered, and does not provide dynamic language changing without refreshing the browser.\n * Loading new translations later in the application life-cycle will not change the translated text\n * of messages that have already been translated.\n *\n * The message IDs and translations are in the same format as that rendered to \"simple JSON\"\n * translation files when extracting messages. In particular, placeholders in messages are rendered\n * using the `{$PLACEHOLDER_NAME}` syntax. For example the message from the following template:\n *\n * ```html\n * <div i18n>pre<span>inner-pre<b>bold</b>inner-post</span>post</div>\n * ```\n *\n * would have the following form in the `translations` map:\n *\n * ```ts\n * {\n * \"2932901491976224757\":\n * \"pre{$START_TAG_SPAN}inner-pre{$START_BOLD_TEXT}bold{$CLOSE_BOLD_TEXT}inner-post{$CLOSE_TAG_SPAN}post\"\n * }\n * ```\n *\n * @param translations A map from message ID to translated message.\n *\n * These messages are processed and added to a lookup based on their `MessageId`.\n *\n * @see {@link clearTranslations} for removing translations loaded using this function.\n * @see {@link /api/localize/init/$localize $localize} for tagging messages as needing to be translated.\n * @publicApi\n */\nexport function loadTranslations(translations: Record<MessageId, TargetMessage>) {\n // Ensure the translate function exists\n if (!$localize.translate) {\n $localize.translate = translate;\n }\n if (!$localize.TRANSLATIONS) {\n $localize.TRANSLATIONS = {};\n }\n Object.keys(translations).forEach((key) => {\n $localize.TRANSLATIONS[key] = parseTranslation(translations[key]);\n });\n}\n\n/**\n * Remove all translations for `$localize`, if doing runtime translation.\n *\n * All translations that had been loading into memory using `loadTranslations()` will be removed.\n *\n * @see {@link loadTranslations} for loading translations at runtime.\n * @see {@link /api/localize/init/$localize $localize} for tagging messages as needing to be translated.\n *\n * @publicApi\n */\nexport function clearTranslations() {\n $localize.translate = undefined;\n $localize.TRANSLATIONS = {};\n}\n\n/**\n * Translate the text of the given message, using the loaded translations.\n *\n * This function may reorder (or remove) substitutions as indicated in the matching translation.\n */\nexport function translate(\n messageParts: TemplateStringsArray,\n substitutions: readonly any[],\n): [TemplateStringsArray, readonly any[]] {\n try {\n return _translate($localize.TRANSLATIONS, messageParts, substitutions);\n } catch (e) {\n console.warn((e as Error).message);\n return [messageParts, substitutions];\n }\n}\n"],"names":["MissingTranslationError","Error","parsedMessage","type","constructor","describeMessage","isMissingTranslationError","e","translate","translations","messageParts","substitutions","message","parseMessage","translation","id","legacyIds","undefined","i","length","placeholderNames","map","placeholder","hasOwnProperty","parseTranslation","messageString","parts","split","push","rawMessageParts","part","charAt","BLOCK_MARKER","text","makeTemplateObject","makeParsedTranslation","cooked","raw","Object","defineProperty","value","meaningString","meaning","legacy","l","join","loadTranslations","$localize","TRANSLATIONS","keys","forEach","key","clearTranslations","_translate","console","warn"],"mappings":";;;;;;;;;AAuBM,MAAOA,uBAAwB,SAAQC,KAAK,CAAA;EAE3BC,aAAA;AADJC,EAAAA,IAAI,GAAG,yBAAyB;EACjDC,WAAAA,CAAqBF,aAA4B,EAAA;AAC/C,IAAA,KAAK,CAAC,CAA4BG,yBAAAA,EAAAA,eAAe,CAACH,aAAa,CAAC,GAAG,CAAC;IADjD,IAAa,CAAAA,aAAA,GAAbA,aAAa;AAElC;AACD;AAEK,SAAUI,yBAAyBA,CAACC,CAAM,EAAA;AAC9C,EAAA,OAAOA,CAAC,CAACJ,IAAI,KAAK,yBAAyB;AAC7C;SAkBgBK,WAASA,CACvBC,YAA+C,EAC/CC,YAAkC,EAClCC,aAA6B,EAAA;AAE7B,EAAA,MAAMC,OAAO,GAAGC,YAAY,CAACH,YAAY,EAAEC,aAAa,CAAC;AAEzD,EAAA,IAAIG,WAAW,GAAGL,YAAY,CAACG,OAAO,CAACG,EAAE,CAAC;AAE1C,EAA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+C,IAAAA,OAAO,CAACC,IAAI,CAAEhD,CAAW,CAACK,OAAO,CAAC;AAClC,IAAA,OAAO,CAACF,YAAY,EAAEC,aAAa,CAAC;AACtC;AACF;;;;"}
{
"name": "@angular/localize",
"version": "22.0.0-next.2",
"version": "22.0.0-next.3",
"description": "Angular - library for localizing messages",

@@ -70,4 +70,4 @@ "bin": {

"peerDependencies": {
"@angular/compiler": "22.0.0-next.2",
"@angular/compiler-cli": "22.0.0-next.2"
"@angular/compiler": "22.0.0-next.3",
"@angular/compiler-cli": "22.0.0-next.3"
},

@@ -74,0 +74,0 @@ "module": "./fesm2022/localize.mjs",

@@ -145,3 +145,3 @@ "use strict";

(0, import_dependencies.removePackageJsonDependency)(host, "@angular/localize");
return (0, import_utility.addDependency)("@angular/localize", `~22.0.0-next.2`);
return (0, import_utility.addDependency)("@angular/localize", `~22.0.0-next.3`);
}

@@ -148,0 +148,0 @@ function ng_add_default(options) {

@@ -14,3 +14,3 @@

checkDuplicateMessages
} from "./chunk-TZHZOBVD.js";
} from "./chunk-VVP7L7WP.js";
import {

@@ -25,3 +25,3 @@ ArbTranslationParser,

makeLocalePlugin
} from "./chunk-IVRM6V2B.js";
} from "./chunk-7PXQZPIU.js";
import {

@@ -36,3 +36,3 @@ Diagnostics,

unwrapSubstitutionsFromLocalizeCall
} from "./chunk-HR5KPXEW.js";
} from "./chunk-BNVRZOYA.js";

@@ -75,1 +75,2 @@ // packages/localize/tools/index.ts

*/
//# sourceMappingURL=index.js.map

@@ -16,4 +16,4 @@ #!/usr/bin/env node

parseFormatOptions
} from "../../chunk-TZHZOBVD.js";
import "../../chunk-HR5KPXEW.js";
} from "../../chunk-VVP7L7WP.js";
import "../../chunk-BNVRZOYA.js";

@@ -164,1 +164,2 @@ // packages/localize/tools/src/extract/cli.ts

*/
//# sourceMappingURL=cli.js.map

@@ -82,1 +82,2 @@ #!/usr/bin/env node

*/
//# sourceMappingURL=cli.js.map

@@ -15,6 +15,6 @@ #!/usr/bin/env node

makeLocalePlugin
} from "../../chunk-IVRM6V2B.js";
} from "../../chunk-7PXQZPIU.js";
import {
Diagnostics
} from "../../chunk-HR5KPXEW.js";
} from "../../chunk-BNVRZOYA.js";

@@ -363,1 +363,2 @@ // packages/localize/tools/src/translate/cli.ts

*/
//# sourceMappingURL=cli.js.map
/**
* @license Angular v22.0.0-next.2
* @license Angular v22.0.0-next.3
* (c) 2010-2026 Google LLC. https://angular.dev/

@@ -4,0 +4,0 @@ * License: MIT

/**
* @license Angular v22.0.0-next.2
* @license Angular v22.0.0-next.3
* (c) 2010-2026 Google LLC. https://angular.dev/

@@ -4,0 +4,0 @@ * License: MIT

import {createRequire as __cjsCompatRequire} from 'module';
const require = __cjsCompatRequire(import.meta.url);
// packages/localize/tools/src/diagnostics.js
var Diagnostics = class {
messages = [];
get hasErrors() {
return this.messages.some((m) => m.type === "error");
}
add(type, message) {
if (type !== "ignore") {
this.messages.push({ type, message });
}
}
warn(message) {
this.messages.push({ type: "warning", message });
}
error(message) {
this.messages.push({ type: "error", message });
}
merge(other) {
this.messages.push(...other.messages);
}
formatDiagnostics(message) {
const errors = this.messages.filter((d) => d.type === "error").map((d) => " - " + d.message);
const warnings = this.messages.filter((d) => d.type === "warning").map((d) => " - " + d.message);
if (errors.length) {
message += "\nERRORS:\n" + errors.join("\n");
}
if (warnings.length) {
message += "\nWARNINGS:\n" + warnings.join("\n");
}
return message;
}
};
// packages/localize/tools/src/source_file_utils.js
import { getFileSystem } from "@angular/compiler-cli/private/localize";
// packages/localize/src/utils/src/constants.js
var BLOCK_MARKER = ":";
var MEANING_SEPARATOR = "|";
var ID_SEPARATOR = "@@";
var LEGACY_ID_INDICATOR = "\u241F";
// packages/compiler/src/i18n/digest.js
var textEncoder;
var _SerializerVisitor = class {
visitText(text, context) {
return text.value;
}
visitContainer(container, context) {
return `[${container.children.map((child) => child.visit(this)).join(", ")}]`;
}
visitIcu(icu, context) {
const strCases = Object.keys(icu.cases).map((k) => `${k} {${icu.cases[k].visit(this)}}`);
return `{${icu.expression}, ${icu.type}, ${strCases.join(", ")}}`;
}
visitTagPlaceholder(ph, context) {
return ph.isVoid ? `<ph tag name="${ph.startName}"/>` : `<ph tag name="${ph.startName}">${ph.children.map((child) => child.visit(this)).join(", ")}</ph name="${ph.closeName}">`;
}
visitPlaceholder(ph, context) {
return ph.value ? `<ph name="${ph.name}">${ph.value}</ph>` : `<ph name="${ph.name}"/>`;
}
visitIcuPlaceholder(ph, context) {
return `<ph icu name="${ph.name}">${ph.value.visit(this)}</ph>`;
}
visitBlockPlaceholder(ph, context) {
return `<ph block name="${ph.startName}">${ph.children.map((child) => child.visit(this)).join(", ")}</ph name="${ph.closeName}">`;
}
};
var serializerVisitor = new _SerializerVisitor();
function fingerprint(str) {
textEncoder ??= new TextEncoder();
const utf8 = textEncoder.encode(str);
const view = new DataView(utf8.buffer, utf8.byteOffset, utf8.byteLength);
let hi = hash32(view, utf8.length, 0);
let lo = hash32(view, utf8.length, 102072);
if (hi == 0 && (lo == 0 || lo == 1)) {
hi = hi ^ 319790063;
lo = lo ^ -1801410264;
}
return BigInt.asUintN(32, BigInt(hi)) << BigInt(32) | BigInt.asUintN(32, BigInt(lo));
}
function computeMsgId(msg, meaning = "") {
let msgFingerprint = fingerprint(msg);
if (meaning) {
msgFingerprint = BigInt.asUintN(64, msgFingerprint << BigInt(1)) | msgFingerprint >> BigInt(63) & BigInt(1);
msgFingerprint += fingerprint(meaning);
}
return BigInt.asUintN(63, msgFingerprint).toString();
}
function hash32(view, length, c) {
let a = 2654435769, b = 2654435769;
let index = 0;
const end = length - 12;
for (; index <= end; index += 12) {
a += view.getUint32(index, true);
b += view.getUint32(index + 4, true);
c += view.getUint32(index + 8, true);
const res = mix(a, b, c);
a = res[0], b = res[1], c = res[2];
}
const remainder = length - index;
c += length;
if (remainder >= 4) {
a += view.getUint32(index, true);
index += 4;
if (remainder >= 8) {
b += view.getUint32(index, true);
index += 4;
if (remainder >= 9) {
c += view.getUint8(index++) << 8;
}
if (remainder >= 10) {
c += view.getUint8(index++) << 16;
}
if (remainder === 11) {
c += view.getUint8(index++) << 24;
}
} else {
if (remainder >= 5) {
b += view.getUint8(index++);
}
if (remainder >= 6) {
b += view.getUint8(index++) << 8;
}
if (remainder === 7) {
b += view.getUint8(index++) << 16;
}
}
} else {
if (remainder >= 1) {
a += view.getUint8(index++);
}
if (remainder >= 2) {
a += view.getUint8(index++) << 8;
}
if (remainder === 3) {
a += view.getUint8(index++) << 16;
}
}
return mix(a, b, c)[2];
}
function mix(a, b, c) {
a -= b;
a -= c;
a ^= c >>> 13;
b -= c;
b -= a;
b ^= a << 8;
c -= a;
c -= b;
c ^= b >>> 13;
a -= b;
a -= c;
a ^= c >>> 12;
b -= c;
b -= a;
b ^= a << 16;
c -= a;
c -= b;
c ^= b >>> 5;
a -= b;
a -= c;
a ^= c >>> 3;
b -= c;
b -= a;
b ^= a << 10;
c -= a;
c -= b;
c ^= b >>> 15;
return [a, b, c];
}
var Endian;
(function(Endian2) {
Endian2[Endian2["Little"] = 0] = "Little";
Endian2[Endian2["Big"] = 1] = "Big";
})(Endian || (Endian = {}));
// packages/localize/src/utils/src/messages.js
function parseMessage(messageParts, expressions, location, messagePartLocations, expressionLocations = []) {
const substitutions = {};
const substitutionLocations = {};
const associatedMessageIds = {};
const metadata = parseMetadata(messageParts[0], messageParts.raw[0]);
const cleanedMessageParts = [metadata.text];
const placeholderNames = [];
let messageString = metadata.text;
for (let i = 1; i < messageParts.length; i++) {
const { messagePart, placeholderName = computePlaceholderName(i), associatedMessageId } = parsePlaceholder(messageParts[i], messageParts.raw[i]);
messageString += `{$${placeholderName}}${messagePart}`;
if (expressions !== void 0) {
substitutions[placeholderName] = expressions[i - 1];
substitutionLocations[placeholderName] = expressionLocations[i - 1];
}
placeholderNames.push(placeholderName);
if (associatedMessageId !== void 0) {
associatedMessageIds[placeholderName] = associatedMessageId;
}
cleanedMessageParts.push(messagePart);
}
const messageId = metadata.customId || computeMsgId(messageString, metadata.meaning || "");
const legacyIds = metadata.legacyIds ? metadata.legacyIds.filter((id) => id !== messageId) : [];
return {
id: messageId,
legacyIds,
substitutions,
substitutionLocations,
text: messageString,
customId: metadata.customId,
meaning: metadata.meaning || "",
description: metadata.description || "",
messageParts: cleanedMessageParts,
messagePartLocations,
placeholderNames,
associatedMessageIds,
location
};
}
function parseMetadata(cooked, raw) {
const { text: messageString, block } = splitBlock(cooked, raw);
if (block === void 0) {
return { text: messageString };
} else {
const [meaningDescAndId, ...legacyIds] = block.split(LEGACY_ID_INDICATOR);
const [meaningAndDesc, customId] = meaningDescAndId.split(ID_SEPARATOR, 2);
let [meaning, description] = meaningAndDesc.split(MEANING_SEPARATOR, 2);
if (description === void 0) {
description = meaning;
meaning = void 0;
}
if (description === "") {
description = void 0;
}
return { text: messageString, meaning, description, customId, legacyIds };
}
}
function parsePlaceholder(cooked, raw) {
const { text: messagePart, block } = splitBlock(cooked, raw);
if (block === void 0) {
return { messagePart };
} else {
const [placeholderName, associatedMessageId] = block.split(ID_SEPARATOR);
return { messagePart, placeholderName, associatedMessageId };
}
}
function splitBlock(cooked, raw) {
if (raw.charAt(0) !== BLOCK_MARKER) {
return { text: cooked };
} else {
const endOfBlock = findEndOfBlock(cooked, raw);
return {
block: cooked.substring(1, endOfBlock),
text: cooked.substring(endOfBlock + 1)
};
}
}
function computePlaceholderName(index) {
return index === 1 ? "PH" : `PH_${index - 1}`;
}
function findEndOfBlock(cooked, raw) {
for (let cookedIndex = 1, rawIndex = 1; cookedIndex < cooked.length; cookedIndex++, rawIndex++) {
if (raw[rawIndex] === "\\") {
rawIndex++;
} else if (cooked[cookedIndex] === BLOCK_MARKER) {
return cookedIndex;
}
}
throw new Error(`Unterminated $localize metadata block in "${raw}".`);
}
// packages/localize/src/utils/src/translations.js
var MissingTranslationError = class extends Error {
parsedMessage;
type = "MissingTranslationError";
constructor(parsedMessage) {
super(`No translation found for ${describeMessage(parsedMessage)}.`);
this.parsedMessage = parsedMessage;
}
};
function isMissingTranslationError(e) {
return e.type === "MissingTranslationError";
}
function translate(translations, messageParts, substitutions) {
const message = parseMessage(messageParts, substitutions);
let translation = translations[message.id];
if (message.legacyIds !== void 0) {
for (let i = 0; i < message.legacyIds.length && translation === void 0; i++) {
translation = translations[message.legacyIds[i]];
}
}
if (translation === void 0) {
throw new MissingTranslationError(message);
}
return [
translation.messageParts,
translation.placeholderNames.map((placeholder) => {
if (message.substitutions.hasOwnProperty(placeholder)) {
return message.substitutions[placeholder];
} else {
throw new Error(`There is a placeholder name mismatch with the translation provided for the message ${describeMessage(message)}.
The translation contains a placeholder with name ${placeholder}, which does not exist in the message.`);
}
})
];
}
function parseTranslation(messageString) {
const parts = messageString.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 {
text: messageString,
messageParts: makeTemplateObject(messageParts, rawMessageParts),
placeholderNames
};
}
function makeParsedTranslation(messageParts, placeholderNames = []) {
let messageString = messageParts[0];
for (let i = 0; i < placeholderNames.length; i++) {
messageString += `{$${placeholderNames[i]}}${messageParts[i + 1]}`;
}
return {
text: messageString,
messageParts: makeTemplateObject(messageParts, messageParts),
placeholderNames
};
}
function makeTemplateObject(cooked, raw) {
Object.defineProperty(cooked, "raw", { value: raw });
return cooked;
}
function describeMessage(message) {
const meaningString = message.meaning && ` - "${message.meaning}"`;
const legacy = message.legacyIds && message.legacyIds.length > 0 ? ` [${message.legacyIds.map((l) => `"${l}"`).join(", ")}]` : "";
return `"${message.id}"${legacy} ("${message.text}"${meaningString})`;
}
// packages/localize/tools/src/source_file_utils.js
import { types as t } from "@babel/core";
function isLocalize(expression, localizeName) {
return isNamedIdentifier(expression, localizeName) && isGlobalIdentifier(expression);
}
function isNamedIdentifier(expression, name) {
return expression.isIdentifier() && expression.node.name === name;
}
function isGlobalIdentifier(identifier) {
return !identifier.scope || !identifier.scope.hasBinding(identifier.node.name);
}
function buildLocalizeReplacement(messageParts, substitutions) {
let mappedString = t.stringLiteral(messageParts[0]);
for (let i = 1; i < messageParts.length; i++) {
mappedString = t.binaryExpression("+", mappedString, wrapInParensIfNecessary(substitutions[i - 1]));
mappedString = t.binaryExpression("+", mappedString, t.stringLiteral(messageParts[i]));
}
return mappedString;
}
function unwrapMessagePartsFromLocalizeCall(call, fs = getFileSystem()) {
let cooked = call.get("arguments")[0];
if (cooked === void 0) {
throw new BabelParseError(call.node, "`$localize` called without any arguments.");
}
if (!cooked.isExpression()) {
throw new BabelParseError(cooked.node, "Unexpected argument to `$localize` (expected an array).");
}
let raw = cooked;
if (cooked.isLogicalExpression() && cooked.node.operator === "||" && cooked.get("left").isIdentifier()) {
const right = cooked.get("right");
if (right.isAssignmentExpression()) {
cooked = right.get("right");
if (!cooked.isExpression()) {
throw new BabelParseError(cooked.node, 'Unexpected "makeTemplateObject()" function (expected an expression).');
}
} else if (right.isSequenceExpression()) {
const expressions = right.get("expressions");
if (expressions.length > 2) {
const [first, second] = expressions;
if (first.isAssignmentExpression()) {
cooked = first.get("right");
if (!cooked.isExpression()) {
throw new BabelParseError(first.node, "Unexpected cooked value, expected an expression.");
}
if (second.isAssignmentExpression()) {
raw = second.get("right");
if (!raw.isExpression()) {
throw new BabelParseError(second.node, "Unexpected raw value, expected an expression.");
}
} else {
raw = cooked;
}
}
}
}
}
if (cooked.isCallExpression()) {
let call2 = cooked;
if (call2.get("arguments").length === 0) {
call2 = unwrapLazyLoadHelperCall(call2);
}
cooked = call2.get("arguments")[0];
if (!cooked.isExpression()) {
throw new BabelParseError(cooked.node, 'Unexpected `cooked` argument to the "makeTemplateObject()" function (expected an expression).');
}
const arg2 = call2.get("arguments")[1];
if (arg2 && !arg2.isExpression()) {
throw new BabelParseError(arg2.node, 'Unexpected `raw` argument to the "makeTemplateObject()" function (expected an expression).');
}
raw = arg2 !== void 0 ? arg2 : cooked;
}
const [cookedStrings] = unwrapStringLiteralArray(cooked, fs);
const [rawStrings, rawLocations] = unwrapStringLiteralArray(raw, fs);
return [makeTemplateObject(cookedStrings, rawStrings), rawLocations];
}
function unwrapSubstitutionsFromLocalizeCall(call, fs = getFileSystem()) {
const expressions = call.get("arguments").splice(1);
if (!isArrayOfExpressions(expressions)) {
const badExpression = expressions.find((expression) => !expression.isExpression());
throw new BabelParseError(badExpression.node, "Invalid substitutions for `$localize` (expected all substitution arguments to be expressions).");
}
return [
expressions.map((path) => path.node),
expressions.map((expression) => getLocation(fs, expression))
];
}
function unwrapMessagePartsFromTemplateLiteral(elements, fs = getFileSystem()) {
const cooked = elements.map((q) => {
if (q.node.value.cooked === void 0) {
throw new BabelParseError(q.node, `Unexpected undefined message part in "${elements.map((q2) => q2.node.value.cooked)}"`);
}
return q.node.value.cooked;
});
const raw = elements.map((q) => q.node.value.raw);
const locations = elements.map((q) => getLocation(fs, q));
return [makeTemplateObject(cooked, raw), locations];
}
function unwrapExpressionsFromTemplateLiteral(quasi, fs = getFileSystem()) {
return [
quasi.node.expressions,
quasi.get("expressions").map((e) => getLocation(fs, e))
];
}
function wrapInParensIfNecessary(expression) {
if (t.isBinaryExpression(expression)) {
return t.parenthesizedExpression(expression);
} else {
return expression;
}
}
function unwrapStringLiteralArray(array, fs = getFileSystem()) {
if (!isStringLiteralArray(array.node)) {
throw new BabelParseError(array.node, "Unexpected messageParts for `$localize` (expected an array of strings).");
}
const elements = array.get("elements");
return [elements.map((str) => str.node.value), elements.map((str) => getLocation(fs, str))];
}
function unwrapLazyLoadHelperCall(call) {
const callee = call.get("callee");
if (!callee.isIdentifier()) {
throw new BabelParseError(callee.node, "Unexpected lazy-load helper call (expected a call of the form `_templateObject()`).");
}
const lazyLoadBinding = call.scope.getBinding(callee.node.name);
if (!lazyLoadBinding) {
throw new BabelParseError(callee.node, "Missing declaration for lazy-load helper function");
}
const lazyLoadFn = lazyLoadBinding.path;
if (!lazyLoadFn.isFunctionDeclaration()) {
throw new BabelParseError(lazyLoadFn.node, "Unexpected expression (expected a function declaration");
}
const returnedNode = getReturnedExpression(lazyLoadFn);
if (returnedNode.isCallExpression()) {
return returnedNode;
}
if (returnedNode.isIdentifier()) {
const identifierName = returnedNode.node.name;
const declaration = returnedNode.scope.getBinding(identifierName);
if (declaration === void 0) {
throw new BabelParseError(returnedNode.node, "Missing declaration for return value from helper.");
}
if (!declaration.path.isVariableDeclarator()) {
throw new BabelParseError(declaration.path.node, "Unexpected helper return value declaration (expected a variable declaration).");
}
const initializer = declaration.path.get("init");
if (!initializer.isCallExpression()) {
throw new BabelParseError(declaration.path.node, "Unexpected return value from helper (expected a call expression).");
}
if (lazyLoadBinding.references === 1) {
lazyLoadFn.remove();
}
return initializer;
}
return call;
}
function getReturnedExpression(fn) {
const bodyStatements = fn.get("body").get("body");
for (const statement of bodyStatements) {
if (statement.isReturnStatement()) {
const argument = statement.get("argument");
if (argument.isSequenceExpression()) {
const expressions = argument.get("expressions");
return Array.isArray(expressions) ? expressions[expressions.length - 1] : expressions;
} else if (argument.isExpression()) {
return argument;
} else {
throw new BabelParseError(statement.node, "Invalid return argument in helper function (expected an expression).");
}
}
}
throw new BabelParseError(fn.node, "Missing return statement in helper function.");
}
function isStringLiteralArray(node) {
return t.isArrayExpression(node) && node.elements.every((element) => t.isStringLiteral(element));
}
function isArrayOfExpressions(paths) {
return paths.every((element) => element.isExpression());
}
function translate2(diagnostics, translations, messageParts, substitutions, missingTranslation) {
try {
return translate(translations, messageParts, substitutions);
} catch (e) {
if (isMissingTranslationError(e)) {
diagnostics.add(missingTranslation, e.message);
return [
makeTemplateObject(e.parsedMessage.messageParts, e.parsedMessage.messageParts),
substitutions
];
} else {
diagnostics.error(e.message);
return [messageParts, substitutions];
}
}
}
var BabelParseError = class extends Error {
node;
type = "BabelParseError";
constructor(node, message) {
super(message);
this.node = node;
}
};
function isBabelParseError(e) {
return e.type === "BabelParseError";
}
function buildCodeFrameError(fs, path, file, e) {
let filename = file.opts.filename;
if (filename) {
filename = fs.resolve(filename);
let cwd = file.opts.cwd;
if (cwd) {
cwd = fs.resolve(cwd);
filename = fs.relative(cwd, filename);
}
} else {
filename = "(unknown file)";
}
const { message } = file.hub.buildError(e.node, e.message);
return `${filename}: ${message}`;
}
function getLocation(fs, startPath, endPath) {
const startLocation = startPath.node.loc;
const file = getFileFromPath(fs, startPath);
if (!startLocation || !file) {
return void 0;
}
const endLocation = endPath && getFileFromPath(fs, endPath) === file && endPath.node.loc || startLocation;
return {
start: getLineAndColumn(startLocation.start),
end: getLineAndColumn(endLocation.end),
file,
text: startPath.getSource() || void 0
};
}
function serializeLocationPosition(location) {
const endLineString = location.end !== void 0 && location.end.line !== location.start.line ? `,${location.end.line + 1}` : "";
return `${location.start.line + 1}${endLineString}`;
}
function getFileFromPath(fs, path) {
const opts = (path?.hub).file?.opts;
const filename = opts?.filename;
if (!filename || !opts.cwd) {
return null;
}
const relativePath = fs.relative(opts.cwd, filename);
const root = opts.generatorOpts?.sourceRoot ?? opts.cwd;
const absPath = fs.resolve(root, relativePath);
return absPath;
}
function getLineAndColumn(loc) {
return { line: loc.line - 1, column: loc.column };
}
export {
Diagnostics,
parseMessage,
parseTranslation,
makeParsedTranslation,
isLocalize,
isNamedIdentifier,
isGlobalIdentifier,
buildLocalizeReplacement,
unwrapMessagePartsFromLocalizeCall,
unwrapSubstitutionsFromLocalizeCall,
unwrapMessagePartsFromTemplateLiteral,
unwrapExpressionsFromTemplateLiteral,
translate2 as translate,
isBabelParseError,
buildCodeFrameError,
getLocation,
serializeLocationPosition
};
/**
* @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.dev/license
*/
import {createRequire as __cjsCompatRequire} from 'module';
const require = __cjsCompatRequire(import.meta.url);
import {
Diagnostics,
buildCodeFrameError,
buildLocalizeReplacement,
isBabelParseError,
isLocalize,
makeParsedTranslation,
parseTranslation,
translate,
unwrapMessagePartsFromLocalizeCall,
unwrapMessagePartsFromTemplateLiteral,
unwrapSubstitutionsFromLocalizeCall
} from "./chunk-HR5KPXEW.js";
// packages/localize/tools/src/translate/source_files/es2015_translate_plugin.js
import { getFileSystem } from "@angular/compiler-cli/private/localize";
function makeEs2015TranslatePlugin(diagnostics, translations, { missingTranslation = "error", localizeName = "$localize" } = {}, fs = getFileSystem()) {
return {
visitor: {
TaggedTemplateExpression(path, state) {
try {
const tag = path.get("tag");
if (isLocalize(tag, localizeName)) {
const [messageParts] = unwrapMessagePartsFromTemplateLiteral(path.get("quasi").get("quasis"), fs);
const translated = translate(diagnostics, translations, messageParts, path.node.quasi.expressions, missingTranslation);
path.replaceWith(buildLocalizeReplacement(translated[0], translated[1]));
}
} catch (e) {
if (isBabelParseError(e)) {
throw buildCodeFrameError(fs, path, state.file, e);
} else {
throw e;
}
}
}
}
};
}
// packages/localize/tools/src/translate/source_files/es5_translate_plugin.js
import { getFileSystem as getFileSystem2 } from "@angular/compiler-cli/private/localize";
function makeEs5TranslatePlugin(diagnostics, translations, { missingTranslation = "error", localizeName = "$localize" } = {}, fs = getFileSystem2()) {
return {
visitor: {
CallExpression(callPath, state) {
try {
const calleePath = callPath.get("callee");
if (isLocalize(calleePath, localizeName)) {
const [messageParts] = unwrapMessagePartsFromLocalizeCall(callPath, fs);
const [expressions] = unwrapSubstitutionsFromLocalizeCall(callPath, fs);
const translated = translate(diagnostics, translations, messageParts, expressions, missingTranslation);
callPath.replaceWith(buildLocalizeReplacement(translated[0], translated[1]));
}
} catch (e) {
if (isBabelParseError(e)) {
diagnostics.error(buildCodeFrameError(fs, callPath, state.file, e));
} else {
throw e;
}
}
}
}
};
}
// packages/localize/tools/src/translate/source_files/locale_plugin.js
import { types as t } from "@babel/core";
function makeLocalePlugin(locale, { localizeName = "$localize" } = {}) {
return {
visitor: {
MemberExpression(expression) {
const obj = expression.get("object");
if (!isLocalize(obj, localizeName)) {
return;
}
const property = expression.get("property");
if (!property.isIdentifier({ name: "locale" })) {
return;
}
if (expression.parentPath.isAssignmentExpression() && expression.parentPath.get("left") === expression) {
return;
}
const parent = expression.parentPath;
if (parent.isLogicalExpression({ operator: "&&" }) && parent.get("right") === expression) {
const left = parent.get("left");
if (isLocalizeGuard(left, localizeName)) {
parent.replaceWith(expression);
} else if (left.isLogicalExpression({ operator: "&&" }) && isLocalizeGuard(left.get("right"), localizeName)) {
left.replaceWith(left.get("left"));
}
}
expression.replaceWith(t.stringLiteral(locale));
}
}
};
}
function isLocalizeGuard(expression, localizeName) {
if (!expression.isBinaryExpression() || !(expression.node.operator === "!==" || expression.node.operator === "!=")) {
return false;
}
const left = expression.get("left");
const right = expression.get("right");
return left.isUnaryExpression({ operator: "typeof" }) && isLocalize(left.get("argument"), localizeName) && right.isStringLiteral({ value: "undefined" }) || right.isUnaryExpression({ operator: "typeof" }) && isLocalize(right.get("argument"), localizeName) && left.isStringLiteral({ value: "undefined" });
}
// packages/localize/tools/src/translate/translation_files/translation_parsers/arb_translation_parser.js
var ArbTranslationParser = class {
analyze(_filePath, contents) {
const diagnostics = new Diagnostics();
if (!contents.includes('"@@locale"')) {
return { canParse: false, diagnostics };
}
try {
return { canParse: true, diagnostics, hint: this.tryParseArbFormat(contents) };
} catch {
diagnostics.warn("File is not valid JSON.");
return { canParse: false, diagnostics };
}
}
parse(_filePath, contents, arb = this.tryParseArbFormat(contents)) {
const bundle = {
locale: arb["@@locale"],
translations: {},
diagnostics: new Diagnostics()
};
for (const messageId of Object.keys(arb)) {
if (messageId.startsWith("@")) {
continue;
}
const targetMessage = arb[messageId];
bundle.translations[messageId] = parseTranslation(targetMessage);
}
return bundle;
}
tryParseArbFormat(contents) {
const json = JSON.parse(contents);
if (typeof json["@@locale"] !== "string") {
throw new Error("Missing @@locale property.");
}
return json;
}
};
// packages/localize/tools/src/translate/translation_files/translation_parsers/simple_json_translation_parser.js
import { extname } from "path";
var SimpleJsonTranslationParser = class {
analyze(filePath, contents) {
const diagnostics = new Diagnostics();
if (extname(filePath) !== ".json" || !(contents.includes('"locale"') && contents.includes('"translations"'))) {
diagnostics.warn("File does not have .json extension.");
return { canParse: false, diagnostics };
}
try {
const json = JSON.parse(contents);
if (json.locale === void 0) {
diagnostics.warn('Required "locale" property missing.');
return { canParse: false, diagnostics };
}
if (typeof json.locale !== "string") {
diagnostics.warn('The "locale" property is not a string.');
return { canParse: false, diagnostics };
}
if (json.translations === void 0) {
diagnostics.warn('Required "translations" property missing.');
return { canParse: false, diagnostics };
}
if (typeof json.translations !== "object") {
diagnostics.warn('The "translations" is not an object.');
return { canParse: false, diagnostics };
}
return { canParse: true, diagnostics, hint: json };
} catch (e) {
diagnostics.warn("File is not valid JSON.");
return { canParse: false, diagnostics };
}
}
parse(_filePath, contents, json) {
const { locale: parsedLocale, translations } = json || JSON.parse(contents);
const parsedTranslations = {};
for (const messageId in translations) {
const targetMessage = translations[messageId];
parsedTranslations[messageId] = parseTranslation(targetMessage);
}
return { locale: parsedLocale, translations: parsedTranslations, diagnostics: new Diagnostics() };
}
};
// packages/localize/tools/src/translate/translation_files/translation_parsers/xliff1_translation_parser.js
import { ParseErrorLevel as ParseErrorLevel2, visitAll as visitAll2 } from "@angular/compiler";
// packages/localize/tools/src/translate/translation_files/base_visitor.js
var BaseVisitor = class {
visitElement(_element, _context) {
}
visitAttribute(_attribute, _context) {
}
visitText(_text, _context) {
}
visitComment(_comment, _context) {
}
visitExpansion(_expansion, _context) {
}
visitExpansionCase(_expansionCase, _context) {
}
visitBlock(_block, _context) {
}
visitBlockParameter(_parameter, _context) {
}
visitLetDeclaration(_decl, _context) {
}
visitComponent(_component, _context) {
}
visitDirective(_directive, _context) {
}
};
// packages/localize/tools/src/translate/translation_files/message_serialization/message_serializer.js
import { Element as Element2, ParseError as ParseError2, visitAll } from "@angular/compiler";
// packages/localize/tools/src/translate/translation_files/translation_parsers/translation_utils.js
import { Element, ParseError, ParseErrorLevel, XmlParser } from "@angular/compiler";
function getAttrOrThrow(element, attrName) {
const attrValue = getAttribute(element, attrName);
if (attrValue === void 0) {
throw new ParseError(element.sourceSpan, `Missing required "${attrName}" attribute:`);
}
return attrValue;
}
function getAttribute(element, attrName) {
const attr = element.attrs.find((a) => a.name === attrName);
return attr !== void 0 ? attr.value : void 0;
}
function parseInnerRange(element) {
const xmlParser = new XmlParser();
const xml = xmlParser.parse(element.sourceSpan.start.file.content, element.sourceSpan.start.file.url, { tokenizeExpansionForms: true, range: getInnerRange(element) });
return xml;
}
function getInnerRange(element) {
const start = element.startSourceSpan.end;
const end = element.endSourceSpan.start;
return {
startPos: start.offset,
startLine: start.line,
startCol: start.col,
endPos: end.offset
};
}
function canParseXml(filePath, contents, rootNodeName, attributes) {
const diagnostics = new Diagnostics();
const xmlParser = new XmlParser();
const xml = xmlParser.parse(contents, filePath);
if (xml.rootNodes.length === 0 || xml.errors.some((error) => error.level === ParseErrorLevel.ERROR)) {
xml.errors.forEach((e) => addParseError(diagnostics, e));
return { canParse: false, diagnostics };
}
const rootElements = xml.rootNodes.filter(isNamedElement(rootNodeName));
const rootElement = rootElements[0];
if (rootElement === void 0) {
diagnostics.warn(`The XML file does not contain a <${rootNodeName}> root node.`);
return { canParse: false, diagnostics };
}
for (const attrKey of Object.keys(attributes)) {
const attr = rootElement.attrs.find((attr2) => attr2.name === attrKey);
if (attr === void 0 || attr.value !== attributes[attrKey]) {
addParseDiagnostic(diagnostics, rootElement.sourceSpan, `The <${rootNodeName}> node does not have the required attribute: ${attrKey}="${attributes[attrKey]}".`, ParseErrorLevel.WARNING);
return { canParse: false, diagnostics };
}
}
if (rootElements.length > 1) {
xml.errors.push(new ParseError(xml.rootNodes[1].sourceSpan, "Unexpected root node. XLIFF 1.2 files should only have a single <xliff> root node.", ParseErrorLevel.WARNING));
}
return { canParse: true, diagnostics, hint: { element: rootElement, errors: xml.errors } };
}
function isNamedElement(name) {
function predicate(node) {
return node instanceof Element && node.name === name;
}
return predicate;
}
function addParseDiagnostic(diagnostics, sourceSpan, message, level) {
addParseError(diagnostics, new ParseError(sourceSpan, message, level));
}
function addParseError(diagnostics, parseError) {
if (parseError.level === ParseErrorLevel.ERROR) {
diagnostics.error(parseError.toString());
} else {
diagnostics.warn(parseError.toString());
}
}
function addErrorsToBundle(bundle, errors) {
for (const error of errors) {
addParseError(bundle.diagnostics, error);
}
}
// packages/localize/tools/src/translate/translation_files/message_serialization/message_serializer.js
var MessageSerializer = class extends BaseVisitor {
renderer;
config;
constructor(renderer, config) {
super();
this.renderer = renderer;
this.config = config;
}
serialize(nodes) {
this.renderer.startRender();
visitAll(this, nodes);
this.renderer.endRender();
return this.renderer.message;
}
visitElement(element) {
if (this.config.placeholder && element.name === this.config.placeholder.elementName) {
const name = getAttrOrThrow(element, this.config.placeholder.nameAttribute);
const body = this.config.placeholder.bodyAttribute && getAttribute(element, this.config.placeholder.bodyAttribute);
this.visitPlaceholder(name, body);
} else if (this.config.placeholderContainer && element.name === this.config.placeholderContainer.elementName) {
const start = getAttrOrThrow(element, this.config.placeholderContainer.startAttribute);
const end = getAttrOrThrow(element, this.config.placeholderContainer.endAttribute);
this.visitPlaceholderContainer(start, element.children, end);
} else if (this.config.inlineElements.indexOf(element.name) !== -1) {
visitAll(this, element.children);
} else {
throw new ParseError2(element.sourceSpan, `Invalid element found in message.`);
}
}
visitText(text) {
this.renderer.text(text.value);
}
visitExpansion(expansion) {
this.renderer.startIcu();
this.renderer.text(`${expansion.switchValue}, ${expansion.type},`);
visitAll(this, expansion.cases);
this.renderer.endIcu();
}
visitExpansionCase(expansionCase) {
this.renderer.text(` ${expansionCase.value} {`);
this.renderer.startContainer();
visitAll(this, expansionCase.expression);
this.renderer.closeContainer();
this.renderer.text(`}`);
}
visitContainedNodes(nodes) {
this.renderer.startContainer();
visitAll(this, nodes);
this.renderer.closeContainer();
}
visitPlaceholder(name, body) {
this.renderer.placeholder(name, body);
}
visitPlaceholderContainer(startName, children, closeName) {
this.renderer.startPlaceholder(startName);
this.visitContainedNodes(children);
this.renderer.closePlaceholder(closeName);
}
isPlaceholderContainer(node) {
return node instanceof Element2 && node.name === this.config.placeholderContainer.elementName;
}
};
// packages/localize/tools/src/translate/translation_files/message_serialization/target_message_renderer.js
var TargetMessageRenderer = class {
current = { messageParts: [], placeholderNames: [], text: "" };
icuDepth = 0;
get message() {
const { messageParts, placeholderNames } = this.current;
return makeParsedTranslation(messageParts, placeholderNames);
}
startRender() {
}
endRender() {
this.storeMessagePart();
}
text(text) {
this.current.text += text;
}
placeholder(name, body) {
this.renderPlaceholder(name);
}
startPlaceholder(name) {
this.renderPlaceholder(name);
}
closePlaceholder(name) {
this.renderPlaceholder(name);
}
startContainer() {
}
closeContainer() {
}
startIcu() {
this.icuDepth++;
this.text("{");
}
endIcu() {
this.icuDepth--;
this.text("}");
}
normalizePlaceholderName(name) {
return name.replace(/-/g, "_");
}
renderPlaceholder(name) {
name = this.normalizePlaceholderName(name);
if (this.icuDepth > 0) {
this.text(`{${name}}`);
} else {
this.storeMessagePart();
this.current.placeholderNames.push(name);
}
}
storeMessagePart() {
this.current.messageParts.push(this.current.text);
this.current.text = "";
}
};
// packages/localize/tools/src/translate/translation_files/translation_parsers/serialize_translation_message.js
function serializeTranslationMessage(element, config) {
const { rootNodes, errors: parseErrors } = parseInnerRange(element);
try {
const serializer = new MessageSerializer(new TargetMessageRenderer(), config);
const translation = serializer.serialize(rootNodes);
return { translation, parseErrors, serializeErrors: [] };
} catch (e) {
return { translation: null, parseErrors, serializeErrors: [e] };
}
}
// packages/localize/tools/src/translate/translation_files/translation_parsers/xliff1_translation_parser.js
var Xliff1TranslationParser = class {
analyze(filePath, contents) {
return canParseXml(filePath, contents, "xliff", { version: "1.2" });
}
parse(filePath, contents, hint) {
return this.extractBundle(hint);
}
extractBundle({ element, errors }) {
const diagnostics = new Diagnostics();
errors.forEach((e) => addParseError(diagnostics, e));
if (element.children.length === 0) {
addParseDiagnostic(diagnostics, element.sourceSpan, "Missing expected <file> element", ParseErrorLevel2.WARNING);
return { locale: void 0, translations: {}, diagnostics };
}
const files = element.children.filter(isNamedElement("file"));
if (files.length === 0) {
addParseDiagnostic(diagnostics, element.sourceSpan, "No <file> elements found in <xliff>", ParseErrorLevel2.WARNING);
} else if (files.length > 1) {
addParseDiagnostic(diagnostics, files[1].sourceSpan, "More than one <file> element found in <xliff>", ParseErrorLevel2.WARNING);
}
const bundle = { locale: void 0, translations: {}, diagnostics };
const translationVisitor = new XliffTranslationVisitor();
const localesFound = /* @__PURE__ */ new Set();
for (const file of files) {
const locale = getAttribute(file, "target-language");
if (locale !== void 0) {
localesFound.add(locale);
bundle.locale = locale;
}
visitAll2(translationVisitor, file.children, bundle);
}
if (localesFound.size > 1) {
addParseDiagnostic(diagnostics, element.sourceSpan, `More than one locale found in translation file: ${JSON.stringify(Array.from(localesFound))}. Using "${bundle.locale}"`, ParseErrorLevel2.WARNING);
}
return bundle;
}
};
var XliffTranslationVisitor = class extends BaseVisitor {
visitElement(element, bundle) {
if (element.name === "trans-unit") {
this.visitTransUnitElement(element, bundle);
} else {
visitAll2(this, element.children, bundle);
}
}
visitTransUnitElement(element, bundle) {
const id = getAttribute(element, "id");
if (id === void 0) {
addParseDiagnostic(bundle.diagnostics, element.sourceSpan, `Missing required "id" attribute on <trans-unit> element.`, ParseErrorLevel2.ERROR);
return;
}
if (bundle.translations[id] !== void 0) {
addParseDiagnostic(bundle.diagnostics, element.sourceSpan, `Duplicated translations for message "${id}"`, ParseErrorLevel2.ERROR);
return;
}
let targetMessage = element.children.find(isNamedElement("target"));
if (targetMessage === void 0) {
addParseDiagnostic(bundle.diagnostics, element.sourceSpan, "Missing <target> element", ParseErrorLevel2.WARNING);
targetMessage = element.children.find(isNamedElement("source"));
if (targetMessage === void 0) {
addParseDiagnostic(bundle.diagnostics, element.sourceSpan, "Missing required element: one of <target> or <source> is required", ParseErrorLevel2.ERROR);
return;
}
}
const { translation, parseErrors, serializeErrors } = serializeTranslationMessage(targetMessage, {
inlineElements: ["g", "bx", "ex", "bpt", "ept", "ph", "it", "mrk"],
placeholder: { elementName: "x", nameAttribute: "id" }
});
if (translation !== null) {
bundle.translations[id] = translation;
}
addErrorsToBundle(bundle, parseErrors);
addErrorsToBundle(bundle, serializeErrors);
}
};
// packages/localize/tools/src/translate/translation_files/translation_parsers/xliff2_translation_parser.js
import { Element as Element3, ParseErrorLevel as ParseErrorLevel3, visitAll as visitAll3 } from "@angular/compiler";
var Xliff2TranslationParser = class {
analyze(filePath, contents) {
return canParseXml(filePath, contents, "xliff", { version: "2.0" });
}
parse(filePath, contents, hint) {
return this.extractBundle(hint);
}
extractBundle({ element, errors }) {
const diagnostics = new Diagnostics();
errors.forEach((e) => addParseError(diagnostics, e));
const locale = getAttribute(element, "trgLang");
const files = element.children.filter(isFileElement);
if (files.length === 0) {
addParseDiagnostic(diagnostics, element.sourceSpan, "No <file> elements found in <xliff>", ParseErrorLevel3.WARNING);
} else if (files.length > 1) {
addParseDiagnostic(diagnostics, files[1].sourceSpan, "More than one <file> element found in <xliff>", ParseErrorLevel3.WARNING);
}
const bundle = { locale, translations: {}, diagnostics };
const translationVisitor = new Xliff2TranslationVisitor();
for (const file of files) {
visitAll3(translationVisitor, file.children, { bundle });
}
return bundle;
}
};
var Xliff2TranslationVisitor = class extends BaseVisitor {
visitElement(element, { bundle, unit }) {
if (element.name === "unit") {
this.visitUnitElement(element, bundle);
} else if (element.name === "segment") {
this.visitSegmentElement(element, bundle, unit);
} else {
visitAll3(this, element.children, { bundle, unit });
}
}
visitUnitElement(element, bundle) {
const externalId = getAttribute(element, "id");
if (externalId === void 0) {
addParseDiagnostic(bundle.diagnostics, element.sourceSpan, `Missing required "id" attribute on <trans-unit> element.`, ParseErrorLevel3.ERROR);
return;
}
if (bundle.translations[externalId] !== void 0) {
addParseDiagnostic(bundle.diagnostics, element.sourceSpan, `Duplicated translations for message "${externalId}"`, ParseErrorLevel3.ERROR);
return;
}
visitAll3(this, element.children, { bundle, unit: externalId });
}
visitSegmentElement(element, bundle, unit) {
if (unit === void 0) {
addParseDiagnostic(bundle.diagnostics, element.sourceSpan, "Invalid <segment> element: should be a child of a <unit> element.", ParseErrorLevel3.ERROR);
return;
}
let targetMessage = element.children.find(isNamedElement("target"));
if (targetMessage === void 0) {
addParseDiagnostic(bundle.diagnostics, element.sourceSpan, "Missing <target> element", ParseErrorLevel3.WARNING);
targetMessage = element.children.find(isNamedElement("source"));
if (targetMessage === void 0) {
addParseDiagnostic(bundle.diagnostics, element.sourceSpan, "Missing required element: one of <target> or <source> is required", ParseErrorLevel3.ERROR);
return;
}
}
const { translation, parseErrors, serializeErrors } = serializeTranslationMessage(targetMessage, {
inlineElements: ["cp", "sc", "ec", "mrk", "sm", "em"],
placeholder: { elementName: "ph", nameAttribute: "equiv", bodyAttribute: "disp" },
placeholderContainer: {
elementName: "pc",
startAttribute: "equivStart",
endAttribute: "equivEnd"
}
});
if (translation !== null) {
bundle.translations[unit] = translation;
}
addErrorsToBundle(bundle, parseErrors);
addErrorsToBundle(bundle, serializeErrors);
}
};
function isFileElement(node) {
return node instanceof Element3 && node.name === "file";
}
// packages/localize/tools/src/translate/translation_files/translation_parsers/xtb_translation_parser.js
import { ParseErrorLevel as ParseErrorLevel4, visitAll as visitAll4 } from "@angular/compiler";
import { extname as extname2 } from "path";
var XtbTranslationParser = class {
analyze(filePath, contents) {
const extension = extname2(filePath);
if (extension !== ".xtb" && extension !== ".xmb") {
const diagnostics = new Diagnostics();
diagnostics.warn("Must have xtb or xmb extension.");
return { canParse: false, diagnostics };
}
return canParseXml(filePath, contents, "translationbundle", {});
}
parse(filePath, contents, hint) {
return this.extractBundle(hint);
}
extractBundle({ element, errors }) {
const langAttr = element.attrs.find((attr) => attr.name === "lang");
const bundle = {
locale: langAttr && langAttr.value,
translations: {},
diagnostics: new Diagnostics()
};
errors.forEach((e) => addParseError(bundle.diagnostics, e));
const bundleVisitor = new XtbVisitor();
visitAll4(bundleVisitor, element.children, bundle);
return bundle;
}
};
var XtbVisitor = class extends BaseVisitor {
visitElement(element, bundle) {
switch (element.name) {
case "translation":
const id = getAttribute(element, "id");
if (id === void 0) {
addParseDiagnostic(bundle.diagnostics, element.sourceSpan, `Missing required "id" attribute on <translation> element.`, ParseErrorLevel4.ERROR);
return;
}
if (bundle.translations[id] !== void 0) {
addParseDiagnostic(bundle.diagnostics, element.sourceSpan, `Duplicated translations for message "${id}"`, ParseErrorLevel4.ERROR);
return;
}
const { translation, parseErrors, serializeErrors } = serializeTranslationMessage(element, {
inlineElements: [],
placeholder: { elementName: "ph", nameAttribute: "name" }
});
if (parseErrors.length) {
bundle.diagnostics.warn(computeParseWarning(id, parseErrors));
} else if (translation !== null) {
bundle.translations[id] = translation;
}
addErrorsToBundle(bundle, serializeErrors);
break;
default:
addParseDiagnostic(bundle.diagnostics, element.sourceSpan, `Unexpected <${element.name}> tag.`, ParseErrorLevel4.ERROR);
}
}
};
function computeParseWarning(id, errors) {
const msg = errors.map((e) => e.toString()).join("\n");
return `Could not parse message with id "${id}" - perhaps it has an unrecognised ICU format?
` + msg;
}
export {
makeEs2015TranslatePlugin,
makeEs5TranslatePlugin,
makeLocalePlugin,
ArbTranslationParser,
SimpleJsonTranslationParser,
Xliff1TranslationParser,
Xliff2TranslationParser,
XtbTranslationParser
};
/**
* @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.dev/license
*/
import {createRequire as __cjsCompatRequire} from 'module';
const require = __cjsCompatRequire(import.meta.url);
import {
Diagnostics,
buildCodeFrameError,
getLocation,
isBabelParseError,
isGlobalIdentifier,
isNamedIdentifier,
parseMessage,
serializeLocationPosition,
unwrapExpressionsFromTemplateLiteral,
unwrapMessagePartsFromLocalizeCall,
unwrapMessagePartsFromTemplateLiteral,
unwrapSubstitutionsFromLocalizeCall
} from "./chunk-HR5KPXEW.js";
// packages/localize/tools/src/extract/duplicates.js
function checkDuplicateMessages(fs, messages, duplicateMessageHandling, basePath) {
const diagnostics = new Diagnostics();
if (duplicateMessageHandling === "ignore")
return diagnostics;
const messageMap = /* @__PURE__ */ new Map();
for (const message of messages) {
if (messageMap.has(message.id)) {
messageMap.get(message.id).push(message);
} else {
messageMap.set(message.id, [message]);
}
}
for (const duplicates of messageMap.values()) {
if (duplicates.length <= 1)
continue;
if (duplicates.every((message) => message.text === duplicates[0].text))
continue;
const diagnosticMessage = `Duplicate messages with id "${duplicates[0].id}":
` + duplicates.map((message) => serializeMessage(fs, basePath, message)).join("\n");
diagnostics.add(duplicateMessageHandling, diagnosticMessage);
}
return diagnostics;
}
function serializeMessage(fs, basePath, message) {
if (message.location === void 0) {
return ` - "${message.text}"`;
} else {
const locationFile = fs.relative(basePath, message.location.file);
const locationPosition = serializeLocationPosition(message.location);
return ` - "${message.text}" : ${locationFile}:${locationPosition}`;
}
}
// packages/localize/tools/src/extract/extraction.js
import { SourceFileLoader } from "@angular/compiler-cli/private/localize";
import { transformSync } from "@babel/core";
// packages/localize/tools/src/extract/source_files/es2015_extract_plugin.js
function makeEs2015ExtractPlugin(fs, messages, localizeName = "$localize") {
return {
visitor: {
TaggedTemplateExpression(path) {
const tag = path.get("tag");
if (isNamedIdentifier(tag, localizeName) && isGlobalIdentifier(tag)) {
const quasiPath = path.get("quasi");
const [messageParts, messagePartLocations] = unwrapMessagePartsFromTemplateLiteral(quasiPath.get("quasis"), fs);
const [expressions, expressionLocations] = unwrapExpressionsFromTemplateLiteral(quasiPath, fs);
const location = getLocation(fs, quasiPath);
const message = parseMessage(messageParts, expressions, location, messagePartLocations, expressionLocations);
messages.push(message);
}
}
}
};
}
// packages/localize/tools/src/extract/source_files/es5_extract_plugin.js
function makeEs5ExtractPlugin(fs, messages, localizeName = "$localize") {
return {
visitor: {
CallExpression(callPath, state) {
try {
const calleePath = callPath.get("callee");
if (isNamedIdentifier(calleePath, localizeName) && isGlobalIdentifier(calleePath)) {
const [messageParts, messagePartLocations] = unwrapMessagePartsFromLocalizeCall(callPath, fs);
const [expressions, expressionLocations] = unwrapSubstitutionsFromLocalizeCall(callPath, fs);
const [messagePartsArg, expressionsArg] = callPath.get("arguments");
const location = getLocation(fs, messagePartsArg, expressionsArg);
const message = parseMessage(messageParts, expressions, location, messagePartLocations, expressionLocations);
messages.push(message);
}
} catch (e) {
if (isBabelParseError(e)) {
throw buildCodeFrameError(fs, callPath, state.file, e);
} else {
throw e;
}
}
}
}
};
}
// packages/localize/tools/src/extract/extraction.js
var MessageExtractor = class {
fs;
logger;
basePath;
useSourceMaps;
localizeName;
loader;
constructor(fs, logger, { basePath, useSourceMaps = true, localizeName = "$localize" }) {
this.fs = fs;
this.logger = logger;
this.basePath = basePath;
this.useSourceMaps = useSourceMaps;
this.localizeName = localizeName;
this.loader = new SourceFileLoader(this.fs, this.logger, { webpack: basePath });
}
extractMessages(filename) {
const messages = [];
const sourceCode = this.fs.readFile(this.fs.resolve(this.basePath, filename));
if (sourceCode.includes(this.localizeName)) {
transformSync(sourceCode, {
sourceRoot: this.basePath,
filename,
plugins: [
makeEs2015ExtractPlugin(this.fs, messages, this.localizeName),
makeEs5ExtractPlugin(this.fs, messages, this.localizeName)
],
code: false,
ast: false
});
if (this.useSourceMaps && messages.length > 0) {
this.updateSourceLocations(filename, sourceCode, messages);
}
}
return messages;
}
/**
* Update the location of each message to point to the source-mapped original source location, if
* available.
*/
updateSourceLocations(filename, contents, messages) {
const sourceFile = this.loader.loadSourceFile(this.fs.resolve(this.basePath, filename), contents);
if (sourceFile === null) {
return;
}
for (const message of messages) {
if (message.location !== void 0) {
message.location = this.getOriginalLocation(sourceFile, message.location);
if (message.messagePartLocations) {
message.messagePartLocations = message.messagePartLocations.map((location) => location && this.getOriginalLocation(sourceFile, location));
}
if (message.substitutionLocations) {
const placeholderNames = Object.keys(message.substitutionLocations);
for (const placeholderName of placeholderNames) {
const location = message.substitutionLocations[placeholderName];
message.substitutionLocations[placeholderName] = location && this.getOriginalLocation(sourceFile, location);
}
}
}
}
}
/**
* Find the original location using source-maps if available.
*
* @param sourceFile The generated `sourceFile` that contains the `location`.
* @param location The location within the generated `sourceFile` that needs mapping.
*
* @returns A new location that refers to the original source location mapped from the given
* `location` in the generated `sourceFile`.
*/
getOriginalLocation(sourceFile, location) {
const originalStart = sourceFile.getOriginalLocation(location.start.line, location.start.column);
if (originalStart === null) {
return location;
}
const originalEnd = sourceFile.getOriginalLocation(location.end.line, location.end.column);
const start = { line: originalStart.line, column: originalStart.column };
const end = originalEnd !== null && originalEnd.file === originalStart.file ? { line: originalEnd.line, column: originalEnd.column } : start;
const originalSourceFile = sourceFile.sources.find((sf) => sf?.sourcePath === originalStart.file);
const startPos = originalSourceFile.startOfLinePositions[start.line] + start.column;
const endPos = originalSourceFile.startOfLinePositions[end.line] + end.column;
const text = originalSourceFile.contents.substring(startPos, endPos).trim();
return { file: originalStart.file, start, end, text };
}
};
// packages/localize/tools/src/extract/translation_files/utils.js
function consolidateMessages(messages, getMessageId2) {
const messageGroups = /* @__PURE__ */ new Map();
for (const message of messages) {
const id = getMessageId2(message);
if (!messageGroups.has(id)) {
messageGroups.set(id, [message]);
} else {
messageGroups.get(id).push(message);
}
}
for (const messages2 of messageGroups.values()) {
messages2.sort(compareLocations);
}
return Array.from(messageGroups.values()).sort((a1, a2) => compareLocations(a1[0], a2[0]));
}
function hasLocation(message) {
return message.location !== void 0;
}
function compareLocations({ location: location1 }, { location: location2 }) {
if (location1 === location2) {
return 0;
}
if (location1 === void 0) {
return -1;
}
if (location2 === void 0) {
return 1;
}
if (location1.file !== location2.file) {
return location1.file < location2.file ? -1 : 1;
}
if (location1.start.line !== location2.start.line) {
return location1.start.line < location2.start.line ? -1 : 1;
}
if (location1.start.column !== location2.start.column) {
return location1.start.column < location2.start.column ? -1 : 1;
}
return 0;
}
// packages/localize/tools/src/extract/translation_files/arb_translation_serializer.js
var ArbTranslationSerializer = class {
sourceLocale;
basePath;
fs;
constructor(sourceLocale, basePath, fs) {
this.sourceLocale = sourceLocale;
this.basePath = basePath;
this.fs = fs;
}
serialize(messages) {
const messageGroups = consolidateMessages(messages, (message) => getMessageId(message));
let output = `{
"@@locale": ${JSON.stringify(this.sourceLocale)}`;
for (const duplicateMessages of messageGroups) {
const message = duplicateMessages[0];
const id = getMessageId(message);
output += this.serializeMessage(id, message);
output += this.serializeMeta(id, message.description, message.meaning, duplicateMessages.filter(hasLocation).map((m) => m.location));
}
output += "\n}";
return output;
}
serializeMessage(id, message) {
return `,
${JSON.stringify(id)}: ${JSON.stringify(message.text)}`;
}
serializeMeta(id, description, meaning, locations) {
const meta = [];
if (description) {
meta.push(`
"description": ${JSON.stringify(description)}`);
}
if (meaning) {
meta.push(`
"x-meaning": ${JSON.stringify(meaning)}`);
}
if (locations.length > 0) {
let locationStr = `
"x-locations": [`;
for (let i = 0; i < locations.length; i++) {
locationStr += (i > 0 ? ",\n" : "\n") + this.serializeLocation(locations[i]);
}
locationStr += "\n ]";
meta.push(locationStr);
}
return meta.length > 0 ? `,
${JSON.stringify("@" + id)}: {${meta.join(",")}
}` : "";
}
serializeLocation({ file, start, end }) {
return [
` {`,
` "file": ${JSON.stringify(this.fs.relative(this.basePath, file))},`,
` "start": { "line": "${start.line}", "column": "${start.column}" },`,
` "end": { "line": "${end.line}", "column": "${end.column}" }`,
` }`
].join("\n");
}
};
function getMessageId(message) {
return message.customId || message.id;
}
// packages/localize/tools/src/extract/translation_files/json_translation_serializer.js
var SimpleJsonTranslationSerializer = class {
sourceLocale;
constructor(sourceLocale) {
this.sourceLocale = sourceLocale;
}
serialize(messages) {
const fileObj = { locale: this.sourceLocale, translations: {} };
for (const [message] of consolidateMessages(messages, (message2) => message2.id)) {
fileObj.translations[message.id] = message.text;
}
return JSON.stringify(fileObj, null, 2);
}
};
// packages/localize/tools/src/extract/translation_files/legacy_message_id_migration_serializer.js
var LegacyMessageIdMigrationSerializer = class {
_diagnostics;
constructor(_diagnostics) {
this._diagnostics = _diagnostics;
}
serialize(messages) {
let hasMessages = false;
const mapping = messages.reduce((output, message) => {
if (shouldMigrate(message)) {
for (const legacyId of message.legacyIds) {
if (output.hasOwnProperty(legacyId)) {
this._diagnostics.warn(`Detected duplicate legacy ID ${legacyId}.`);
}
output[legacyId] = message.id;
hasMessages = true;
}
}
return output;
}, {});
if (!hasMessages) {
this._diagnostics.warn("Could not find any legacy message IDs in source files while generating the legacy message migration file.");
}
return JSON.stringify(mapping, null, 2);
}
};
function shouldMigrate(message) {
return !message.customId && !!message.legacyIds && message.legacyIds.length > 0;
}
// packages/localize/tools/src/extract/translation_files/format_options.js
function validateOptions(name, validOptions, options) {
const validOptionsMap = new Map(validOptions);
for (const option in options) {
if (!validOptionsMap.has(option)) {
throw new Error(`Invalid format option for ${name}: "${option}".
Allowed options are ${JSON.stringify(Array.from(validOptionsMap.keys()))}.`);
}
const validOptionValues = validOptionsMap.get(option);
const optionValue = options[option];
if (!validOptionValues.includes(optionValue)) {
throw new Error(`Invalid format option value for ${name}: "${option}".
Allowed option values are ${JSON.stringify(validOptionValues)} but received "${optionValue}".`);
}
}
}
function parseFormatOptions(optionString = "{}") {
return JSON.parse(optionString);
}
// packages/localize/tools/src/extract/translation_files/xliff1_translation_serializer.js
import { getFileSystem } from "@angular/compiler-cli/private/localize";
// packages/localize/tools/src/extract/translation_files/icu_parsing.js
function extractIcuPlaceholders(text) {
const state = new StateStack();
const pieces = new IcuPieces();
const braces = /[{}]/g;
let lastPos = 0;
let match;
while (match = braces.exec(text)) {
if (match[0] == "{") {
state.enterBlock();
} else {
state.leaveBlock();
}
if (state.getCurrent() === "placeholder") {
const name = tryParsePlaceholder(text, braces.lastIndex);
if (name) {
pieces.addText(text.substring(lastPos, braces.lastIndex - 1));
pieces.addPlaceholder(name);
braces.lastIndex += name.length + 1;
state.leaveBlock();
} else {
pieces.addText(text.substring(lastPos, braces.lastIndex));
state.nestedIcu();
}
} else {
pieces.addText(text.substring(lastPos, braces.lastIndex));
}
lastPos = braces.lastIndex;
}
pieces.addText(text.substring(lastPos));
return pieces.toArray();
}
var IcuPieces = class {
pieces = [""];
/**
* Add the given `text` to the current "static text" piece.
*
* Sequential calls to `addText()` will append to the current text piece.
*/
addText(text) {
this.pieces[this.pieces.length - 1] += text;
}
/**
* Add the given placeholder `name` to the stored pieces.
*/
addPlaceholder(name) {
this.pieces.push(name);
this.pieces.push("");
}
/**
* Return the stored pieces as an array of strings.
*
* Even values are static strings (e.g. 0, 2, 4, etc)
* Odd values are placeholder names (e.g. 1, 3, 5, etc)
*/
toArray() {
return this.pieces;
}
};
var StateStack = class {
stack = [];
/**
* Update the state upon entering a block.
*
* The new state is computed from the current state and added to the stack.
*/
enterBlock() {
const current = this.getCurrent();
switch (current) {
case "icu":
this.stack.push("case");
break;
case "case":
this.stack.push("placeholder");
break;
case "placeholder":
this.stack.push("case");
break;
default:
this.stack.push("icu");
break;
}
}
/**
* Update the state upon leaving a block.
*
* The previous state is popped off the stack.
*/
leaveBlock() {
return this.stack.pop();
}
/**
* Update the state upon arriving at a nested ICU.
*
* In this case, the current state of "placeholder" is incorrect, so this is popped off and the
* correct "icu" state is stored.
*/
nestedIcu() {
const current = this.stack.pop();
assert(current === "placeholder", "A nested ICU must replace a placeholder but got " + current);
this.stack.push("icu");
}
/**
* Get the current (most recent) state from the stack.
*/
getCurrent() {
return this.stack[this.stack.length - 1];
}
};
function tryParsePlaceholder(text, start) {
for (let i = start; i < text.length; i++) {
if (text[i] === ",") {
break;
}
if (text[i] === "}") {
return text.substring(start, i);
}
}
return null;
}
function assert(test, message) {
if (!test) {
throw new Error("Assertion failure: " + message);
}
}
// packages/localize/tools/src/extract/translation_files/xml_file.js
var XmlFile = class {
output = '<?xml version="1.0" encoding="UTF-8" ?>\n';
indent = "";
elements = [];
preservingWhitespace = false;
toString() {
return this.output;
}
startTag(name, attributes = {}, { selfClosing = false, preserveWhitespace } = {}) {
if (!this.preservingWhitespace) {
this.output += this.indent;
}
this.output += `<${name}`;
for (const [attrName, attrValue] of Object.entries(attributes)) {
if (attrValue) {
this.output += ` ${attrName}="${escapeXml(attrValue)}"`;
}
}
if (selfClosing) {
this.output += "/>";
} else {
this.output += ">";
this.elements.push(name);
this.incIndent();
}
if (preserveWhitespace !== void 0) {
this.preservingWhitespace = preserveWhitespace;
}
if (!this.preservingWhitespace) {
this.output += `
`;
}
return this;
}
endTag(name, { preserveWhitespace } = {}) {
const expectedTag = this.elements.pop();
if (expectedTag !== name) {
throw new Error(`Unexpected closing tag: "${name}", expected: "${expectedTag}"`);
}
this.decIndent();
if (!this.preservingWhitespace) {
this.output += this.indent;
}
this.output += `</${name}>`;
if (preserveWhitespace !== void 0) {
this.preservingWhitespace = preserveWhitespace;
}
if (!this.preservingWhitespace) {
this.output += `
`;
}
return this;
}
text(str) {
this.output += escapeXml(str);
return this;
}
rawText(str) {
this.output += str;
return this;
}
incIndent() {
this.indent = this.indent + " ";
}
decIndent() {
this.indent = this.indent.slice(0, -2);
}
};
var _ESCAPED_CHARS = [
[/&/g, "&amp;"],
[/"/g, "&quot;"],
[/'/g, "&apos;"],
[/</g, "&lt;"],
[/>/g, "&gt;"]
];
function escapeXml(text) {
return _ESCAPED_CHARS.reduce((text2, entry) => text2.replace(entry[0], entry[1]), text);
}
// packages/localize/tools/src/extract/translation_files/xliff1_translation_serializer.js
var LEGACY_XLIFF_MESSAGE_LENGTH = 40;
var Xliff1TranslationSerializer = class {
sourceLocale;
basePath;
useLegacyIds;
formatOptions;
fs;
constructor(sourceLocale, basePath, useLegacyIds, formatOptions = {}, fs = getFileSystem()) {
this.sourceLocale = sourceLocale;
this.basePath = basePath;
this.useLegacyIds = useLegacyIds;
this.formatOptions = formatOptions;
this.fs = fs;
validateOptions("Xliff1TranslationSerializer", [["xml:space", ["preserve"]]], formatOptions);
}
serialize(messages) {
const messageGroups = consolidateMessages(messages, (message) => this.getMessageId(message));
const xml = new XmlFile();
xml.startTag("xliff", { "version": "1.2", "xmlns": "urn:oasis:names:tc:xliff:document:1.2" });
xml.startTag("file", {
"source-language": this.sourceLocale,
"datatype": "plaintext",
"original": "ng2.template",
...this.formatOptions
});
xml.startTag("body");
for (const duplicateMessages of messageGroups) {
const message = duplicateMessages[0];
const id = this.getMessageId(message);
xml.startTag("trans-unit", { id, datatype: "html" });
xml.startTag("source", {}, { preserveWhitespace: true });
this.serializeMessage(xml, message);
xml.endTag("source", { preserveWhitespace: false });
for (const { location } of duplicateMessages.filter(hasLocation)) {
this.serializeLocation(xml, location);
}
if (message.description) {
this.serializeNote(xml, "description", message.description);
}
if (message.meaning) {
this.serializeNote(xml, "meaning", message.meaning);
}
xml.endTag("trans-unit");
}
xml.endTag("body");
xml.endTag("file");
xml.endTag("xliff");
return xml.toString();
}
serializeMessage(xml, message) {
const length = message.messageParts.length - 1;
for (let i = 0; i < length; i++) {
this.serializeTextPart(xml, message.messageParts[i]);
const name = message.placeholderNames[i];
const location = message.substitutionLocations?.[name];
const associatedMessageId = message.associatedMessageIds && message.associatedMessageIds[name];
this.serializePlaceholder(xml, name, location?.text, associatedMessageId);
}
this.serializeTextPart(xml, message.messageParts[length]);
}
serializeTextPart(xml, text) {
const pieces = extractIcuPlaceholders(text);
const length = pieces.length - 1;
for (let i = 0; i < length; i += 2) {
xml.text(pieces[i]);
this.serializePlaceholder(xml, pieces[i + 1], void 0, void 0);
}
xml.text(pieces[length]);
}
serializePlaceholder(xml, id, text, associatedId) {
const attrs = { id };
const ctype = getCtypeForPlaceholder(id);
if (ctype !== null) {
attrs["ctype"] = ctype;
}
if (text !== void 0) {
attrs["equiv-text"] = text;
}
if (associatedId !== void 0) {
attrs["xid"] = associatedId;
}
xml.startTag("x", attrs, { selfClosing: true });
}
serializeNote(xml, name, value) {
xml.startTag("note", { priority: "1", from: name }, { preserveWhitespace: true });
xml.text(value);
xml.endTag("note", { preserveWhitespace: false });
}
serializeLocation(xml, location) {
xml.startTag("context-group", { purpose: "location" });
this.renderContext(xml, "sourcefile", this.fs.relative(this.basePath, location.file));
const endLineString = location.end !== void 0 && location.end.line !== location.start.line ? `,${location.end.line + 1}` : "";
this.renderContext(xml, "linenumber", `${location.start.line + 1}${endLineString}`);
xml.endTag("context-group");
}
renderContext(xml, type, value) {
xml.startTag("context", { "context-type": type }, { preserveWhitespace: true });
xml.text(value);
xml.endTag("context", { preserveWhitespace: false });
}
/**
* Get the id for the given `message`.
*
* If there was a custom id provided, use that.
*
* If we have requested legacy message ids, then try to return the appropriate id
* from the list of legacy ids that were extracted.
*
* Otherwise return the canonical message id.
*
* An Xliff 1.2 legacy message id is a hex encoded SHA-1 string, which is 40 characters long. See
* https://csrc.nist.gov/csrc/media/publications/fips/180/4/final/documents/fips180-4-draft-aug2014.pdf
*/
getMessageId(message) {
return message.customId || this.useLegacyIds && message.legacyIds !== void 0 && message.legacyIds.find((id) => id.length === LEGACY_XLIFF_MESSAGE_LENGTH) || message.id;
}
};
function getCtypeForPlaceholder(placeholder) {
const tag = placeholder.replace(/^(START_|CLOSE_)/, "");
switch (tag) {
case "LINE_BREAK":
return "lb";
case "TAG_IMG":
return "image";
default:
const element = tag.startsWith("TAG_") ? tag.replace(/^TAG_(.+)/, (_, tagName) => tagName.toLowerCase()) : TAG_MAP[tag];
if (element === void 0) {
return null;
}
return `x-${element}`;
}
}
var TAG_MAP = {
"LINK": "a",
"BOLD_TEXT": "b",
"EMPHASISED_TEXT": "em",
"HEADING_LEVEL1": "h1",
"HEADING_LEVEL2": "h2",
"HEADING_LEVEL3": "h3",
"HEADING_LEVEL4": "h4",
"HEADING_LEVEL5": "h5",
"HEADING_LEVEL6": "h6",
"HORIZONTAL_RULE": "hr",
"ITALIC_TEXT": "i",
"LIST_ITEM": "li",
"MEDIA_LINK": "link",
"ORDERED_LIST": "ol",
"PARAGRAPH": "p",
"QUOTATION": "q",
"STRIKETHROUGH_TEXT": "s",
"SMALL_TEXT": "small",
"SUBSTRIPT": "sub",
"SUPERSCRIPT": "sup",
"TABLE_BODY": "tbody",
"TABLE_CELL": "td",
"TABLE_FOOTER": "tfoot",
"TABLE_HEADER_CELL": "th",
"TABLE_HEADER": "thead",
"TABLE_ROW": "tr",
"MONOSPACED_TEXT": "tt",
"UNDERLINED_TEXT": "u",
"UNORDERED_LIST": "ul"
};
// packages/localize/tools/src/extract/translation_files/xliff2_translation_serializer.js
import { getFileSystem as getFileSystem2 } from "@angular/compiler-cli/private/localize";
var MAX_LEGACY_XLIFF_2_MESSAGE_LENGTH = 20;
var Xliff2TranslationSerializer = class {
sourceLocale;
basePath;
useLegacyIds;
formatOptions;
fs;
currentPlaceholderId = 0;
constructor(sourceLocale, basePath, useLegacyIds, formatOptions = {}, fs = getFileSystem2()) {
this.sourceLocale = sourceLocale;
this.basePath = basePath;
this.useLegacyIds = useLegacyIds;
this.formatOptions = formatOptions;
this.fs = fs;
validateOptions("Xliff1TranslationSerializer", [["xml:space", ["preserve"]]], formatOptions);
}
serialize(messages) {
const messageGroups = consolidateMessages(messages, (message) => this.getMessageId(message));
const xml = new XmlFile();
xml.startTag("xliff", {
"version": "2.0",
"xmlns": "urn:oasis:names:tc:xliff:document:2.0",
"srcLang": this.sourceLocale
});
xml.startTag("file", { "id": "ngi18n", "original": "ng.template", ...this.formatOptions });
for (const duplicateMessages of messageGroups) {
const message = duplicateMessages[0];
const id = this.getMessageId(message);
xml.startTag("unit", { id });
const messagesWithLocations = duplicateMessages.filter(hasLocation);
if (message.meaning || message.description || messagesWithLocations.length) {
xml.startTag("notes");
for (const { location: { file, start, end } } of messagesWithLocations) {
const endLineString = end !== void 0 && end.line !== start.line ? `,${end.line + 1}` : "";
this.serializeNote(xml, "location", `${this.fs.relative(this.basePath, file)}:${start.line + 1}${endLineString}`);
}
if (message.description) {
this.serializeNote(xml, "description", message.description);
}
if (message.meaning) {
this.serializeNote(xml, "meaning", message.meaning);
}
xml.endTag("notes");
}
xml.startTag("segment");
xml.startTag("source", {}, { preserveWhitespace: true });
this.serializeMessage(xml, message);
xml.endTag("source", { preserveWhitespace: false });
xml.endTag("segment");
xml.endTag("unit");
}
xml.endTag("file");
xml.endTag("xliff");
return xml.toString();
}
serializeMessage(xml, message) {
this.currentPlaceholderId = 0;
const length = message.messageParts.length - 1;
for (let i = 0; i < length; i++) {
this.serializeTextPart(xml, message.messageParts[i]);
const name = message.placeholderNames[i];
const associatedMessageId = message.associatedMessageIds && message.associatedMessageIds[name];
this.serializePlaceholder(xml, name, message.substitutionLocations, associatedMessageId);
}
this.serializeTextPart(xml, message.messageParts[length]);
}
serializeTextPart(xml, text) {
const pieces = extractIcuPlaceholders(text);
const length = pieces.length - 1;
for (let i = 0; i < length; i += 2) {
xml.text(pieces[i]);
this.serializePlaceholder(xml, pieces[i + 1], void 0, void 0);
}
xml.text(pieces[length]);
}
serializePlaceholder(xml, placeholderName, substitutionLocations, associatedMessageId) {
const text = substitutionLocations?.[placeholderName]?.text;
if (placeholderName.startsWith("START_")) {
const closingPlaceholderName = placeholderName.replace(/^START/, "CLOSE").replace(/_\d+$/, "");
const closingText = substitutionLocations?.[closingPlaceholderName]?.text;
const attrs = {
id: `${this.currentPlaceholderId++}`,
equivStart: placeholderName,
equivEnd: closingPlaceholderName
};
const type = getTypeForPlaceholder(placeholderName);
if (type !== null) {
attrs["type"] = type;
}
if (text !== void 0) {
attrs["dispStart"] = text;
}
if (closingText !== void 0) {
attrs["dispEnd"] = closingText;
}
xml.startTag("pc", attrs);
} else if (placeholderName.startsWith("CLOSE_")) {
xml.endTag("pc");
} else {
const attrs = {
id: `${this.currentPlaceholderId++}`,
equiv: placeholderName
};
const type = getTypeForPlaceholder(placeholderName);
if (type !== null) {
attrs["type"] = type;
}
if (text !== void 0) {
attrs["disp"] = text;
}
if (associatedMessageId !== void 0) {
attrs["subFlows"] = associatedMessageId;
}
xml.startTag("ph", attrs, { selfClosing: true });
}
}
serializeNote(xml, name, value) {
xml.startTag("note", { category: name }, { preserveWhitespace: true });
xml.text(value);
xml.endTag("note", { preserveWhitespace: false });
}
/**
* Get the id for the given `message`.
*
* If there was a custom id provided, use that.
*
* If we have requested legacy message ids, then try to return the appropriate id
* from the list of legacy ids that were extracted.
*
* Otherwise return the canonical message id.
*
* An Xliff 2.0 legacy message id is a 64 bit number encoded as a decimal string, which will have
* at most 20 digits, since 2^65-1 = 36,893,488,147,419,103,231. This digest is based on:
* https://github.com/google/closure-compiler/blob/master/src/com/google/javascript/jscomp/GoogleJsMessageIdGenerator.java
*/
getMessageId(message) {
return message.customId || this.useLegacyIds && message.legacyIds !== void 0 && message.legacyIds.find((id) => id.length <= MAX_LEGACY_XLIFF_2_MESSAGE_LENGTH && !/[^0-9]/.test(id)) || message.id;
}
};
function getTypeForPlaceholder(placeholder) {
const tag = placeholder.replace(/^(START_|CLOSE_)/, "").replace(/_\d+$/, "");
switch (tag) {
case "BOLD_TEXT":
case "EMPHASISED_TEXT":
case "ITALIC_TEXT":
case "LINE_BREAK":
case "STRIKETHROUGH_TEXT":
case "UNDERLINED_TEXT":
return "fmt";
case "TAG_IMG":
return "image";
case "LINK":
return "link";
default:
return /^(START_|CLOSE_)/.test(placeholder) ? "other" : null;
}
}
// packages/localize/tools/src/extract/translation_files/xmb_translation_serializer.js
import { getFileSystem as getFileSystem3 } from "@angular/compiler-cli/private/localize";
var XMB_HANDLER = "angular";
var XmbTranslationSerializer = class {
basePath;
useLegacyIds;
fs;
constructor(basePath, useLegacyIds, fs = getFileSystem3()) {
this.basePath = basePath;
this.useLegacyIds = useLegacyIds;
this.fs = fs;
}
serialize(messages) {
const messageGroups = consolidateMessages(messages, (message) => this.getMessageId(message));
const xml = new XmlFile();
xml.rawText(`<!DOCTYPE messagebundle [
<!ELEMENT messagebundle (msg)*>
<!ATTLIST messagebundle class CDATA #IMPLIED>
<!ELEMENT msg (#PCDATA|ph|source)*>
<!ATTLIST msg id CDATA #IMPLIED>
<!ATTLIST msg seq CDATA #IMPLIED>
<!ATTLIST msg name CDATA #IMPLIED>
<!ATTLIST msg desc CDATA #IMPLIED>
<!ATTLIST msg meaning CDATA #IMPLIED>
<!ATTLIST msg obsolete (obsolete) #IMPLIED>
<!ATTLIST msg xml:space (default|preserve) "default">
<!ATTLIST msg is_hidden CDATA #IMPLIED>
<!ELEMENT source (#PCDATA)>
<!ELEMENT ph (#PCDATA|ex)*>
<!ATTLIST ph name CDATA #REQUIRED>
<!ELEMENT ex (#PCDATA)>
]>
`);
xml.startTag("messagebundle", {
"handler": XMB_HANDLER
});
for (const duplicateMessages of messageGroups) {
const message = duplicateMessages[0];
const id = this.getMessageId(message);
xml.startTag("msg", { id, desc: message.description, meaning: message.meaning }, { preserveWhitespace: true });
if (message.location) {
this.serializeLocation(xml, message.location);
}
this.serializeMessage(xml, message);
xml.endTag("msg", { preserveWhitespace: false });
}
xml.endTag("messagebundle");
return xml.toString();
}
serializeLocation(xml, location) {
xml.startTag("source");
const endLineString = location.end !== void 0 && location.end.line !== location.start.line ? `,${location.end.line + 1}` : "";
xml.text(`${this.fs.relative(this.basePath, location.file)}:${location.start.line}${endLineString}`);
xml.endTag("source");
}
serializeMessage(xml, message) {
const length = message.messageParts.length - 1;
for (let i = 0; i < length; i++) {
this.serializeTextPart(xml, message.messageParts[i]);
xml.startTag("ph", { name: message.placeholderNames[i] }, { selfClosing: true });
}
this.serializeTextPart(xml, message.messageParts[length]);
}
serializeTextPart(xml, text) {
const pieces = extractIcuPlaceholders(text);
const length = pieces.length - 1;
for (let i = 0; i < length; i += 2) {
xml.text(pieces[i]);
xml.startTag("ph", { name: pieces[i + 1] }, { selfClosing: true });
}
xml.text(pieces[length]);
}
/**
* Get the id for the given `message`.
*
* If there was a custom id provided, use that.
*
* If we have requested legacy message ids, then try to return the appropriate id
* from the list of legacy ids that were extracted.
*
* Otherwise return the canonical message id.
*
* An XMB legacy message id is a 64 bit number encoded as a decimal string, which will have
* at most 20 digits, since 2^65-1 = 36,893,488,147,419,103,231. This digest is based on:
* https://github.com/google/closure-compiler/blob/master/src/com/google/javascript/jscomp/GoogleJsMessageIdGenerator.java
*/
getMessageId(message) {
return message.customId || this.useLegacyIds && message.legacyIds !== void 0 && message.legacyIds.find((id) => id.length <= 20 && !/[^0-9]/.test(id)) || message.id;
}
};
export {
checkDuplicateMessages,
MessageExtractor,
ArbTranslationSerializer,
SimpleJsonTranslationSerializer,
LegacyMessageIdMigrationSerializer,
parseFormatOptions,
Xliff1TranslationSerializer,
Xliff2TranslationSerializer,
XmbTranslationSerializer
};
/**
* @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.dev/license
*/