MCPcopy Create free account
hub / github.com/angular/angular / makeParsedTranslation

Function makeParsedTranslation

packages/localize/src/utils/src/translations.ts:122–136  ·  view source on GitHub ↗
(
  messageParts: string[],
  placeholderNames: string[] = [],
)

Source from the content-addressed store, hash-verified

120 * @param placeholderNames The names of the placeholders to intersperse between the `messageParts`.
121 */
122export function makeParsedTranslation(
123 messageParts: string[],
124 placeholderNames: string[] = [],
125): ParsedTranslation {
126 messageParts = messageParts.map((part) => part.replace(/\uFFFD/g, ''));
127 let messageString = messageParts[0];
128 for (let i = 0; i < placeholderNames.length; i++) {
129 messageString += `{$${placeholderNames[i]}}${messageParts[i + 1]}`;
130 }
131 return {
132 text: messageString,
133 messageParts: makeTemplateObject(messageParts, messageParts),
134 placeholderNames,
135 };
136}
137
138/**
139 * Create the specialized array that is passed to tagged-string tag functions.

Callers 1

Calls 3

mapMethod · 0.80
makeTemplateObjectFunction · 0.70
replaceMethod · 0.45

Tested by

no test coverage detected