style(I18N): Carriage returns in serialized files

This commit is contained in:
Victor Berchet
2016-09-30 14:52:12 -07:00
committed by Chuck Jazdzewski
parent 756ef09d12
commit 65a60b7456
5 changed files with 68 additions and 60 deletions

View File

@ -21,47 +21,49 @@ const HTML = `
const WRITE_XLIFF = `<?xml version="1.0" encoding="UTF-8" ?>
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
<file source-language="en" datatype="plaintext" original="ng2.template">
<body>
<trans-unit id="983775b9a51ce14b036be72d4cfd65d68d64e231" datatype="html">
<source>translatable attribute</source>
<target/>
</trans-unit>
<trans-unit id="ec1d033f2436133c14ab038286c4f5df4697484a" datatype="html">
<source>translatable element <x id="START_BOLD_TEXT" ctype="b"/>with placeholders<x id="CLOSE_BOLD_TEXT" ctype="b"/> <x id="INTERPOLATION"/></source>
<target/>
</trans-unit>
<trans-unit id="db3e0a6a5a96481f60aec61d98c3eecddef5ac23" datatype="html">
<source>foo</source>
<target/>
<note priority="1" from="description">d</note>
<note priority="1" from="meaning">m</note>
</trans-unit>
</body>
</file>
</xliff>`;
<file source-language="en" datatype="plaintext" original="ng2.template">
<body>
<trans-unit id="983775b9a51ce14b036be72d4cfd65d68d64e231" datatype="html">
<source>translatable attribute</source>
<target/>
</trans-unit>
<trans-unit id="ec1d033f2436133c14ab038286c4f5df4697484a" datatype="html">
<source>translatable element <x id="START_BOLD_TEXT" ctype="b"/>with placeholders<x id="CLOSE_BOLD_TEXT" ctype="b"/> <x id="INTERPOLATION"/></source>
<target/>
</trans-unit>
<trans-unit id="db3e0a6a5a96481f60aec61d98c3eecddef5ac23" datatype="html">
<source>foo</source>
<target/>
<note priority="1" from="description">d</note>
<note priority="1" from="meaning">m</note>
</trans-unit>
</body>
</file>
</xliff>
`;
const LOAD_XLIFF = `<?xml version="1.0" encoding="UTF-8" ?>
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
<file source-language="en" datatype="plaintext" original="ng2.template">
<body>
<trans-unit id="983775b9a51ce14b036be72d4cfd65d68d64e231" datatype="html">
<source>translatable attribute</source>
<target>etubirtta elbatalsnart</target>
</trans-unit>
<trans-unit id="ec1d033f2436133c14ab038286c4f5df4697484a" datatype="html">
<source>translatable element <x id="START_BOLD_TEXT" ctype="b"/>with placeholders<x id="CLOSE_BOLD_TEXT" ctype="b"/> <x id="INTERPOLATION"/></source>
<target><x id="INTERPOLATION"/> footnemele elbatalsnart <x id="START_BOLD_TEXT" ctype="b"/>sredlohecalp htiw<x id="CLOSE_BOLD_TEXT" ctype="b"/></target>
</trans-unit>
<trans-unit id="db3e0a6a5a96481f60aec61d98c3eecddef5ac23" datatype="html">
<source>foo</source>
<target>oof</target>
<note priority="1" from="description">d</note>
<note priority="1" from="meaning">m</note>
</trans-unit>
</body>
</file>
</xliff>`;
<file source-language="en" datatype="plaintext" original="ng2.template">
<body>
<trans-unit id="983775b9a51ce14b036be72d4cfd65d68d64e231" datatype="html">
<source>translatable attribute</source>
<target>etubirtta elbatalsnart</target>
</trans-unit>
<trans-unit id="ec1d033f2436133c14ab038286c4f5df4697484a" datatype="html">
<source>translatable element <x id="START_BOLD_TEXT" ctype="b"/>with placeholders<x id="CLOSE_BOLD_TEXT" ctype="b"/> <x id="INTERPOLATION"/></source>
<target><x id="INTERPOLATION"/> footnemele elbatalsnart <x id="START_BOLD_TEXT" ctype="b"/>sredlohecalp htiw<x id="CLOSE_BOLD_TEXT" ctype="b"/></target>
</trans-unit>
<trans-unit id="db3e0a6a5a96481f60aec61d98c3eecddef5ac23" datatype="html">
<source>foo</source>
<target>oof</target>
<note priority="1" from="description">d</note>
<note priority="1" from="meaning">m</note>
</trans-unit>
</body>
</file>
</xliff>
`;
export function main(): void {
let serializer: Xliff;

View File

@ -6,12 +6,10 @@
* found in the LICENSE file at https://angular.io/license
*/
import {MessageBundle} from '@angular/compiler/src/i18n/message_bundle';
import {Xmb} from '@angular/compiler/src/i18n/serializers/xmb';
import {describe, expect, it} from '@angular/core/testing/testing_internal';
import {MessageBundle} from '../../../src/i18n/message_bundle';
import {HtmlParser} from '../../../src/ml_parser/html_parser';
import {DEFAULT_INTERPOLATION_CONFIG} from '../../../src/ml_parser/interpolation_config';
import {HtmlParser} from '@angular/compiler/src/ml_parser/html_parser';
import {DEFAULT_INTERPOLATION_CONFIG} from '@angular/compiler/src/ml_parser/interpolation_config';
export function main(): void {
describe('XMB serializer', () => {
@ -49,7 +47,8 @@ export function main(): void {
<msg id="e2ccf3d131b15f54aa1fcf1314b1ca77c14bfcc2">{ count, plural, =0 {<ph name="START_PARAGRAPH"><ex>&lt;p&gt;</ex></ph>test<ph name="CLOSE_PARAGRAPH"><ex>&lt;/p&gt;</ex></ph>} }</msg>
<msg id="db3e0a6a5a96481f60aec61d98c3eecddef5ac23" desc="d" meaning="m">foo</msg>
<msg id="83dd87699b8c1779dd72277ef6e2d46ca58be042">{ count, plural, =0 {{ sex, gender, other {<ph name="START_PARAGRAPH"><ex>&lt;p&gt;</ex></ph>deeply nested<ph name="CLOSE_PARAGRAPH"><ex>&lt;/p&gt;</ex></ph>} } } }</msg>
</messagebundle>`;
</messagebundle>
`;
it('should write a valid xmb file', () => { expect(toXmb(HTML)).toEqual(XMB); });