MCPcopy
hub / github.com/angular/angular / fakeTranslate

Function fakeTranslate

packages/compiler/test/i18n/extractor_merger_spec.ts:656–682  ·  view source on GitHub ↗
(
  content: string,
  implicitTags: string[] = [],
  implicitAttrs: {[k: string]: string[]} = {},
)

Source from the content-addressed store, hash-verified

654}
655
656function fakeTranslate(
657 content: string,
658 implicitTags: string[] = [],
659 implicitAttrs: {[k: string]: string[]} = {},
660): string {
661 const htmlNodes: html.Node[] = parseHtml(content);
662 const messages: i18n.Message[] = extractMessages(
663 htmlNodes,
664 implicitTags,
665 implicitAttrs,
666 /* preserveSignificantWhitespace */ true,
667 ).messages;
668
669 const i18nMsgMap: {[id: string]: i18n.Node[]} = {};
670
671 messages.forEach((message) => {
672 const id = digest(message);
673 const text = serializeI18nNodes(message.nodes).join('').replace(/</g, '[');
674 i18nMsgMap[id] = [new i18n.Text(`**${text}**`, null!)];
675 });
676
677 const translationBundle = new TranslationBundle(i18nMsgMap, null, digest);
678 const output = mergeTranslations(htmlNodes, translationBundle, implicitTags, implicitAttrs);
679 expect(output.errors).toEqual([]);
680
681 return serializeHtmlNodes(output.rootNodes).join('');
682}
683
684function fakeNoTranslate(
685 content: string,

Callers 1

Calls 7

extractMessagesFunction · 0.90
digestFunction · 0.90
mergeTranslationsFunction · 0.90
parseHtmlFunction · 0.70
joinMethod · 0.65
forEachMethod · 0.45
replaceMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…