diff --git a/packages/compiler/src/i18n/serializers/xliff.ts b/packages/compiler/src/i18n/serializers/xliff.ts
index 5e054f468e..11a59441a6 100644
--- a/packages/compiler/src/i18n/serializers/xliff.ts
+++ b/packages/compiler/src/i18n/serializers/xliff.ts
@@ -139,23 +139,28 @@ class _WriteVisitor implements i18n.Visitor {
visitTagPlaceholder(ph: i18n.TagPlaceholder, context?: any): xml.Node[] {
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];
+ return [new xml.Tag(
+ _PLACEHOLDER_TAG, {id: ph.startName, ctype, 'equiv-text': `<${ph.tag}/>`})];
}
- const closeTagPh = new xml.Tag(_PLACEHOLDER_TAG, {id: ph.closeName, ctype});
+ const startTagPh =
+ new xml.Tag(_PLACEHOLDER_TAG, {id: ph.startName, ctype, 'equiv-text': `<${ph.tag}>`});
+ const closeTagPh =
+ new xml.Tag(_PLACEHOLDER_TAG, {id: ph.closeName, ctype, 'equiv-text': `${ph.tag}>`});
return [startTagPh, ...this.serialize(ph.children), closeTagPh];
}
visitPlaceholder(ph: i18n.Placeholder, context?: any): xml.Node[] {
- return [new xml.Tag(_PLACEHOLDER_TAG, {id: ph.name})];
+ return [new xml.Tag(_PLACEHOLDER_TAG, {id: ph.name, 'equiv-text': `{{${ph.value}}}`})];
}
visitIcuPlaceholder(ph: i18n.IcuPlaceholder, context?: any): xml.Node[] {
- return [new xml.Tag(_PLACEHOLDER_TAG, {id: ph.name})];
+ const equivText =
+ `{${ph.value.expression}, ${ph.value.type}, ${Object.keys(ph.value.cases).map((value: string) => value + ' {...}').join(' ')}}`;
+ return [new xml.Tag(_PLACEHOLDER_TAG, {id: ph.name, 'equiv-text': equivText})];
}
serialize(nodes: i18n.Node[]): xml.Node[] {
diff --git a/packages/compiler/src/i18n/serializers/xmb.ts b/packages/compiler/src/i18n/serializers/xmb.ts
index c9ee3eb52b..dde588f7aa 100644
--- a/packages/compiler/src/i18n/serializers/xmb.ts
+++ b/packages/compiler/src/i18n/serializers/xmb.ts
@@ -129,11 +129,16 @@ class _Visitor implements i18n.Visitor {
}
visitPlaceholder(ph: i18n.Placeholder, context?: any): xml.Node[] {
- return [new xml.Tag(_PLACEHOLDER_TAG, {name: ph.name})];
+ const exTag = new xml.Tag(_EXEMPLE_TAG, {}, [new xml.Text(`{{${ph.value}}}`)]);
+ return [new xml.Tag(_PLACEHOLDER_TAG, {name: ph.name}, [exTag])];
}
visitIcuPlaceholder(ph: i18n.IcuPlaceholder, context?: any): xml.Node[] {
- return [new xml.Tag(_PLACEHOLDER_TAG, {name: ph.name})];
+ const exTag = new xml.Tag(_EXEMPLE_TAG, {}, [
+ new xml.Text(
+ `{${ph.value.expression}, ${ph.value.type}, ${Object.keys(ph.value.cases).map((value: string) => value + ' {...}').join(' ')}}`)
+ ]);
+ return [new xml.Tag(_PLACEHOLDER_TAG, {name: ph.name}, [exTag])];
}
serialize(nodes: i18n.Node[]): xml.Node[] {
diff --git a/packages/compiler/test/i18n/integration_common.ts b/packages/compiler/test/i18n/integration_common.ts
index bb612e5783..b2abdb8d0d 100644
--- a/packages/compiler/test/i18n/integration_common.ts
+++ b/packages/compiler/test/i18n/integration_common.ts
@@ -113,6 +113,7 @@ export const HTML = `
+
diff --git a/packages/compiler/test/i18n/integration_xliff_spec.ts b/packages/compiler/test/i18n/integration_xliff_spec.ts
index 6637224a7e..1bcc2f0cc6 100644
--- a/packages/compiler/test/i18n/integration_xliff_spec.ts
+++ b/packages/compiler/test/i18n/integration_xliff_spec.ts
@@ -70,9 +70,17 @@ const XLIFF_TOMERGE = `
different meaning
-
+
avec des espaces réservés
+
+
+ with nested placeholders
+
+ file.ts
+ 11
+
+
sur des balises non traductibles
@@ -82,12 +90,12 @@ const XLIFF_TOMERGE = `
sur des balises traductibles
-
+
{VAR_PLURAL, plural, =0 {zero} =1 {un} =2 {deux} other {beaucoup} }
@@ -97,7 +105,7 @@ const XLIFF_TOMERGE = `
@@ -106,15 +114,15 @@ const XLIFF_TOMERGE = `
{VAR_SELECT, select, m {homme} f {femme} }
-
+
-
+
sexe =
-
+
@@ -123,9 +131,9 @@ const XLIFF_TOMERGE = `
Balises dans les commentaires html
@@ -134,7 +142,7 @@ const XLIFF_TOMERGE = `
-
+
ca devrait marcher
@@ -142,20 +150,20 @@ const XLIFF_TOMERGE = `
avec un ID explicite
-
+
{VAR_PLURAL, plural, =0 {zero} =1 {un} =2 {deux} other {beaucoup} }
-
+
{VAR_PLURAL, plural, =0 {Pas de réponse} =1 {une réponse} other {Found réponse} }
desc
-
+
FOOBAR
-
+
`;
@@ -183,7 +191,7 @@ const XLIFF_EXTRACTED = `
different meaning
-
+
file.ts
9
@@ -193,146 +201,153 @@ const XLIFF_EXTRACTED = `
10
+
+
+
+ file.ts
+ 11
+
+
file.ts
- 13
+ 14
file.ts
- 14
+ 15
-
+
file.ts
- 19
+ 20
file.ts
- 36
+ 37
file.ts
- 21
+ 22
file.ts
- 22
+ 23
file.ts
- 24
+ 25
file.ts
- 25
+ 26
-
-
- file.ts
- 28
-
-
-
-
+
file.ts
29
-
-
+
+
file.ts
30
+
+
+
+ file.ts
+ 31
+
+
file.ts
- 35
+ 36
file.ts
- 53
+ 54
file.ts
- 33
+ 34
-
+
file.ts
- 39
+ 40
-
- file.ts
- 41
-
-
-
-
file.ts
42
-
-
+
+
file.ts
- 45
+ 43
+
+
+
+
+
+ file.ts
+ 46
desc
-
+
file.ts
- 53
+ 54
-
+
file.ts
- 55
+ 56
`;
diff --git a/packages/compiler/test/i18n/integration_xmb_xtb_spec.ts b/packages/compiler/test/i18n/integration_xmb_xtb_spec.ts
index 679a22e218..ebd7c324f7 100644
--- a/packages/compiler/test/i18n/integration_xmb_xtb_spec.ts
+++ b/packages/compiler/test/i18n/integration_xmb_xtb_spec.ts
@@ -61,6 +61,7 @@ const XTB = `
imbriqué
imbriqué
avec des espaces réservés
+ <div>avec <div>des espaces réservés</div> imbriqués</div>
sur des balises non traductibles
sur des balises traductibles
{VAR_PLURAL, plural, =0 {zero} =1 {un} =2 {deux} other {beaucoup}}
@@ -90,29 +91,30 @@ const XMB = `i18n attribu
nested
nested
<i>with placeholders</i>
- on not translatable node
- on translatable node
- {VAR_PLURAL, plural, =0 {zero} =1 {one} =2 {two} other {<b>many</b>} }
-
- ICU
+ <div>with <div>nested</div> placeholders</div>
+ on not translatable node
+ on translatable node
+ {VAR_PLURAL, plural, =0 {zero} =1 {one} =2 {two} other {<b>many</b>} }
+
+ {sex, select, 0 {...} m {...} f {...}}
- {VAR_SELECT, select, 0 {other} m {male} f {female} }
-
- ICU
+ {VAR_SELECT, select, 0 {other} m {male} f {female} }
+
+ {sexB, select, m {...} f {...}}
- {VAR_SELECT, select, m {male} f {female} }
- INTERPOLATION
- sex = INTERPOLATION
- CUSTOM_NAME
- in a translatable section
-
+ {VAR_SELECT, select, m {male} f {female} }
+ {{ "count = " + count }}
+ sex = {{ sex }}
+ {{ "custom name" //i18n(ph="CUSTOM_NAME") }}
+ in a translatable section
+
<h1>Markers in html comments</h1>
<div></div>
- <div>ICU</div>
+ <div>{count, plural, =0 {...} =1 {...} =2 {...} other {...}}</div>
- it <b>should</b> work
- with an explicit ID
- {VAR_PLURAL, plural, =0 {zero} =1 {one} =2 {two} other {<b>many</b>} }
- {VAR_PLURAL, plural, =0 {Found no results} =1 {Found one result} other {Found INTERPOLATION results} }
- foo<a>bar</a>
- MAP_NAME`;
+ it <b>should</b> work
+ with an explicit ID
+ {VAR_PLURAL, plural, =0 {zero} =1 {one} =2 {two} other {<b>many</b>} }
+ {VAR_PLURAL, plural, =0 {Found no results} =1 {Found one result} other {Found {{response.getItemsList().length}} results} }
+ foo<a>bar</a>
+ {{ 'test' //i18n(ph="map name") }}`;
diff --git a/packages/compiler/test/i18n/serializers/xliff_spec.ts b/packages/compiler/test/i18n/serializers/xliff_spec.ts
index 1a1071abf1..c5f6a2c128 100644
--- a/packages/compiler/test/i18n/serializers/xliff_spec.ts
+++ b/packages/compiler/test/i18n/serializers/xliff_spec.ts
@@ -24,7 +24,7 @@ const HTML = `
foo
{ count, plural, =0 { { sex, select, other {
deeply nested
}} }}
-{ count, plural, =0 { { sex, select, other {
deeply nested
}} }}
+Test: { count, plural, =0 { { sex, select, other {
deeply nested
}} } =other {a lot}}
multi
lines
`;
@@ -41,14 +41,14 @@ const WRITE_XLIFF = `
-
+
file.ts
3
-
+
file.ts
4
@@ -84,7 +84,7 @@ const WRITE_XLIFF = `
-
+
file.ts
9
@@ -92,14 +92,21 @@ const WRITE_XLIFF = `
ph names
-
+
file.ts
10
-
-
+
+
+
+ file.ts
+ 11
+
+
+
+
file.ts
11
@@ -192,9 +199,17 @@ const LOAD_XLIFF = `
{VAR_PLURAL, plural, =0 {{VAR_SELECT, select, other {profondément imbriqué} } } }
-
-
- {VAR_PLURAL, plural, =0 {{VAR_SELECT, select, other {profondément imbriqué} } } }
+
+
+ Test:
+
+ file.ts
+ 11
+
+
+
+
+ {VAR_PLURAL, plural, =0 {{VAR_SELECT, select, other {profondément imbriqué} } } =other {beaucoup} }