diff --git a/packages/compiler/src/i18n/serializers/xliff.ts b/packages/compiler/src/i18n/serializers/xliff.ts
index 11a59441a6..fb64794daa 100644
--- a/packages/compiler/src/i18n/serializers/xliff.ts
+++ b/packages/compiler/src/i18n/serializers/xliff.ts
@@ -20,9 +20,11 @@ const _XMLNS = 'urn:oasis:names:tc:xliff:document:1.2';
// TODO(vicb): make this a param (s/_/-/)
const _DEFAULT_SOURCE_LANG = 'en';
const _PLACEHOLDER_TAG = 'x';
+const _MARKER_TAG = 'mrk';
const _FILE_TAG = 'file';
const _SOURCE_TAG = 'source';
+const _SEGMENT_SOURCE_TAG = 'seg-source';
const _TARGET_TAG = 'target';
const _UNIT_TAG = 'trans-unit';
const _CONTEXT_GROUP_TAG = 'context-group';
@@ -214,8 +216,9 @@ class XliffParser implements ml.Visitor {
}
break;
+ // ignore those tags
case _SOURCE_TAG:
- // ignore source message
+ case _SEGMENT_SOURCE_TAG:
break;
case _TARGET_TAG:
@@ -266,7 +269,7 @@ class XmlToI18n implements ml.Visitor {
const i18nNodes = this._errors.length > 0 || xmlIcu.rootNodes.length == 0 ?
[] :
- ml.visitAll(this, xmlIcu.rootNodes);
+ [].concat(...ml.visitAll(this, xmlIcu.rootNodes));
return {
i18nNodes: i18nNodes,
@@ -276,7 +279,7 @@ class XmlToI18n implements ml.Visitor {
visitText(text: ml.Text, context: any) { return new i18n.Text(text.value, text.sourceSpan !); }
- visitElement(el: ml.Element, context: any): i18n.Placeholder|null {
+ visitElement(el: ml.Element, context: any): i18n.Placeholder|ml.Node[]|null {
if (el.name === _PLACEHOLDER_TAG) {
const nameAttr = el.attrs.find((attr) => attr.name === 'id');
if (nameAttr) {
@@ -284,9 +287,14 @@ class XmlToI18n implements ml.Visitor {
}
this._addError(el, `<${_PLACEHOLDER_TAG}> misses the "id" attribute`);
- } else {
- this._addError(el, `Unexpected tag`);
+ return null;
}
+
+ if (el.name === _MARKER_TAG) {
+ return [].concat(...ml.visitAll(this, el.children));
+ }
+
+ this._addError(el, `Unexpected tag`);
return null;
}
diff --git a/packages/compiler/src/i18n/serializers/xliff2.ts b/packages/compiler/src/i18n/serializers/xliff2.ts
index ea754b34fc..eac6612f5d 100644
--- a/packages/compiler/src/i18n/serializers/xliff2.ts
+++ b/packages/compiler/src/i18n/serializers/xliff2.ts
@@ -21,6 +21,7 @@ const _XMLNS = 'urn:oasis:names:tc:xliff:document:2.0';
const _DEFAULT_SOURCE_LANG = 'en';
const _PLACEHOLDER_TAG = 'ph';
const _PLACEHOLDER_SPANNING_TAG = 'pc';
+const _MARKER_TAG = 'mrk';
const _XLIFF_TAG = 'xliff';
const _SOURCE_TAG = 'source';
@@ -332,6 +333,8 @@ class XmlToI18n implements ml.Visitor {
new i18n.Placeholder('', endId, el.sourceSpan));
}
break;
+ case _MARKER_TAG:
+ return [].concat(...ml.visitAll(this, el.children));
default:
this._addError(el, `Unexpected tag`);
}
diff --git a/packages/compiler/test/i18n/serializers/xliff2_spec.ts b/packages/compiler/test/i18n/serializers/xliff2_spec.ts
index 937dcf0eb8..027bdc5bdc 100644
--- a/packages/compiler/test/i18n/serializers/xliff2_spec.ts
+++ b/packages/compiler/test/i18n/serializers/xliff2_spec.ts
@@ -238,6 +238,24 @@ lines
lignes
+
+
+ Please check the translation for 'namespace'. On also can use 'espace de nom',but I think most technical manuals use the English term.
+
+
+ You use your own namespace.
+ Vous pouvez utiliser votre propre namespace.
+
+
+
+
+ Please check the translation for 'namespace'. On also can use 'espace de nom',but I think most technical manuals use the English term.
+
+
+ You use your own namespace.
+ Vous pouvez utiliser votre propre namespace.
+
+
`;
@@ -289,7 +307,9 @@ lignes
'5229984852258993423': '{VAR_PLURAL, plural, =0 {[{VAR_SELECT, select, other {[, profondément imbriqué, ]}}, ]}, =other {[beaucoup]}}',
'2340165783990709777': `multi
-lignes`
+lignes`,
+ 'mrk-test': 'Vous pouvez utiliser votre propre namespace.',
+ 'mrk-test2': 'Vous pouvez utiliser votre propre namespace.'
});
});
diff --git a/packages/compiler/test/i18n/serializers/xliff_spec.ts b/packages/compiler/test/i18n/serializers/xliff_spec.ts
index 010bace00d..87c153b633 100644
--- a/packages/compiler/test/i18n/serializers/xliff_spec.ts
+++ b/packages/compiler/test/i18n/serializers/xliff_spec.ts
@@ -221,6 +221,20 @@ lignes
12
+
+ First sentence.
+
+ Should not be parsed
+
+ Translated first sentence.
+
+
+ First sentence. Second sentence.
+
+ Should not be parsed
+
+ Translated first sentence.
+