diff --git a/modules/@angular/compiler/src/i18n/extractor_merger.ts b/modules/@angular/compiler/src/i18n/extractor_merger.ts index 1a37f3aaa8..0e834c1ca2 100644 --- a/modules/@angular/compiler/src/i18n/extractor_merger.ts +++ b/modules/@angular/compiler/src/i18n/extractor_merger.ts @@ -8,6 +8,7 @@ import * as html from '../ml_parser/ast'; import {InterpolationConfig} from '../ml_parser/interpolation_config'; +import {ParseTreeResult} from '../ml_parser/parser'; import {digestMessage} from './digest'; import * as i18n from './i18n_ast'; @@ -31,7 +32,7 @@ export function extractMessages( export function mergeTranslations( nodes: html.Node[], translations: TranslationBundle, interpolationConfig: InterpolationConfig, - implicitTags: string[], implicitAttrs: {[k: string]: string[]}): html.Node[] { + implicitTags: string[], implicitAttrs: {[k: string]: string[]}): ParseTreeResult { const visitor = new _Visitor(implicitTags, implicitAttrs); return visitor.merge(nodes, translations, interpolationConfig); } @@ -102,7 +103,7 @@ class _Visitor implements html.Visitor { */ merge( nodes: html.Node[], translations: TranslationBundle, - interpolationConfig: InterpolationConfig): html.Node[] { + interpolationConfig: InterpolationConfig): ParseTreeResult { this._init(_VisitorMode.Merge, interpolationConfig); this._translations = translations; @@ -111,12 +112,11 @@ class _Visitor implements html.Visitor { const translatedNode = wrapper.visit(this, null); - // TODO(vicb): return MergeResult with errors if (this._inI18nBlock) { this._reportError(nodes[nodes.length - 1], 'Unclosed block'); } - return translatedNode.children; + return new ParseTreeResult(translatedNode.children, this._errors); } visitExpansionCase(icuCase: html.ExpansionCase, context: any): any { diff --git a/modules/@angular/compiler/src/i18n/html_parser.ts b/modules/@angular/compiler/src/i18n/html_parser.ts index 2200f838af..5672d29014 100644 --- a/modules/@angular/compiler/src/i18n/html_parser.ts +++ b/modules/@angular/compiler/src/i18n/html_parser.ts @@ -46,9 +46,6 @@ export class HtmlParser implements BaseHtmlParser { const xtb = new Xtb(this._htmlParser, interpolationConfig); const translationBundle = TranslationBundle.load(this._translations, url, messageBundle, xtb); - const translatedNodes = - mergeTranslations(parseResult.rootNodes, translationBundle, interpolationConfig, [], {}); - - return new ParseTreeResult(translatedNodes, []); + return mergeTranslations(parseResult.rootNodes, translationBundle, interpolationConfig, [], {}); } } \ No newline at end of file diff --git a/modules/@angular/compiler/test/i18n/extractor_merger_spec.ts b/modules/@angular/compiler/test/i18n/extractor_merger_spec.ts index ab2483153e..fc51c963a2 100644 --- a/modules/@angular/compiler/test/i18n/extractor_merger_spec.ts +++ b/modules/@angular/compiler/test/i18n/extractor_merger_spec.ts @@ -410,10 +410,12 @@ function fakeTranslate( const translations = new TranslationBundle(i18nMsgMap); - const translateNodes = mergeTranslations( - htmlNodes, translations, DEFAULT_INTERPOLATION_CONFIG, implicitTags, implicitAttrs); + const translatedNodes = + mergeTranslations( + htmlNodes, translations, DEFAULT_INTERPOLATION_CONFIG, implicitTags, implicitAttrs) + .rootNodes; - return serializeHtmlNodes(translateNodes).join(''); + return serializeHtmlNodes(translatedNodes).join(''); } function extract(