/** * @license * Copyright Google LLC All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ import { extractMessages } from './extractor_merger'; import * as i18n from './i18n_ast'; /** * A container for message extracted from the templates. */ export class MessageBundle { constructor(_htmlParser, _implicitTags, _implicitAttrs, _locale = null) { this._htmlParser = _htmlParser; this._implicitTags = _implicitTags; this._implicitAttrs = _implicitAttrs; this._locale = _locale; this._messages = []; } updateFromTemplate(html, url, interpolationConfig) { const htmlParserResult = this._htmlParser.parse(html, url, { tokenizeExpansionForms: true, interpolationConfig }); if (htmlParserResult.errors.length) { return htmlParserResult.errors; } const i18nParserResult = extractMessages(htmlParserResult.rootNodes, interpolationConfig, this._implicitTags, this._implicitAttrs); if (i18nParserResult.errors.length) { return i18nParserResult.errors; } this._messages.push(...i18nParserResult.messages); return []; } // Return the message in the internal format // The public (serialized) format might be different, see the `write` method. getMessages() { return this._messages; } write(serializer, filterSources) { const messages = {}; const mapperVisitor = new MapPlaceholderNames(); // Deduplicate messages based on their ID this._messages.forEach(message => { const id = serializer.digest(message); if (!messages.hasOwnProperty(id)) { messages[id] = message; } else { messages[id].sources.push(...message.sources); } }); // Transform placeholder names using the serializer mapping const msgList = Object.keys(messages).map(id => { const mapper = serializer.createNameMapper(messages[id]); const src = messages[id]; const nodes = mapper ? mapperVisitor.convert(src.nodes, mapper) : src.nodes; let transformedMessage = new i18n.Message(nodes, {}, {}, src.meaning, src.description, id); transformedMessage.sources = src.sources; if (filterSources) { transformedMessage.sources.forEach((source) => source.filePath = filterSources(source.filePath)); } return transformedMessage; }); return serializer.write(msgList, this._locale); } } // Transform an i18n AST by renaming the placeholder nodes with the given mapper class MapPlaceholderNames extends i18n.CloneVisitor { convert(nodes, mapper) { return mapper ? nodes.map(n => n.visit(this, mapper)) : nodes; } visitTagPlaceholder(ph, mapper) { const startName = mapper.toPublicName(ph.startName); const closeName = ph.closeName ? mapper.toPublicName(ph.closeName) : ph.closeName; const children = ph.children.map(n => n.visit(this, mapper)); return new i18n.TagPlaceholder(ph.tag, ph.attrs, startName, closeName, children, ph.isVoid, ph.sourceSpan, ph.startSourceSpan, ph.endSourceSpan); } visitPlaceholder(ph, mapper) { return new i18n.Placeholder(ph.value, mapper.toPublicName(ph.name), ph.sourceSpan); } visitIcuPlaceholder(ph, mapper) { return new i18n.IcuPlaceholder(ph.value, mapper.toPublicName(ph.name), ph.sourceSpan); } } //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibWVzc2FnZV9idW5kbGUuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi8uLi8uLi9wYWNrYWdlcy9jb21waWxlci9zcmMvaTE4bi9tZXNzYWdlX2J1bmRsZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTs7Ozs7O0dBTUc7QUFNSCxPQUFPLEVBQUMsZUFBZSxFQUFDLE1BQU0sb0JBQW9CLENBQUM7QUFDbkQsT0FBTyxLQUFLLElBQUksTUFBTSxZQUFZLENBQUM7QUFJbkM7O0dBRUc7QUFDSCxNQUFNLE9BQU8sYUFBYTtJQUd4QixZQUNZLFdBQXVCLEVBQVUsYUFBdUIsRUFDeEQsY0FBdUMsRUFBVSxVQUF1QixJQUFJO1FBRDVFLGdCQUFXLEdBQVgsV0FBVyxDQUFZO1FBQVUsa0JBQWEsR0FBYixhQUFhLENBQVU7UUFDeEQsbUJBQWMsR0FBZCxjQUFjLENBQXlCO1FBQVUsWUFBTyxHQUFQLE9BQU8sQ0FBb0I7UUFKaEYsY0FBUyxHQUFtQixFQUFFLENBQUM7SUFJb0QsQ0FBQztJQUU1RixrQkFBa0IsQ0FBQyxJQUFZLEVBQUUsR0FBVyxFQUFFLG1CQUF3QztRQUVwRixNQUFNLGdCQUFnQixHQUNsQixJQUFJLENBQUMsV0FBVyxDQUFDLEtBQUssQ0FBQyxJQUFJLEVBQUUsR0FBRyxFQUFFLEVBQUMsc0JB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