(
content: string,
implicitTags: string[] = [],
implicitAttrs: {[k: string]: string[]} = {},
)
| 654 | } |
| 655 | |
| 656 | function 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 | |
| 684 | function fakeNoTranslate( |
| 685 | content: string, |
no test coverage detected
searching dependent graphs…