From 040bf57966258f75021aaa55b4719a09269353aa Mon Sep 17 00:00:00 2001
From: Victor Berchet
Date: Fri, 30 Sep 2016 15:39:46 -0700
Subject: [PATCH] fix(xlif): fix `` ctype names
fixes #12000
see http://docs.oasis-open.org/xliff/v1.2/os/xliff-core.html#ctype
---
.../compiler/src/i18n/serializers/xliff.ts | 17 +++++++++++++++--
.../test/i18n/serializers/xliff_spec.ts | 16 ++++++++++++++--
2 files changed, 29 insertions(+), 4 deletions(-)
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
+