Skip to content

Commit a97c3d8

Browse files
committed
Include <xliff> element in XLIFF output
I was creating this, but forgot to actually use it. It's the top-level element for an XLIFF file.
1 parent 5cc9c77 commit a97c3d8

File tree

4 files changed

+89
-74
lines changed

4 files changed

+89
-74
lines changed

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8-
<!-- ## Unreleased -->
8+
## Unreleased
9+
10+
- Fix missing `<xliff>` element in XLIFF output.
911

1012
## [0.2.2] - 2020-05-13
1113

src/formatters/xliff.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,10 +200,11 @@ export class XliffFormatter implements Formatter {
200200
'xsi:schemaLocation',
201201
'urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-strict.xsd'
202202
);
203+
doc.appendChild(xliff);
203204

204205
// https://docs.oasis-open.org/xliff/v1.2/os/xliff-core.html#file
205206
const file = doc.createElement('file');
206-
doc.appendChild(file);
207+
xliff.appendChild(file);
207208
// TODO The spec requires the source filename in the "original" attribute,
208209
// but we don't currently track filenames.
209210
file.setAttribute('original', 'lit-localize-inputs');
Lines changed: 46 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,47 @@
11
<?xml version="1.0" encoding="UTF-8" ?>
2-
<file
3-
original="lit-localize-inputs"
4-
datatype="plaintext"
5-
source-language="en"
6-
target-language="es-419"
2+
<xliff
3+
version="1.2"
4+
xmlns="http://www.w3.org/2001/XMLSchema-instance"
5+
xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-strict.xsd"
76
>
8-
<body>
9-
<trans-unit id="string">
10-
<source>Hello World!</source>
11-
<target>Hola Mundo!</target>
12-
</trans-unit>
13-
<trans-unit id="lit">
14-
<source>Hello <ph id="0">&lt;b>&lt;i></ph>World!<ph
15-
id="1"
16-
>&lt;/i>&lt;/b></ph></source>
17-
<target>Hola <ph id="0">&lt;b>&lt;i></ph>Mundo!<ph
18-
id="1"
19-
>&lt;/i>&lt;/b></ph></target>
20-
</trans-unit>
21-
<trans-unit id="variables_1">
22-
<source>Hello <ph id="0">${name}</ph>!</source>
23-
<target>Hola <ph id="0">${name}</ph>!</target>
24-
</trans-unit>
25-
<trans-unit id="lit_variables_1">
26-
<source>Hello <ph id="0">${name}</ph>, click <ph
27-
id="1"
28-
>&lt;a href="${url}"></ph>here<ph id="2">&lt;/a></ph>!</source>
29-
<target>Hola <ph id="0">${name}</ph>, clic <ph
30-
id="1"
31-
>&lt;a href="${url}"></ph>aquí<ph id="2">&lt;/a></ph>!</target>
32-
</trans-unit>
33-
<trans-unit id="lit_variables_2">
34-
<source><ph id="0">${x}</ph>y<ph id="1">${x}</ph>y<ph
35-
id="2"
36-
>${x}</ph></source>
37-
</trans-unit>
38-
<trans-unit id="lit_variables_3">
39-
<source><ph id="0">&lt;b>
7+
<file
8+
original="lit-localize-inputs"
9+
datatype="plaintext"
10+
source-language="en"
11+
target-language="es-419"
12+
>
13+
<body>
14+
<trans-unit id="string">
15+
<source>Hello World!</source>
16+
<target>Hola Mundo!</target>
17+
</trans-unit>
18+
<trans-unit id="lit">
19+
<source>Hello <ph id="0">&lt;b>&lt;i></ph>World!<ph
20+
id="1"
21+
>&lt;/i>&lt;/b></ph></source>
22+
<target>Hola <ph id="0">&lt;b>&lt;i></ph>Mundo!<ph
23+
id="1"
24+
>&lt;/i>&lt;/b></ph></target>
25+
</trans-unit>
26+
<trans-unit id="variables_1">
27+
<source>Hello <ph id="0">${name}</ph>!</source>
28+
<target>Hola <ph id="0">${name}</ph>!</target>
29+
</trans-unit>
30+
<trans-unit id="lit_variables_1">
31+
<source>Hello <ph id="0">${name}</ph>, click <ph
32+
id="1"
33+
>&lt;a href="${url}"></ph>here<ph id="2">&lt;/a></ph>!</source>
34+
<target>Hola <ph id="0">${name}</ph>, clic <ph
35+
id="1"
36+
>&lt;a href="${url}"></ph>aquí<ph id="2">&lt;/a></ph>!</target>
37+
</trans-unit>
38+
<trans-unit id="lit_variables_2">
39+
<source><ph id="0">${x}</ph>y<ph id="1">${x}</ph>y<ph
40+
id="2"
41+
>${x}</ph></source>
42+
</trans-unit>
43+
<trans-unit id="lit_variables_3">
44+
<source><ph id="0">&lt;b>
4045
${x}
4146
&lt;/b>
4247
&lt;i></ph>
@@ -51,6 +56,7 @@
5156
&lt;b>
5257
${x}
5358
&lt;/b></ph></source>
54-
</trans-unit>
55-
</body>
56-
</file>
59+
</trans-unit>
60+
</body>
61+
</file>
62+
</xliff>
Lines changed: 38 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,39 @@
11
<?xml version="1.0" encoding="UTF-8" ?>
2-
<file
3-
original="lit-localize-inputs"
4-
datatype="plaintext"
5-
source-language="en"
6-
target-language="zh_CN"
2+
<xliff
3+
version="1.2"
4+
xmlns="http://www.w3.org/2001/XMLSchema-instance"
5+
xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-strict.xsd"
76
>
8-
<body>
9-
<trans-unit id="string">
10-
<source>Hello World!</source>
11-
</trans-unit>
12-
<trans-unit id="lit">
13-
<source>Hello <ph id="0">&lt;b>&lt;i></ph>World!<ph
14-
id="1"
15-
>&lt;/i>&lt;/b></ph></source>
16-
</trans-unit>
17-
<trans-unit id="variables_1">
18-
<source>Hello <ph id="0">${name}</ph>!</source>
19-
</trans-unit>
20-
<trans-unit id="lit_variables_1">
21-
<source>Hello <ph id="0">${name}</ph>, click <ph
22-
id="1"
23-
>&lt;a href="${url}"></ph>here<ph id="2">&lt;/a></ph>!</source>
24-
</trans-unit>
25-
<trans-unit id="lit_variables_2">
26-
<source><ph id="0">${x}</ph>y<ph id="1">${x}</ph>y<ph
27-
id="2"
28-
>${x}</ph></source>
29-
</trans-unit>
30-
<trans-unit id="lit_variables_3">
31-
<source><ph id="0">&lt;b>
7+
<file
8+
original="lit-localize-inputs"
9+
datatype="plaintext"
10+
source-language="en"
11+
target-language="zh_CN"
12+
>
13+
<body>
14+
<trans-unit id="string">
15+
<source>Hello World!</source>
16+
</trans-unit>
17+
<trans-unit id="lit">
18+
<source>Hello <ph id="0">&lt;b>&lt;i></ph>World!<ph
19+
id="1"
20+
>&lt;/i>&lt;/b></ph></source>
21+
</trans-unit>
22+
<trans-unit id="variables_1">
23+
<source>Hello <ph id="0">${name}</ph>!</source>
24+
</trans-unit>
25+
<trans-unit id="lit_variables_1">
26+
<source>Hello <ph id="0">${name}</ph>, click <ph
27+
id="1"
28+
>&lt;a href="${url}"></ph>here<ph id="2">&lt;/a></ph>!</source>
29+
</trans-unit>
30+
<trans-unit id="lit_variables_2">
31+
<source><ph id="0">${x}</ph>y<ph id="1">${x}</ph>y<ph
32+
id="2"
33+
>${x}</ph></source>
34+
</trans-unit>
35+
<trans-unit id="lit_variables_3">
36+
<source><ph id="0">&lt;b>
3237
${x}
3338
&lt;/b>
3439
&lt;i></ph>
@@ -43,6 +48,7 @@
4348
&lt;b>
4449
${x}
4550
&lt;/b></ph></source>
46-
</trans-unit>
47-
</body>
48-
</file>
51+
</trans-unit>
52+
</body>
53+
</file>
54+
</xliff>

0 commit comments

Comments
 (0)