@angular/localize 20.0.2 → 20.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/fesm2022/init.mjs +1 -1
- package/fesm2022/init.mjs.map +1 -1
- package/fesm2022/localize-GIKF7LQz.mjs +1 -1
- package/fesm2022/localize-GIKF7LQz.mjs.map +1 -1
- package/fesm2022/localize.mjs +1 -1
- package/fesm2022/localize.mjs.map +1 -1
- package/index.d.ts +1 -1
- package/init/index.d.ts +1 -1
- package/package.json +3 -3
- package/schematics/ng-add/ng_add_bundle.cjs +2 -2
- package/schematics/ng-add/ng_add_bundle.cjs.map +1 -1
- package/tools/bundles/{chunk-ARKHNZ5Y.js → chunk-EZ3BW4XG.js} +8 -8
- package/tools/bundles/{chunk-7UITC7I7.js → chunk-TONUHCMD.js} +18 -18
- package/tools/bundles/{chunk-7COYUM4Y.js → chunk-YGTHV3U7.js} +18 -18
- package/tools/bundles/index.js +4 -4
- package/tools/bundles/src/extract/cli.js +5 -5
- package/tools/bundles/src/migrate/cli.js +5 -5
- package/tools/bundles/src/translate/cli.js +11 -11
- /package/tools/bundles/{chunk-ARKHNZ5Y.js.map → chunk-EZ3BW4XG.js.map} +0 -0
- /package/tools/bundles/{chunk-7UITC7I7.js.map → chunk-TONUHCMD.js.map} +0 -0
- /package/tools/bundles/{chunk-7COYUM4Y.js.map → chunk-YGTHV3U7.js.map} +0 -0
package/fesm2022/init.mjs
CHANGED
package/fesm2022/init.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.mjs","sources":["../../../../../
|
|
1
|
+
{"version":3,"file":"init.mjs","sources":["../../../../../darwin_arm64-fastbuild-ST-46c76129e412/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":[],"mappings":";;;;;;;;AAeA;AACC,UAAkB,CAAC,SAAS,GAAG,SAAS;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"localize-GIKF7LQz.mjs","sources":["../../../../../k8-fastbuild-ST-46c76129e412/bin/packages/localize/src/utils/src/constants.ts","../../../../../k8-fastbuild-ST-46c76129e412/bin/packages/compiler/src/i18n/digest.ts","../../../../../k8-fastbuild-ST-46c76129e412/bin/packages/localize/src/utils/src/messages.ts","../../../../../k8-fastbuild-ST-46c76129e412/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"],"mappings":";;;;;;AAQA;;;;;;;;;;;AAWG;AACI,MAAMA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;AAElF,IAAA,OAAO,OAAO;AAChB;AAEA,MAAM,YAAY,GAAG,GAAG;AAExB;;;;;;;;;;;;AAYG;AACH,SAAS,UAAU,CAAC,WAAmB,EAAE,cAAsB,EAAA;AAC7D,IAAA,OAAO,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK;AAClC,UAAE,WAAW,CAAC,SAAS,CAAC,cAAc,CAAC,WAAW,EAAE,cAAc,CAAC,GAAG,CAAC;UACrE,WAAW;AACjB;;;;"}
|
|
1
|
+
{"version":3,"file":"localize-GIKF7LQz.mjs","sources":["../../../../../darwin_arm64-fastbuild-ST-46c76129e412/bin/packages/localize/src/utils/src/constants.ts","../../../../../darwin_arm64-fastbuild-ST-46c76129e412/bin/packages/compiler/src/i18n/digest.ts","../../../../../darwin_arm64-fastbuild-ST-46c76129e412/bin/packages/localize/src/utils/src/messages.ts","../../../../../darwin_arm64-fastbuild-ST-46c76129e412/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(messageP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CAAC,CAAC,GAAG,UAAU,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;;AAElF,IAAA,OAAO,OAAO;AAChB;AAEA,MAAM,YAAY,GAAG,GAAG;AAExB;;;;;;;;;;;;AAYG;AACH,SAAS,UAAU,CAAC,WAAmB,EAAE,cAAsB,EAAA;AAC7D,IAAA,OAAO,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK;AAClC,UAAE,WAAW,CAAC,SAAS,CAAC,cAAc,CAAC,WAAW,EAAE,cAAc,CAAC,GAAG,CAAC;UACrE,WAAW;AACjB;;;;"}
|
package/fesm2022/localize.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"localize.mjs","sources":["../../../../../k8-fastbuild-ST-46c76129e412/bin/packages/localize/src/utils/src/translations.ts","../../../../../k8-fastbuild-ST-46c76129e412/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":["translate","_translate"],"mappings":";;;;;;;;;AAuBM,MAAO,uBAAwB,SAAQ,KAAK,CAAA;AAE3B,IAAA,aAAA;IADJ,IAAI,GAAG,yBAAyB;AACjD,IAAA,WAAA,CAAqB,aAA4B,EAAA;QAC/C,KAAK,CAAC,4BAA4B,eAAe,CAAC,aAAa,CAAC,CAAA,CAAA,CAAG,CAAC;QADjD,IAAa,CAAA,aAAA,GAAb,aAAa;;AAGnC;AAEK,SAAU,yBAAyB,CAAC,CAAM,EAAA;AAC9C,IAAA,OAAO,CAAC,CAAC,IAAI,KAAK,yBAAyB;AAC7C;AAEA;;;;;;;;;;;;;;;AAeG;SACaA,WAAS,CACvB,YAA+C,EAC/C,YAAkC,EAClC,aAA6B,EAAA;IAE7B,MAAM,OAAO,GAAG,YAAY,CAAC,YAAY,EAAE,aAAa,CAAC;;IAEzD,IAAI,WAAW,GAAG,YAAY,CAAC,OAAO,CAAC,EAAE,CAAC;;AAE1C,IAAA,IAAI,OAAO,CAAC,SAAS,KAAK,SAAS,EAAE;QACnC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,SAAS,CAAC,MAAM,IAAI,WAAW,KAAK,SAAS,EAAE,CAAC,EAAE,EAAE;YAC9E,WAAW,GAAG,YAAY,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;;;AAGpD,IAAA,IAAI,WAAW,KAAK,SAAS,EAAE;AAC7B,QAAA,MAAM,IAAI,uBAAuB,CAAC,OAAO,CAAC;;IAE5C,OAAO;AACL,QAAA,WAAW,CAAC,YAAY;QACxB,WAAW,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC,WAAW,KAAI;YAC/C,IAAI,OAAO,CAAC,aAAa,CAAC,cAAc,CAAC,WAAW,CAAC,EAAE;AACrD,gBAAA,OAAO,OAAO,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,SAAS,CAAC,YAAY,EAAE;AAC3B,QAAA,SAAS,CAAC,YAAY,GAAG,EAAE;;IAE7B,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,KAAI;AACxC,QAAA,SAAS,CAAC,YAAY,CAAC,GAAG,CAAC,GAAG,gBAAgB,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC;AACnE,KAAC,CAAC;AACJ;AAEA;;;;;;;;;AASG;SACa,iBAAiB,GAAA;AAC/B,IAAA,SAAS,CAAC,SAAS,GAAG,SAAS;AAC/B,IAAA,SAAS,CAAC,YAAY,GAAG,EAAE;AAC7B;AAEA;;;;AAIG;AACa,SAAA,SAAS,CACvB,YAAkC,EAClC,aAA6B,EAAA;AAE7B,IAAA,IAAI;QACF,OAAOC,WAAU,CAAC,SAAS,CAAC,YAAY,EAAE,YAAY,EAAE,aAAa,CAAC;;IACtE,OAAO,CAAC,EAAE;AACV,QAAA,OAAO,CAAC,IAAI,CAAE,CAAW,CAAC,OAAO,CAAC;AAClC,QAAA,OAAO,CAAC,YAAY,EAAE,aAAa,CAAC;;AAExC;;;;"}
|
|
1
|
+
{"version":3,"file":"localize.mjs","sources":["../../../../../darwin_arm64-fastbuild-ST-46c76129e412/bin/packages/localize/src/utils/src/translations.ts","../../../../../darwin_arm64-fastbuild-ST-46c76129e412/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":["translate","_translate"],"mappings":";;;;;;;;;AAuBM,MAAO,uBAAwB,SAAQ,KAAK,CAAA;AAE3B,IAAA,aAAA;IADJ,IAAI,GAAG,yBAAyB;AACjD,IAAA,WAAA,CAAqB,aAA4B,EAAA;QAC/C,KAAK,CAAC,4BAA4B,eAAe,CAAC,aAAa,CAAC,CAAA,CAAA,CAAG,CAAC;QADjD,IAAa,CAAA,aAAA,GAAb,aAAa;;AAGnC;AAEK,SAAU,yBAAyB,CAAC,CAAM,EAAA;AAC9C,IAAA,OAAO,CAAC,CAAC,IAAI,KAAK,yBAAyB;AAC7C;AAEA;;;;;;;;;;;;;;;AAeG;SACaA,WAAS,CACvB,YAA+C,EAC/C,YAAkC,EAClC,aAA6B,EAAA;IAE7B,MAAM,OAAO,GAAG,YAAY,CAAC,YAAY,EAAE,aAAa,CAAC;;IAEzD,IAAI,WAAW,GAAG,YAAY,CAAC,OAAO,CAAC,EAAE,CAAC;;AAE1C,IAAA,IAAI,OAAO,CAAC,SAAS,KAAK,SAAS,EAAE;QACnC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,SAAS,CAAC,MAAM,IAAI,WAAW,KAAK,SAAS,EAAE,CAAC,EAAE,EAAE;YAC9E,WAAW,GAAG,YAAY,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;;;AAGpD,IAAA,IAAI,WAAW,KAA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CAAC,IAAI,CAAI,CAAA,EAAA,aAAa,GAAG;AACvE;;AC7HA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsCG;AACG,SAAU,gBAAgB,CAAC,YAA8C,EAAA;;AAE7E,IAAA,IAAI,CAAC,SAAS,CAAC,SAAS,EAAE;AACxB,QAAA,SAAS,CAAC,SAAS,GAAG,SAAS;;AAEjC,IAAA,IAAI,CAAC,SAAS,CAAC,YAAY,EAAE;AAC3B,QAAA,SAAS,CAAC,YAAY,GAAG,EAAE;;IAE7B,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,KAAI;AACxC,QAAA,SAAS,CAAC,YAAY,CAAC,GAAG,CAAC,GAAG,gBAAgB,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC;AACnE,KAAC,CAAC;AACJ;AAEA;;;;;;;;;AASG;SACa,iBAAiB,GAAA;AAC/B,IAAA,SAAS,CAAC,SAAS,GAAG,SAAS;AAC/B,IAAA,SAAS,CAAC,YAAY,GAAG,EAAE;AAC7B;AAEA;;;;AAIG;AACa,SAAA,SAAS,CACvB,YAAkC,EAClC,aAA6B,EAAA;AAE7B,IAAA,IAAI;QACF,OAAOC,WAAU,CAAC,SAAS,CAAC,YAAY,EAAE,YAAY,EAAE,aAAa,CAAC;;IACtE,OAAO,CAAC,EAAE;AACV,QAAA,OAAO,CAAC,IAAI,CAAE,CAAW,CAAC,OAAO,CAAC;AAClC,QAAA,OAAO,CAAC,YAAY,EAAE,aAAa,CAAC;;AAExC;;;;"}
|
package/index.d.ts
CHANGED
package/init/index.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@angular/localize",
|
|
3
|
-
"version": "20.0.
|
|
3
|
+
"version": "20.0.3",
|
|
4
4
|
"description": "Angular - library for localizing messages",
|
|
5
5
|
"bin": {
|
|
6
6
|
"localize-translate": "./tools/bundles/src/translate/cli.js",
|
|
@@ -67,8 +67,8 @@
|
|
|
67
67
|
"yargs": "^18.0.0"
|
|
68
68
|
},
|
|
69
69
|
"peerDependencies": {
|
|
70
|
-
"@angular/compiler": "20.0.
|
|
71
|
-
"@angular/compiler-cli": "20.0.
|
|
70
|
+
"@angular/compiler": "20.0.3",
|
|
71
|
+
"@angular/compiler-cli": "20.0.3"
|
|
72
72
|
},
|
|
73
73
|
"module": "./fesm2022/localize.mjs",
|
|
74
74
|
"typings": "./index.d.ts",
|
|
@@ -16,7 +16,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
};
|
|
17
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
18
|
|
|
19
|
-
// bazel-out/
|
|
19
|
+
// bazel-out/darwin_arm64-fastbuild/bin/packages/localize/schematics/ng-add/index.js
|
|
20
20
|
var ng_add_exports = {};
|
|
21
21
|
__export(ng_add_exports, {
|
|
22
22
|
default: () => ng_add_default
|
|
@@ -126,7 +126,7 @@ function moveToDependencies(host) {
|
|
|
126
126
|
return;
|
|
127
127
|
}
|
|
128
128
|
(0, import_dependencies.removePackageJsonDependency)(host, "@angular/localize");
|
|
129
|
-
return (0, import_utility.addDependency)("@angular/localize", `~20.0.
|
|
129
|
+
return (0, import_utility.addDependency)("@angular/localize", `~20.0.3`);
|
|
130
130
|
}
|
|
131
131
|
function ng_add_default(options) {
|
|
132
132
|
const projectName = options.project;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["index.ts"],
|
|
4
|
-
"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 * @fileoverview Schematics for `ng add @angular/localize` schematic.\n */\n\nimport {chain, noop, Rule, SchematicsException, Tree} from '@angular-devkit/schematics';\nimport {\n AngularBuilder,\n addDependency,\n readWorkspace,\n updateWorkspace,\n} from '@schematics/angular/utility';\nimport {removePackageJsonDependency} from '@schematics/angular/utility/dependencies';\nimport {JSONFile, JSONPath} from '@schematics/angular/utility/json-file';\n\nimport {Schema} from './schema';\n\nconst localizeType = `@angular/localize`;\nconst localizePolyfill = '@angular/localize/init';\nconst localizeTripleSlashType = `/// <reference types=\"@angular/localize\" />`;\n\nfunction addPolyfillToConfig(projectName: string): Rule {\n return updateWorkspace((workspace) => {\n const project = workspace.projects.get(projectName);\n if (!project) {\n throw new SchematicsException(`Invalid project name '${projectName}'.`);\n }\n\n const isLocalizePolyfill = (path: string) => path.startsWith('@angular/localize');\n\n for (const target of project.targets.values()) {\n switch (target.builder) {\n case AngularBuilder.Karma:\n case AngularBuilder.BuildKarma:\n case AngularBuilder.Server:\n case AngularBuilder.Browser:\n case AngularBuilder.BrowserEsbuild:\n case AngularBuilder.Application:\n case AngularBuilder.BuildApplication:\n target.options ??= {};\n const value = target.options['polyfills'];\n if (typeof value === 'string') {\n if (!isLocalizePolyfill(value)) {\n target.options['polyfills'] = [value, localizePolyfill];\n }\n } else if (Array.isArray(value)) {\n if (!(value as string[]).some(isLocalizePolyfill)) {\n value.push(localizePolyfill);\n }\n } else {\n target.options['polyfills'] = [localizePolyfill];\n }\n\n break;\n }\n }\n });\n}\n\nfunction addTypeScriptConfigTypes(projectName: string): Rule {\n return async (host: Tree) => {\n const workspace = await readWorkspace(host);\n const project = workspace.projects.get(projectName);\n if (!project) {\n throw new SchematicsException(`Invalid project name '${projectName}'.`);\n }\n\n // We add the root workspace tsconfig for better IDE support.\n const tsConfigFiles = new Set<string>();\n for (const target of project.targets.values()) {\n switch (target.builder) {\n case AngularBuilder.Karma:\n case AngularBuilder.Server:\n case AngularBuilder.BrowserEsbuild:\n case AngularBuilder.Browser:\n case AngularBuilder.Application:\n case AngularBuilder.BuildApplication:\n const value = target.options?.['tsConfig'];\n if (typeof value === 'string') {\n tsConfigFiles.add(value);\n }\n\n break;\n }\n\n if (\n target.builder === AngularBuilder.Browser ||\n target.builder === AngularBuilder.BrowserEsbuild\n ) {\n const value = target.options?.['main'];\n if (typeof value === 'string') {\n addTripleSlashType(host, value);\n }\n } else if (target.builder === AngularBuilder.Application) {\n const value = target.options?.['browser'];\n if (typeof value === 'string') {\n addTripleSlashType(host, value);\n }\n }\n }\n\n const typesJsonPath: JSONPath = ['compilerOptions', 'types'];\n for (const path of tsConfigFiles) {\n if (!host.exists(path)) {\n continue;\n }\n\n const json = new JSONFile(host, path);\n const types = json.get(typesJsonPath) ?? [];\n if (!Array.isArray(types)) {\n throw new SchematicsException(\n `TypeScript configuration file '${path}' has an invalid 'types' property. It must be an array.`,\n );\n }\n\n const hasLocalizeType = types.some(\n (t) => t === localizeType || t === '@angular/localize/init',\n );\n if (hasLocalizeType) {\n // Skip has already localize type.\n continue;\n }\n\n json.modify(typesJsonPath, [...types, localizeType]);\n }\n };\n}\n\nfunction addTripleSlashType(host: Tree, path: string): void {\n const content = host.readText(path);\n if (!content.includes(localizeTripleSlashType)) {\n host.overwrite(path, localizeTripleSlashType + '\\n\\n' + content);\n }\n}\n\nfunction moveToDependencies(host: Tree): Rule | void {\n if (!host.exists('package.json')) {\n return;\n }\n\n // Remove the previous dependency and add in a new one under the desired type.\n removePackageJsonDependency(host, '@angular/localize');\n\n return addDependency('@angular/localize', `~20.0.
|
|
4
|
+
"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 * @fileoverview Schematics for `ng add @angular/localize` schematic.\n */\n\nimport {chain, noop, Rule, SchematicsException, Tree} from '@angular-devkit/schematics';\nimport {\n AngularBuilder,\n addDependency,\n readWorkspace,\n updateWorkspace,\n} from '@schematics/angular/utility';\nimport {removePackageJsonDependency} from '@schematics/angular/utility/dependencies';\nimport {JSONFile, JSONPath} from '@schematics/angular/utility/json-file';\n\nimport {Schema} from './schema';\n\nconst localizeType = `@angular/localize`;\nconst localizePolyfill = '@angular/localize/init';\nconst localizeTripleSlashType = `/// <reference types=\"@angular/localize\" />`;\n\nfunction addPolyfillToConfig(projectName: string): Rule {\n return updateWorkspace((workspace) => {\n const project = workspace.projects.get(projectName);\n if (!project) {\n throw new SchematicsException(`Invalid project name '${projectName}'.`);\n }\n\n const isLocalizePolyfill = (path: string) => path.startsWith('@angular/localize');\n\n for (const target of project.targets.values()) {\n switch (target.builder) {\n case AngularBuilder.Karma:\n case AngularBuilder.BuildKarma:\n case AngularBuilder.Server:\n case AngularBuilder.Browser:\n case AngularBuilder.BrowserEsbuild:\n case AngularBuilder.Application:\n case AngularBuilder.BuildApplication:\n target.options ??= {};\n const value = target.options['polyfills'];\n if (typeof value === 'string') {\n if (!isLocalizePolyfill(value)) {\n target.options['polyfills'] = [value, localizePolyfill];\n }\n } else if (Array.isArray(value)) {\n if (!(value as string[]).some(isLocalizePolyfill)) {\n value.push(localizePolyfill);\n }\n } else {\n target.options['polyfills'] = [localizePolyfill];\n }\n\n break;\n }\n }\n });\n}\n\nfunction addTypeScriptConfigTypes(projectName: string): Rule {\n return async (host: Tree) => {\n const workspace = await readWorkspace(host);\n const project = workspace.projects.get(projectName);\n if (!project) {\n throw new SchematicsException(`Invalid project name '${projectName}'.`);\n }\n\n // We add the root workspace tsconfig for better IDE support.\n const tsConfigFiles = new Set<string>();\n for (const target of project.targets.values()) {\n switch (target.builder) {\n case AngularBuilder.Karma:\n case AngularBuilder.Server:\n case AngularBuilder.BrowserEsbuild:\n case AngularBuilder.Browser:\n case AngularBuilder.Application:\n case AngularBuilder.BuildApplication:\n const value = target.options?.['tsConfig'];\n if (typeof value === 'string') {\n tsConfigFiles.add(value);\n }\n\n break;\n }\n\n if (\n target.builder === AngularBuilder.Browser ||\n target.builder === AngularBuilder.BrowserEsbuild\n ) {\n const value = target.options?.['main'];\n if (typeof value === 'string') {\n addTripleSlashType(host, value);\n }\n } else if (target.builder === AngularBuilder.Application) {\n const value = target.options?.['browser'];\n if (typeof value === 'string') {\n addTripleSlashType(host, value);\n }\n }\n }\n\n const typesJsonPath: JSONPath = ['compilerOptions', 'types'];\n for (const path of tsConfigFiles) {\n if (!host.exists(path)) {\n continue;\n }\n\n const json = new JSONFile(host, path);\n const types = json.get(typesJsonPath) ?? [];\n if (!Array.isArray(types)) {\n throw new SchematicsException(\n `TypeScript configuration file '${path}' has an invalid 'types' property. It must be an array.`,\n );\n }\n\n const hasLocalizeType = types.some(\n (t) => t === localizeType || t === '@angular/localize/init',\n );\n if (hasLocalizeType) {\n // Skip has already localize type.\n continue;\n }\n\n json.modify(typesJsonPath, [...types, localizeType]);\n }\n };\n}\n\nfunction addTripleSlashType(host: Tree, path: string): void {\n const content = host.readText(path);\n if (!content.includes(localizeTripleSlashType)) {\n host.overwrite(path, localizeTripleSlashType + '\\n\\n' + content);\n }\n}\n\nfunction moveToDependencies(host: Tree): Rule | void {\n if (!host.exists('package.json')) {\n return;\n }\n\n // Remove the previous dependency and add in a new one under the desired type.\n removePackageJsonDependency(host, '@angular/localize');\n\n return addDependency('@angular/localize', `~20.0.3`);\n}\n\nexport default function (options: Schema): Rule {\n const projectName = options.project;\n\n if (!projectName) {\n throw new SchematicsException('Option \"project\" is required.');\n }\n\n return chain([\n addTypeScriptConfigTypes(projectName),\n addPolyfillToConfig(projectName),\n // If `$localize` will be used at runtime then must install `@angular/localize`\n // into `dependencies`, rather than the default of `devDependencies`.\n options.useAtRuntime ? moveToDependencies : noop(),\n ]);\n}\n"],
|
|
5
5
|
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;;;;;AAUA,wBAA2D;AAC3D,qBAKO;AACP,0BAA0C;AAC1C,uBAAiC;AAIjC,IAAM,eAAe;AACrB,IAAM,mBAAmB;AACzB,IAAM,0BAA0B;AAEhC,SAAS,oBAAoB,aAAmB;AAC9C,aAAO,gCAAgB,CAAC,cAAa;AACnC,UAAM,UAAU,UAAU,SAAS,IAAI,WAAW;AAClD,QAAI,CAAC,SAAS;AACZ,YAAM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;IACX,yBAAyB,WAAW;IACpC,oBAAoB,WAAW;IAG/B,QAAQ,eAAe,yBAAqB,wBAAI;GACjD;AACH;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
const require = __cjsCompatRequire(import.meta.url);
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
// bazel-out/
|
|
6
|
+
// bazel-out/darwin_arm64-fastbuild/bin/packages/localize/tools/src/diagnostics.js
|
|
7
7
|
var Diagnostics = class {
|
|
8
8
|
messages = [];
|
|
9
9
|
get hasErrors() {
|
|
@@ -36,16 +36,16 @@ var Diagnostics = class {
|
|
|
36
36
|
}
|
|
37
37
|
};
|
|
38
38
|
|
|
39
|
-
// bazel-out/
|
|
39
|
+
// bazel-out/darwin_arm64-fastbuild/bin/packages/localize/tools/src/source_file_utils.js
|
|
40
40
|
import { getFileSystem } from "@angular/compiler-cli/private/localize";
|
|
41
41
|
|
|
42
|
-
// bazel-out/
|
|
42
|
+
// bazel-out/darwin_arm64-fastbuild/bin/packages/localize/src/utils/src/constants.js
|
|
43
43
|
var BLOCK_MARKER = ":";
|
|
44
44
|
var MEANING_SEPARATOR = "|";
|
|
45
45
|
var ID_SEPARATOR = "@@";
|
|
46
46
|
var LEGACY_ID_INDICATOR = "\u241F";
|
|
47
47
|
|
|
48
|
-
// bazel-out/
|
|
48
|
+
// bazel-out/darwin_arm64-fastbuild/bin/packages/compiler/src/i18n/digest.js
|
|
49
49
|
var textEncoder;
|
|
50
50
|
var _SerializerVisitor = class {
|
|
51
51
|
visitText(text, context) {
|
|
@@ -180,7 +180,7 @@ var Endian;
|
|
|
180
180
|
Endian2[Endian2["Big"] = 1] = "Big";
|
|
181
181
|
})(Endian || (Endian = {}));
|
|
182
182
|
|
|
183
|
-
// bazel-out/
|
|
183
|
+
// bazel-out/darwin_arm64-fastbuild/bin/packages/localize/src/utils/src/messages.js
|
|
184
184
|
function parseMessage(messageParts, expressions, location, messagePartLocations, expressionLocations = []) {
|
|
185
185
|
const substitutions = {};
|
|
186
186
|
const substitutionLocations = {};
|
|
@@ -272,7 +272,7 @@ function findEndOfBlock(cooked, raw) {
|
|
|
272
272
|
throw new Error(`Unterminated $localize metadata block in "${raw}".`);
|
|
273
273
|
}
|
|
274
274
|
|
|
275
|
-
// bazel-out/
|
|
275
|
+
// bazel-out/darwin_arm64-fastbuild/bin/packages/localize/src/utils/src/translations.js
|
|
276
276
|
var MissingTranslationError = class extends Error {
|
|
277
277
|
parsedMessage;
|
|
278
278
|
type = "MissingTranslationError";
|
|
@@ -343,7 +343,7 @@ function describeMessage(message) {
|
|
|
343
343
|
return `"${message.id}"${legacy} ("${message.text}"${meaningString})`;
|
|
344
344
|
}
|
|
345
345
|
|
|
346
|
-
// bazel-out/
|
|
346
|
+
// bazel-out/darwin_arm64-fastbuild/bin/packages/localize/tools/src/source_file_utils.js
|
|
347
347
|
import { types as t } from "@babel/core";
|
|
348
348
|
function isLocalize(expression, localizeName) {
|
|
349
349
|
return isNamedIdentifier(expression, localizeName) && isGlobalIdentifier(expression);
|
|
@@ -621,4 +621,4 @@ export {
|
|
|
621
621
|
* Use of this source code is governed by an MIT-style license that can be
|
|
622
622
|
* found in the LICENSE file at https://angular.dev/license
|
|
623
623
|
*/
|
|
624
|
-
//# sourceMappingURL=chunk-
|
|
624
|
+
//# sourceMappingURL=chunk-EZ3BW4XG.js.map
|
|
@@ -15,9 +15,9 @@ import {
|
|
|
15
15
|
unwrapMessagePartsFromLocalizeCall,
|
|
16
16
|
unwrapMessagePartsFromTemplateLiteral,
|
|
17
17
|
unwrapSubstitutionsFromLocalizeCall
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-EZ3BW4XG.js";
|
|
19
19
|
|
|
20
|
-
// bazel-out/
|
|
20
|
+
// bazel-out/darwin_arm64-fastbuild/bin/packages/localize/tools/src/extract/duplicates.js
|
|
21
21
|
function checkDuplicateMessages(fs, messages, duplicateMessageHandling, basePath) {
|
|
22
22
|
const diagnostics = new Diagnostics();
|
|
23
23
|
if (duplicateMessageHandling === "ignore")
|
|
@@ -51,11 +51,11 @@ function serializeMessage(fs, basePath, message) {
|
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
// bazel-out/
|
|
54
|
+
// bazel-out/darwin_arm64-fastbuild/bin/packages/localize/tools/src/extract/extraction.js
|
|
55
55
|
import { SourceFileLoader } from "@angular/compiler-cli/private/localize";
|
|
56
56
|
import { transformSync } from "@babel/core";
|
|
57
57
|
|
|
58
|
-
// bazel-out/
|
|
58
|
+
// bazel-out/darwin_arm64-fastbuild/bin/packages/localize/tools/src/extract/source_files/es2015_extract_plugin.js
|
|
59
59
|
function makeEs2015ExtractPlugin(fs, messages, localizeName = "$localize") {
|
|
60
60
|
return {
|
|
61
61
|
visitor: {
|
|
@@ -74,7 +74,7 @@ function makeEs2015ExtractPlugin(fs, messages, localizeName = "$localize") {
|
|
|
74
74
|
};
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
-
// bazel-out/
|
|
77
|
+
// bazel-out/darwin_arm64-fastbuild/bin/packages/localize/tools/src/extract/source_files/es5_extract_plugin.js
|
|
78
78
|
function makeEs5ExtractPlugin(fs, messages, localizeName = "$localize") {
|
|
79
79
|
return {
|
|
80
80
|
visitor: {
|
|
@@ -101,7 +101,7 @@ function makeEs5ExtractPlugin(fs, messages, localizeName = "$localize") {
|
|
|
101
101
|
};
|
|
102
102
|
}
|
|
103
103
|
|
|
104
|
-
// bazel-out/
|
|
104
|
+
// bazel-out/darwin_arm64-fastbuild/bin/packages/localize/tools/src/extract/extraction.js
|
|
105
105
|
var MessageExtractor = class {
|
|
106
106
|
fs;
|
|
107
107
|
logger;
|
|
@@ -174,7 +174,7 @@ var MessageExtractor = class {
|
|
|
174
174
|
}
|
|
175
175
|
};
|
|
176
176
|
|
|
177
|
-
// bazel-out/
|
|
177
|
+
// bazel-out/darwin_arm64-fastbuild/bin/packages/localize/tools/src/extract/translation_files/utils.js
|
|
178
178
|
function consolidateMessages(messages, getMessageId2) {
|
|
179
179
|
const messageGroups = /* @__PURE__ */ new Map();
|
|
180
180
|
for (const message of messages) {
|
|
@@ -215,7 +215,7 @@ function compareLocations({ location: location1 }, { location: location2 }) {
|
|
|
215
215
|
return 0;
|
|
216
216
|
}
|
|
217
217
|
|
|
218
|
-
// bazel-out/
|
|
218
|
+
// bazel-out/darwin_arm64-fastbuild/bin/packages/localize/tools/src/extract/translation_files/arb_translation_serializer.js
|
|
219
219
|
var ArbTranslationSerializer = class {
|
|
220
220
|
sourceLocale;
|
|
221
221
|
basePath;
|
|
@@ -279,7 +279,7 @@ function getMessageId(message) {
|
|
|
279
279
|
return message.customId || message.id;
|
|
280
280
|
}
|
|
281
281
|
|
|
282
|
-
// bazel-out/
|
|
282
|
+
// bazel-out/darwin_arm64-fastbuild/bin/packages/localize/tools/src/extract/translation_files/json_translation_serializer.js
|
|
283
283
|
var SimpleJsonTranslationSerializer = class {
|
|
284
284
|
sourceLocale;
|
|
285
285
|
constructor(sourceLocale) {
|
|
@@ -294,7 +294,7 @@ var SimpleJsonTranslationSerializer = class {
|
|
|
294
294
|
}
|
|
295
295
|
};
|
|
296
296
|
|
|
297
|
-
// bazel-out/
|
|
297
|
+
// bazel-out/darwin_arm64-fastbuild/bin/packages/localize/tools/src/extract/translation_files/legacy_message_id_migration_serializer.js
|
|
298
298
|
var LegacyMessageIdMigrationSerializer = class {
|
|
299
299
|
_diagnostics;
|
|
300
300
|
constructor(_diagnostics) {
|
|
@@ -324,7 +324,7 @@ function shouldMigrate(message) {
|
|
|
324
324
|
return !message.customId && !!message.legacyIds && message.legacyIds.length > 0;
|
|
325
325
|
}
|
|
326
326
|
|
|
327
|
-
// bazel-out/
|
|
327
|
+
// bazel-out/darwin_arm64-fastbuild/bin/packages/localize/tools/src/extract/translation_files/format_options.js
|
|
328
328
|
function validateOptions(name, validOptions, options) {
|
|
329
329
|
const validOptionsMap = new Map(validOptions);
|
|
330
330
|
for (const option in options) {
|
|
@@ -344,10 +344,10 @@ function parseFormatOptions(optionString = "{}") {
|
|
|
344
344
|
return JSON.parse(optionString);
|
|
345
345
|
}
|
|
346
346
|
|
|
347
|
-
// bazel-out/
|
|
347
|
+
// bazel-out/darwin_arm64-fastbuild/bin/packages/localize/tools/src/extract/translation_files/xliff1_translation_serializer.js
|
|
348
348
|
import { getFileSystem } from "@angular/compiler-cli/private/localize";
|
|
349
349
|
|
|
350
|
-
// bazel-out/
|
|
350
|
+
// bazel-out/darwin_arm64-fastbuild/bin/packages/localize/tools/src/extract/translation_files/icu_parsing.js
|
|
351
351
|
function extractIcuPlaceholders(text) {
|
|
352
352
|
const state = new StateStack();
|
|
353
353
|
const pieces = new IcuPieces();
|
|
@@ -440,7 +440,7 @@ function assert(test, message) {
|
|
|
440
440
|
}
|
|
441
441
|
}
|
|
442
442
|
|
|
443
|
-
// bazel-out/
|
|
443
|
+
// bazel-out/darwin_arm64-fastbuild/bin/packages/localize/tools/src/extract/translation_files/xml_file.js
|
|
444
444
|
var XmlFile = class {
|
|
445
445
|
output = '<?xml version="1.0" encoding="UTF-8" ?>\n';
|
|
446
446
|
indent = "";
|
|
@@ -520,7 +520,7 @@ function escapeXml(text) {
|
|
|
520
520
|
return _ESCAPED_CHARS.reduce((text2, entry) => text2.replace(entry[0], entry[1]), text);
|
|
521
521
|
}
|
|
522
522
|
|
|
523
|
-
// bazel-out/
|
|
523
|
+
// bazel-out/darwin_arm64-fastbuild/bin/packages/localize/tools/src/extract/translation_files/xliff1_translation_serializer.js
|
|
524
524
|
var LEGACY_XLIFF_MESSAGE_LENGTH = 40;
|
|
525
525
|
var Xliff1TranslationSerializer = class {
|
|
526
526
|
sourceLocale;
|
|
@@ -672,7 +672,7 @@ var TAG_MAP = {
|
|
|
672
672
|
"UNORDERED_LIST": "ul"
|
|
673
673
|
};
|
|
674
674
|
|
|
675
|
-
// bazel-out/
|
|
675
|
+
// bazel-out/darwin_arm64-fastbuild/bin/packages/localize/tools/src/extract/translation_files/xliff2_translation_serializer.js
|
|
676
676
|
import { getFileSystem as getFileSystem2 } from "@angular/compiler-cli/private/localize";
|
|
677
677
|
var MAX_LEGACY_XLIFF_2_MESSAGE_LENGTH = 20;
|
|
678
678
|
var Xliff2TranslationSerializer = class {
|
|
@@ -818,7 +818,7 @@ function getTypeForPlaceholder(placeholder) {
|
|
|
818
818
|
}
|
|
819
819
|
}
|
|
820
820
|
|
|
821
|
-
// bazel-out/
|
|
821
|
+
// bazel-out/darwin_arm64-fastbuild/bin/packages/localize/tools/src/extract/translation_files/xmb_translation_serializer.js
|
|
822
822
|
import { getFileSystem as getFileSystem3 } from "@angular/compiler-cli/private/localize";
|
|
823
823
|
var XMB_HANDLER = "angular";
|
|
824
824
|
var XmbTranslationSerializer = class {
|
|
@@ -917,4 +917,4 @@ export {
|
|
|
917
917
|
* Use of this source code is governed by an MIT-style license that can be
|
|
918
918
|
* found in the LICENSE file at https://angular.dev/license
|
|
919
919
|
*/
|
|
920
|
-
//# sourceMappingURL=chunk-
|
|
920
|
+
//# sourceMappingURL=chunk-TONUHCMD.js.map
|
|
@@ -14,9 +14,9 @@ import {
|
|
|
14
14
|
unwrapMessagePartsFromLocalizeCall,
|
|
15
15
|
unwrapMessagePartsFromTemplateLiteral,
|
|
16
16
|
unwrapSubstitutionsFromLocalizeCall
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-EZ3BW4XG.js";
|
|
18
18
|
|
|
19
|
-
// bazel-out/
|
|
19
|
+
// bazel-out/darwin_arm64-fastbuild/bin/packages/localize/tools/src/translate/source_files/es2015_translate_plugin.js
|
|
20
20
|
import { getFileSystem } from "@angular/compiler-cli/private/localize";
|
|
21
21
|
function makeEs2015TranslatePlugin(diagnostics, translations, { missingTranslation = "error", localizeName = "$localize" } = {}, fs = getFileSystem()) {
|
|
22
22
|
return {
|
|
@@ -41,7 +41,7 @@ function makeEs2015TranslatePlugin(diagnostics, translations, { missingTranslati
|
|
|
41
41
|
};
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
// bazel-out/
|
|
44
|
+
// bazel-out/darwin_arm64-fastbuild/bin/packages/localize/tools/src/translate/source_files/es5_translate_plugin.js
|
|
45
45
|
import { getFileSystem as getFileSystem2 } from "@angular/compiler-cli/private/localize";
|
|
46
46
|
function makeEs5TranslatePlugin(diagnostics, translations, { missingTranslation = "error", localizeName = "$localize" } = {}, fs = getFileSystem2()) {
|
|
47
47
|
return {
|
|
@@ -67,7 +67,7 @@ function makeEs5TranslatePlugin(diagnostics, translations, { missingTranslation
|
|
|
67
67
|
};
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
-
// bazel-out/
|
|
70
|
+
// bazel-out/darwin_arm64-fastbuild/bin/packages/localize/tools/src/translate/source_files/locale_plugin.js
|
|
71
71
|
import { types as t } from "@babel/core";
|
|
72
72
|
function makeLocalePlugin(locale, { localizeName = "$localize" } = {}) {
|
|
73
73
|
return {
|
|
@@ -107,7 +107,7 @@ function isLocalizeGuard(expression, localizeName) {
|
|
|
107
107
|
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" });
|
|
108
108
|
}
|
|
109
109
|
|
|
110
|
-
// bazel-out/
|
|
110
|
+
// bazel-out/darwin_arm64-fastbuild/bin/packages/localize/tools/src/translate/translation_files/translation_parsers/arb_translation_parser.js
|
|
111
111
|
var ArbTranslationParser = class {
|
|
112
112
|
analyze(_filePath, contents) {
|
|
113
113
|
const diagnostics = new Diagnostics();
|
|
@@ -145,7 +145,7 @@ var ArbTranslationParser = class {
|
|
|
145
145
|
}
|
|
146
146
|
};
|
|
147
147
|
|
|
148
|
-
// bazel-out/
|
|
148
|
+
// bazel-out/darwin_arm64-fastbuild/bin/packages/localize/tools/src/translate/translation_files/translation_parsers/simple_json_translation_parser.js
|
|
149
149
|
import { extname } from "path";
|
|
150
150
|
var SimpleJsonTranslationParser = class {
|
|
151
151
|
analyze(filePath, contents) {
|
|
@@ -189,10 +189,10 @@ var SimpleJsonTranslationParser = class {
|
|
|
189
189
|
}
|
|
190
190
|
};
|
|
191
191
|
|
|
192
|
-
// bazel-out/
|
|
192
|
+
// bazel-out/darwin_arm64-fastbuild/bin/packages/localize/tools/src/translate/translation_files/translation_parsers/xliff1_translation_parser.js
|
|
193
193
|
import { ParseErrorLevel as ParseErrorLevel3, visitAll as visitAll2 } from "@angular/compiler";
|
|
194
194
|
|
|
195
|
-
// bazel-out/
|
|
195
|
+
// bazel-out/darwin_arm64-fastbuild/bin/packages/localize/tools/src/translate/translation_files/base_visitor.js
|
|
196
196
|
var BaseVisitor = class {
|
|
197
197
|
visitElement(_element, _context) {
|
|
198
198
|
}
|
|
@@ -218,10 +218,10 @@ var BaseVisitor = class {
|
|
|
218
218
|
}
|
|
219
219
|
};
|
|
220
220
|
|
|
221
|
-
// bazel-out/
|
|
221
|
+
// bazel-out/darwin_arm64-fastbuild/bin/packages/localize/tools/src/translate/translation_files/message_serialization/message_serializer.js
|
|
222
222
|
import { Element as Element2, visitAll } from "@angular/compiler";
|
|
223
223
|
|
|
224
|
-
// bazel-out/
|
|
224
|
+
// bazel-out/darwin_arm64-fastbuild/bin/packages/localize/tools/src/translate/translation_files/translation_parsers/translation_parse_error.js
|
|
225
225
|
import { ParseErrorLevel } from "@angular/compiler";
|
|
226
226
|
var TranslationParseError = class extends Error {
|
|
227
227
|
span;
|
|
@@ -246,7 +246,7 @@ At ${span.start}${span.details ? `, ${span.details}` : ""}:
|
|
|
246
246
|
return msg;
|
|
247
247
|
}
|
|
248
248
|
|
|
249
|
-
// bazel-out/
|
|
249
|
+
// bazel-out/darwin_arm64-fastbuild/bin/packages/localize/tools/src/translate/translation_files/translation_parsers/translation_utils.js
|
|
250
250
|
import { Element, ParseError, ParseErrorLevel as ParseErrorLevel2, XmlParser } from "@angular/compiler";
|
|
251
251
|
function getAttrOrThrow(element, attrName) {
|
|
252
252
|
const attrValue = getAttribute(element, attrName);
|
|
@@ -322,7 +322,7 @@ function addErrorsToBundle(bundle, errors) {
|
|
|
322
322
|
}
|
|
323
323
|
}
|
|
324
324
|
|
|
325
|
-
// bazel-out/
|
|
325
|
+
// bazel-out/darwin_arm64-fastbuild/bin/packages/localize/tools/src/translate/translation_files/message_serialization/message_serializer.js
|
|
326
326
|
var MessageSerializer = class extends BaseVisitor {
|
|
327
327
|
renderer;
|
|
328
328
|
config;
|
|
@@ -386,7 +386,7 @@ var MessageSerializer = class extends BaseVisitor {
|
|
|
386
386
|
}
|
|
387
387
|
};
|
|
388
388
|
|
|
389
|
-
// bazel-out/
|
|
389
|
+
// bazel-out/darwin_arm64-fastbuild/bin/packages/localize/tools/src/translate/translation_files/message_serialization/target_message_renderer.js
|
|
390
390
|
var TargetMessageRenderer = class {
|
|
391
391
|
current = { messageParts: [], placeholderNames: [], text: "" };
|
|
392
392
|
icuDepth = 0;
|
|
@@ -441,7 +441,7 @@ var TargetMessageRenderer = class {
|
|
|
441
441
|
}
|
|
442
442
|
};
|
|
443
443
|
|
|
444
|
-
// bazel-out/
|
|
444
|
+
// bazel-out/darwin_arm64-fastbuild/bin/packages/localize/tools/src/translate/translation_files/translation_parsers/serialize_translation_message.js
|
|
445
445
|
function serializeTranslationMessage(element, config) {
|
|
446
446
|
const { rootNodes, errors: parseErrors } = parseInnerRange(element);
|
|
447
447
|
try {
|
|
@@ -453,7 +453,7 @@ function serializeTranslationMessage(element, config) {
|
|
|
453
453
|
}
|
|
454
454
|
}
|
|
455
455
|
|
|
456
|
-
// bazel-out/
|
|
456
|
+
// bazel-out/darwin_arm64-fastbuild/bin/packages/localize/tools/src/translate/translation_files/translation_parsers/xliff1_translation_parser.js
|
|
457
457
|
var Xliff1TranslationParser = class {
|
|
458
458
|
analyze(filePath, contents) {
|
|
459
459
|
return canParseXml(filePath, contents, "xliff", { version: "1.2" });
|
|
@@ -530,7 +530,7 @@ var XliffTranslationVisitor = class extends BaseVisitor {
|
|
|
530
530
|
}
|
|
531
531
|
};
|
|
532
532
|
|
|
533
|
-
// bazel-out/
|
|
533
|
+
// bazel-out/darwin_arm64-fastbuild/bin/packages/localize/tools/src/translate/translation_files/translation_parsers/xliff2_translation_parser.js
|
|
534
534
|
import { Element as Element3, ParseErrorLevel as ParseErrorLevel4, visitAll as visitAll3 } from "@angular/compiler";
|
|
535
535
|
var Xliff2TranslationParser = class {
|
|
536
536
|
analyze(filePath, contents) {
|
|
@@ -613,7 +613,7 @@ function isFileElement(node) {
|
|
|
613
613
|
return node instanceof Element3 && node.name === "file";
|
|
614
614
|
}
|
|
615
615
|
|
|
616
|
-
// bazel-out/
|
|
616
|
+
// bazel-out/darwin_arm64-fastbuild/bin/packages/localize/tools/src/translate/translation_files/translation_parsers/xtb_translation_parser.js
|
|
617
617
|
import { ParseErrorLevel as ParseErrorLevel5, visitAll as visitAll4 } from "@angular/compiler";
|
|
618
618
|
import { extname as extname2 } from "path";
|
|
619
619
|
var XtbTranslationParser = class {
|
|
@@ -694,4 +694,4 @@ export {
|
|
|
694
694
|
* Use of this source code is governed by an MIT-style license that can be
|
|
695
695
|
* found in the LICENSE file at https://angular.dev/license
|
|
696
696
|
*/
|
|
697
|
-
//# sourceMappingURL=chunk-
|
|
697
|
+
//# sourceMappingURL=chunk-YGTHV3U7.js.map
|
package/tools/bundles/index.js
CHANGED
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
Xliff2TranslationSerializer,
|
|
12
12
|
XmbTranslationSerializer,
|
|
13
13
|
checkDuplicateMessages
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-TONUHCMD.js";
|
|
15
15
|
import {
|
|
16
16
|
ArbTranslationParser,
|
|
17
17
|
SimpleJsonTranslationParser,
|
|
@@ -21,7 +21,7 @@ import {
|
|
|
21
21
|
makeEs2015TranslatePlugin,
|
|
22
22
|
makeEs5TranslatePlugin,
|
|
23
23
|
makeLocalePlugin
|
|
24
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-YGTHV3U7.js";
|
|
25
25
|
import {
|
|
26
26
|
Diagnostics,
|
|
27
27
|
buildLocalizeReplacement,
|
|
@@ -31,9 +31,9 @@ import {
|
|
|
31
31
|
unwrapMessagePartsFromLocalizeCall,
|
|
32
32
|
unwrapMessagePartsFromTemplateLiteral,
|
|
33
33
|
unwrapSubstitutionsFromLocalizeCall
|
|
34
|
-
} from "./chunk-
|
|
34
|
+
} from "./chunk-EZ3BW4XG.js";
|
|
35
35
|
|
|
36
|
-
// bazel-out/
|
|
36
|
+
// bazel-out/darwin_arm64-fastbuild/bin/packages/localize/tools/index.js
|
|
37
37
|
import { NodeJSFileSystem, setFileSystem } from "@angular/compiler-cli/private/localize";
|
|
38
38
|
setFileSystem(new NodeJSFileSystem());
|
|
39
39
|
export {
|
|
@@ -13,15 +13,15 @@ import {
|
|
|
13
13
|
XmbTranslationSerializer,
|
|
14
14
|
checkDuplicateMessages,
|
|
15
15
|
parseFormatOptions
|
|
16
|
-
} from "../../chunk-
|
|
17
|
-
import "../../chunk-
|
|
16
|
+
} from "../../chunk-TONUHCMD.js";
|
|
17
|
+
import "../../chunk-EZ3BW4XG.js";
|
|
18
18
|
|
|
19
|
-
// bazel-out/
|
|
19
|
+
// bazel-out/darwin_arm64-fastbuild/bin/packages/localize/tools/src/extract/cli.js
|
|
20
20
|
import { ConsoleLogger, LogLevel, NodeJSFileSystem, setFileSystem } from "@angular/compiler-cli/private/localize";
|
|
21
21
|
import { globSync } from "tinyglobby";
|
|
22
22
|
import yargs from "yargs";
|
|
23
23
|
|
|
24
|
-
// bazel-out/
|
|
24
|
+
// bazel-out/darwin_arm64-fastbuild/bin/packages/localize/tools/src/extract/index.js
|
|
25
25
|
function extractTranslations({ rootPath: rootPath2, sourceFilePaths: sourceFilePaths2, sourceLocale, format: format2, outputPath: output, logger: logger2, useSourceMaps, useLegacyIds, duplicateMessageHandling: duplicateMessageHandling2, formatOptions: formatOptions2 = {}, fileSystem: fs }) {
|
|
26
26
|
const basePath = fs.resolve(rootPath2);
|
|
27
27
|
const extractor = new MessageExtractor(fs, logger2, { basePath, useSourceMaps });
|
|
@@ -64,7 +64,7 @@ function getSerializer(format2, sourceLocale, rootPath2, useLegacyIds, formatOpt
|
|
|
64
64
|
throw new Error(`No translation serializer can handle the provided format: ${format2}`);
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
-
// bazel-out/
|
|
67
|
+
// bazel-out/darwin_arm64-fastbuild/bin/packages/localize/tools/src/extract/cli.js
|
|
68
68
|
process.title = "Angular Localization Message Extractor (localize-extract)";
|
|
69
69
|
var args = process.argv.slice(2);
|
|
70
70
|
var options = yargs(args).option("l", {
|
|
@@ -4,15 +4,15 @@
|
|
|
4
4
|
const require = __cjsCompatRequire(import.meta.url);
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
// bazel-out/
|
|
7
|
+
// bazel-out/darwin_arm64-fastbuild/bin/packages/localize/tools/src/migrate/cli.js
|
|
8
8
|
import { ConsoleLogger, LogLevel, NodeJSFileSystem, setFileSystem } from "@angular/compiler-cli/private/localize";
|
|
9
9
|
import { globSync } from "tinyglobby";
|
|
10
10
|
import yargs from "yargs";
|
|
11
11
|
|
|
12
|
-
// bazel-out/
|
|
12
|
+
// bazel-out/darwin_arm64-fastbuild/bin/packages/localize/tools/src/migrate/index.js
|
|
13
13
|
import { getFileSystem } from "@angular/compiler-cli/private/localize";
|
|
14
14
|
|
|
15
|
-
// bazel-out/
|
|
15
|
+
// bazel-out/darwin_arm64-fastbuild/bin/packages/localize/tools/src/migrate/migrate.js
|
|
16
16
|
function migrateFile(sourceCode, mapping) {
|
|
17
17
|
const legacyIds = Object.keys(mapping);
|
|
18
18
|
for (const legacyId of legacyIds) {
|
|
@@ -26,7 +26,7 @@ function escapeRegExp(str) {
|
|
|
26
26
|
return str.replace(/([.*+?^=!:${}()|[\]\/\\])/g, "\\$1");
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
// bazel-out/
|
|
29
|
+
// bazel-out/darwin_arm64-fastbuild/bin/packages/localize/tools/src/migrate/index.js
|
|
30
30
|
function migrateFiles({ rootPath: rootPath2, translationFilePaths: translationFilePaths2, mappingFilePath, logger: logger2 }) {
|
|
31
31
|
const fs2 = getFileSystem();
|
|
32
32
|
const absoluteMappingPath = fs2.resolve(rootPath2, mappingFilePath);
|
|
@@ -42,7 +42,7 @@ function migrateFiles({ rootPath: rootPath2, translationFilePaths: translationFi
|
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
// bazel-out/
|
|
45
|
+
// bazel-out/darwin_arm64-fastbuild/bin/packages/localize/tools/src/migrate/cli.js
|
|
46
46
|
var args = process.argv.slice(2);
|
|
47
47
|
var options = yargs(args).option("r", {
|
|
48
48
|
alias: "root",
|
|
@@ -12,26 +12,26 @@ import {
|
|
|
12
12
|
makeEs2015TranslatePlugin,
|
|
13
13
|
makeEs5TranslatePlugin,
|
|
14
14
|
makeLocalePlugin
|
|
15
|
-
} from "../../chunk-
|
|
15
|
+
} from "../../chunk-YGTHV3U7.js";
|
|
16
16
|
import {
|
|
17
17
|
Diagnostics
|
|
18
|
-
} from "../../chunk-
|
|
18
|
+
} from "../../chunk-EZ3BW4XG.js";
|
|
19
19
|
|
|
20
|
-
// bazel-out/
|
|
20
|
+
// bazel-out/darwin_arm64-fastbuild/bin/packages/localize/tools/src/translate/cli.js
|
|
21
21
|
import { NodeJSFileSystem, setFileSystem } from "@angular/compiler-cli/private/localize";
|
|
22
22
|
import { globSync } from "tinyglobby";
|
|
23
23
|
import yargs from "yargs";
|
|
24
24
|
|
|
25
|
-
// bazel-out/
|
|
25
|
+
// bazel-out/darwin_arm64-fastbuild/bin/packages/localize/tools/src/translate/output_path.js
|
|
26
26
|
function getOutputPathFn(fs2, outputFolder) {
|
|
27
27
|
const [pre, post] = outputFolder.split("{{LOCALE}}");
|
|
28
28
|
return post === void 0 ? (_locale, relativePath) => fs2.join(pre, relativePath) : (locale, relativePath) => fs2.join(pre + locale + post, relativePath);
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
// bazel-out/
|
|
31
|
+
// bazel-out/darwin_arm64-fastbuild/bin/packages/localize/tools/src/translate/index.js
|
|
32
32
|
import { getFileSystem, relativeFrom } from "@angular/compiler-cli/private/localize";
|
|
33
33
|
|
|
34
|
-
// bazel-out/
|
|
34
|
+
// bazel-out/darwin_arm64-fastbuild/bin/packages/localize/tools/src/translate/asset_files/asset_translation_handler.js
|
|
35
35
|
import { absoluteFrom } from "@angular/compiler-cli/private/localize";
|
|
36
36
|
var AssetTranslationHandler = class {
|
|
37
37
|
fs;
|
|
@@ -60,7 +60,7 @@ var AssetTranslationHandler = class {
|
|
|
60
60
|
}
|
|
61
61
|
};
|
|
62
62
|
|
|
63
|
-
// bazel-out/
|
|
63
|
+
// bazel-out/darwin_arm64-fastbuild/bin/packages/localize/tools/src/translate/source_files/source_file_translation_handler.js
|
|
64
64
|
import { absoluteFrom as absoluteFrom2 } from "@angular/compiler-cli/private/localize";
|
|
65
65
|
import babel from "@babel/core";
|
|
66
66
|
var SourceFileTranslationHandler = class {
|
|
@@ -134,7 +134,7 @@ var SourceFileTranslationHandler = class {
|
|
|
134
134
|
}
|
|
135
135
|
};
|
|
136
136
|
|
|
137
|
-
// bazel-out/
|
|
137
|
+
// bazel-out/darwin_arm64-fastbuild/bin/packages/localize/tools/src/translate/translation_files/translation_loader.js
|
|
138
138
|
var TranslationLoader = class {
|
|
139
139
|
fs;
|
|
140
140
|
translationParsers;
|
|
@@ -207,7 +207,7 @@ ${parser.constructor.name} cannot parse translation file.`));
|
|
|
207
207
|
}
|
|
208
208
|
};
|
|
209
209
|
|
|
210
|
-
// bazel-out/
|
|
210
|
+
// bazel-out/darwin_arm64-fastbuild/bin/packages/localize/tools/src/translate/translator.js
|
|
211
211
|
var Translator = class {
|
|
212
212
|
fs;
|
|
213
213
|
resourceHandlers;
|
|
@@ -232,7 +232,7 @@ var Translator = class {
|
|
|
232
232
|
}
|
|
233
233
|
};
|
|
234
234
|
|
|
235
|
-
// bazel-out/
|
|
235
|
+
// bazel-out/darwin_arm64-fastbuild/bin/packages/localize/tools/src/translate/index.js
|
|
236
236
|
function translateFiles({ sourceRootPath: sourceRootPath2, sourceFilePaths: sourceFilePaths2, translationFilePaths: translationFilePaths2, translationFileLocales: translationFileLocales2, outputPathFn: outputPathFn2, diagnostics: diagnostics2, missingTranslation: missingTranslation2, duplicateTranslation: duplicateTranslation2, sourceLocale: sourceLocale2 }) {
|
|
237
237
|
const fs2 = getFileSystem();
|
|
238
238
|
const translationLoader = new TranslationLoader(fs2, [
|
|
@@ -249,7 +249,7 @@ function translateFiles({ sourceRootPath: sourceRootPath2, sourceFilePaths: sour
|
|
|
249
249
|
resourceProcessor.translateFiles(sourceFilePaths2.map(relativeFrom), fs2.resolve(sourceRootPath2), outputPathFn2, translations, sourceLocale2);
|
|
250
250
|
}
|
|
251
251
|
|
|
252
|
-
// bazel-out/
|
|
252
|
+
// bazel-out/darwin_arm64-fastbuild/bin/packages/localize/tools/src/translate/cli.js
|
|
253
253
|
process.title = "Angular Localization Message Translator (localize-translate)";
|
|
254
254
|
var args = process.argv.slice(2);
|
|
255
255
|
var options = yargs(args).option("r", {
|
|
File without changes
|
|
File without changes
|
|
File without changes
|