diff --git a/modules/@angular/compiler/src/i18n/serializers/xliff.ts b/modules/@angular/compiler/src/i18n/serializers/xliff.ts index 08b0c84fa8..2600af3f7f 100644 --- a/modules/@angular/compiler/src/i18n/serializers/xliff.ts +++ b/modules/@angular/compiler/src/i18n/serializers/xliff.ts @@ -139,13 +139,15 @@ class _WriteVisitor implements i18n.Visitor { } visitTagPlaceholder(ph: i18n.TagPlaceholder, context?: any): xml.Node[] { - const startTagPh = new xml.Tag(_PLACEHOLDER_TAG, {id: ph.startName, ctype: ph.tag}); + const ctype = getCtypeForTag(ph.tag); + + const startTagPh = new xml.Tag(_PLACEHOLDER_TAG, {id: ph.startName, ctype}); if (ph.isVoid) { // void tags have no children nor closing tags return [startTagPh]; } - const closeTagPh = new xml.Tag(_PLACEHOLDER_TAG, {id: ph.closeName, ctype: ph.tag}); + const closeTagPh = new xml.Tag(_PLACEHOLDER_TAG, {id: ph.closeName, ctype}); return [startTagPh, ...this.serialize(ph.children), closeTagPh]; } @@ -289,3 +291,14 @@ class _LoadVisitor implements ml.Visitor { this._errors.push(new I18nError(node.sourceSpan, message)); } } + +function getCtypeForTag(tag: string): string { + switch (tag.toLowerCase()) { + case 'br': + return 'lb'; + case 'img': + return 'image'; + default: + return `x-${tag}`; + } +} \ No newline at end of file diff --git a/modules/@angular/compiler/test/i18n/serializers/xliff_spec.ts b/modules/@angular/compiler/test/i18n/serializers/xliff_spec.ts index 5d9ea96a3b..a5322f94ff 100644 --- a/modules/@angular/compiler/test/i18n/serializers/xliff_spec.ts +++ b/modules/@angular/compiler/test/i18n/serializers/xliff_spec.ts @@ -17,6 +17,7 @@ const HTML = `

not translatable

translatable element with placeholders {{ interpolation}}

foo

+


`; const WRITE_XLIFF = ` @@ -28,7 +29,7 @@ const WRITE_XLIFF = ` - translatable element with placeholders + translatable element with placeholders @@ -37,6 +38,11 @@ const WRITE_XLIFF = ` d m + + + + ph names + @@ -52,7 +58,7 @@ const LOAD_XLIFF = ` translatable element with placeholders - footnemele elbatalsnart sredlohecalp htiw + footnemele elbatalsnart sredlohecalp htiw foo @@ -60,6 +66,11 @@ const LOAD_XLIFF = ` d m + + + + ph names + @@ -105,6 +116,7 @@ export function main(): void { 'ec1d033f2436133c14ab038286c4f5df4697484a': '{{ interpolation}} footnemele elbatalsnart sredlohecalp htiw', 'db3e0a6a5a96481f60aec61d98c3eecddef5ac23': 'oof', + 'd7fa2d59aaedcaa5309f13028c59af8c85b8c49d': '


', }); }); });