MCPcopy Index your code
hub / github.com/angular/angular / translate

Function translate

packages/localize/tools/src/source_file_utils.ts:426–448  ·  view source on GitHub ↗
(
  diagnostics: Diagnostics,
  translations: Record<string, ɵParsedTranslation>,
  messageParts: TemplateStringsArray,
  substitutions: readonly any[],
  missingTranslation: DiagnosticHandlingStrategy,
)

Source from the content-addressed store, hash-verified

424 * @publicApi used by CLI
425 */
426export function translate(
427 diagnostics: Diagnostics,
428 translations: Record<string, ɵParsedTranslation>,
429 messageParts: TemplateStringsArray,
430 substitutions: readonly any[],
431 missingTranslation: DiagnosticHandlingStrategy,
432): [TemplateStringsArray, readonly any[]] {
433 try {
434 return ɵtranslate(translations, messageParts, substitutions);
435 } catch (e: any) {
436 if (ɵisMissingTranslationError(e)) {
437 diagnostics.add(missingTranslation, e.message);
438 // Return the parsed message because this will have the meta blocks stripped
439 return [
440 ɵmakeTemplateObject(e.parsedMessage.messageParts, e.parsedMessage.messageParts),
441 substitutions,
442 ];
443 } else {
444 diagnostics.error(e.message);
445 return [messageParts, substitutions];
446 }
447 }
448}
449
450export class BabelParseError extends Error {
451 private readonly type = 'BabelParseError';

Callers 2

TaggedTemplateExpressionFunction · 0.90
CallExpressionFunction · 0.90

Calls 2

addMethod · 0.65
errorMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…