diff --git a/integration/ivy-i18n/scripts/update-xlf-translation-file.js b/integration/ivy-i18n/scripts/update-xlf-translation-file.js index 79a0001a3b4bb..10e778a0b697b 100644 --- a/integration/ivy-i18n/scripts/update-xlf-translation-file.js +++ b/integration/ivy-i18n/scripts/update-xlf-translation-file.js @@ -14,7 +14,7 @@ fs.writeFileSync(filePath + '.bak', contents, 'utf8'); // Write translated file const updated = - contents.replace(/source>/g, 'target>') + contents.replace(/<(\/)?source([^>]*)>/g, '<$1target$2>') .replace(/Hello/g, 'Bonjour') .replace(/source-language="([^"]+)"/g, 'source-language="$1" target-language="legacy"'); fs.writeFileSync(filePath, updated, 'utf8'); diff --git a/packages/localize/src/tools/src/extract/translation_files/xliff1_translation_serializer.ts b/packages/localize/src/tools/src/extract/translation_files/xliff1_translation_serializer.ts index c44f8f9d21315..d84823454a6ed 100644 --- a/packages/localize/src/tools/src/extract/translation_files/xliff1_translation_serializer.ts +++ b/packages/localize/src/tools/src/extract/translation_files/xliff1_translation_serializer.ts @@ -54,7 +54,7 @@ export class Xliff1TranslationSerializer implements TranslationSerializer { ids.add(id); xml.startTag('trans-unit', {id, datatype: 'html'}); - xml.startTag('source', {}, {preserveWhitespace: true}); + xml.startTag('source', {'xml:space': 'preserve'}, {preserveWhitespace: true}); this.serializeMessage(xml, message); xml.endTag('source', {preserveWhitespace: false}); if (message.location) { diff --git a/packages/localize/src/tools/src/extract/translation_files/xliff2_translation_serializer.ts b/packages/localize/src/tools/src/extract/translation_files/xliff2_translation_serializer.ts index 4dd7e4f4a2824..2351b2d4f82b1 100644 --- a/packages/localize/src/tools/src/extract/translation_files/xliff2_translation_serializer.ts +++ b/packages/localize/src/tools/src/extract/translation_files/xliff2_translation_serializer.ts @@ -70,7 +70,7 @@ export class Xliff2TranslationSerializer implements TranslationSerializer { xml.endTag('notes'); } xml.startTag('segment'); - xml.startTag('source', {}, {preserveWhitespace: true}); + xml.startTag('source', {'xml:space': 'preserve'}, {preserveWhitespace: true}); this.serializeMessage(xml, message); xml.endTag('source', {preserveWhitespace: false}); xml.endTag('segment'); diff --git a/packages/localize/src/tools/test/extract/translation_files/xliff1_translation_serializer_spec.ts b/packages/localize/src/tools/test/extract/translation_files/xliff1_translation_serializer_spec.ts index f421850a3270e..55ee27f6e8cf2 100644 --- a/packages/localize/src/tools/test/extract/translation_files/xliff1_translation_serializer_spec.ts +++ b/packages/localize/src/tools/test/extract/translation_files/xliff1_translation_serializer_spec.ts @@ -77,7 +77,7 @@ runInEachFileSystem(() => { ` `, - ` abc`, + ` abc`, ` `, ` file.ts`, ` 6`, @@ -85,32 +85,32 @@ runInEachFileSystem(() => { ` some meaning`, ` `, ` `, - ` abc`, + ` abc`, ` `, ` `, - ` ac`, + ` ac`, ` some description`, ` `, ` `, - ` b`, + ` b`, ` `, ` `, - ` a`, + ` a`, ` and description`, ` meaning`, ` `, ` `, - ` multi`, + ` multi`, `lines`, ` `, ` `, - ` <escapeme>`, + ` <escapeme>`, ` `, ` `, - ` pre-ICU {VAR_SELECT, select, a {a} b {} c {pre post}} post-ICU`, + ` pre-ICU {VAR_SELECT, select, a {a} b {} c {pre post}} post-ICU`, ` `, ` `, - ` {VAR_PLURAL, plural, one {something bold} other {pre middle post}}`, + ` {VAR_PLURAL, plural, one {something bold} other {pre middle post}}`, ` `, ` `, ` `, diff --git a/packages/localize/src/tools/test/extract/translation_files/xliff2_translation_serializer_spec.ts b/packages/localize/src/tools/test/extract/translation_files/xliff2_translation_serializer_spec.ts index d783e0ce9f914..f15fc87dd429f 100644 --- a/packages/localize/src/tools/test/extract/translation_files/xliff2_translation_serializer_spec.ts +++ b/packages/localize/src/tools/test/extract/translation_files/xliff2_translation_serializer_spec.ts @@ -84,12 +84,12 @@ runInEachFileSystem(() => { ` some meaning`, ` `, ` `, - ` abc`, + ` abc`, ` `, ` `, ` `, ` `, - ` abc`, + ` abc`, ` `, ` `, ` `, @@ -98,12 +98,12 @@ runInEachFileSystem(() => { ` some description`, ` `, ` `, - ` ac`, + ` ac`, ` `, ` `, ` `, ` `, - ` b`, + ` b`, ` `, ` `, ` `, @@ -112,28 +112,28 @@ runInEachFileSystem(() => { ` meaning`, ` `, ` `, - ` a`, + ` a`, ` `, ` `, ` `, ` `, - ` multi`, + ` multi`, `lines`, ` `, ` `, ` `, ` `, - ` <escapeme>`, + ` <escapeme>`, ` `, ` `, ` `, ` `, - ` pre-ICU {VAR_SELECT, select, a {a} b {} c {pre post}} post-ICU`, + ` pre-ICU {VAR_SELECT, select, a {a} b {} c {pre post}} post-ICU`, ` `, ` `, ` `, ` `, - ` {VAR_PLURAL, plural, one {something bold} other {pre middle post}}`, + ` {VAR_PLURAL, plural, one {something bold} other {pre middle post}}`, ` `, ` `, ` `,