MCPcopy
hub / github.com/angular/angular / parseTranslation

Function parseTranslation

packages/localize/src/utils/src/translations.ts:93–109  ·  view source on GitHub ↗
(messageString: TargetMessage)

Source from the content-addressed store, hash-verified

91 * @param message the message to be parsed.
92 */
93export function parseTranslation(messageString: TargetMessage): ParsedTranslation {
94 const parts = messageString.split(/{\$([^}]*)}/);
95 const messageParts = [parts[0]];
96 const placeholderNames: string[] = [];
97 for (let i = 1; i < parts.length - 1; i += 2) {
98 placeholderNames.push(parts[i]);
99 messageParts.push(`${parts[i + 1]}`);
100 }
101 const rawMessageParts = messageParts.map((part) =>
102 part.charAt(0) === BLOCK_MARKER ? '\\' + part : part,
103 );
104 return {
105 text: messageString,
106 messageParts: makeTemplateObject(messageParts, rawMessageParts),
107 placeholderNames,
108 };
109}
110
111/**
112 * Create a `ParsedTranslation` from a set of `messageParts` and `placeholderNames`.

Callers 3

loadTranslationsFunction · 0.90
parseTranslationsFunction · 0.85

Calls 4

mapMethod · 0.80
charAtMethod · 0.80
makeTemplateObjectFunction · 0.70
pushMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…