1 | /**
|
---|
2 | * @license
|
---|
3 | * Copyright Google LLC All Rights Reserved.
|
---|
4 | *
|
---|
5 | * Use of this source code is governed by an MIT-style license that can be
|
---|
6 | * found in the LICENSE file at https://angular.io/license
|
---|
7 | */
|
---|
8 | import * as ml from '../../ml_parser/ast';
|
---|
9 | import { XmlParser } from '../../ml_parser/xml_parser';
|
---|
10 | import { decimalDigest } from '../digest';
|
---|
11 | import * as i18n from '../i18n_ast';
|
---|
12 | import { I18nError } from '../parse_util';
|
---|
13 | import { Serializer } from './serializer';
|
---|
14 | import * as xml from './xml_helper';
|
---|
15 | const _VERSION = '2.0';
|
---|
16 | const _XMLNS = 'urn:oasis:names:tc:xliff:document:2.0';
|
---|
17 | // TODO(vicb): make this a param (s/_/-/)
|
---|
18 | const _DEFAULT_SOURCE_LANG = 'en';
|
---|
19 | const _PLACEHOLDER_TAG = 'ph';
|
---|
20 | const _PLACEHOLDER_SPANNING_TAG = 'pc';
|
---|
21 | const _MARKER_TAG = 'mrk';
|
---|
22 | const _XLIFF_TAG = 'xliff';
|
---|
23 | const _SOURCE_TAG = 'source';
|
---|
24 | const _TARGET_TAG = 'target';
|
---|
25 | const _UNIT_TAG = 'unit';
|
---|
26 | // https://docs.oasis-open.org/xliff/xliff-core/v2.0/os/xliff-core-v2.0-os.html
|
---|
27 | export class Xliff2 extends Serializer {
|
---|
28 | write(messages, locale) {
|
---|
29 | const visitor = new _WriteVisitor();
|
---|
30 | const units = [];
|
---|
31 | messages.forEach(message => {
|
---|
32 | const unit = new xml.Tag(_UNIT_TAG, { id: message.id });
|
---|
33 | const notes = new xml.Tag('notes');
|
---|
34 | if (message.description || message.meaning) {
|
---|
35 | if (message.description) {
|
---|
36 | notes.children.push(new xml.CR(8), new xml.Tag('note', { category: 'description' }, [new xml.Text(message.description)]));
|
---|
37 | }
|
---|
38 | if (message.meaning) {
|
---|
39 | notes.children.push(new xml.CR(8), new xml.Tag('note', { category: 'meaning' }, [new xml.Text(message.meaning)]));
|
---|
40 | }
|
---|
41 | }
|
---|
42 | message.sources.forEach((source) => {
|
---|
43 | notes.children.push(new xml.CR(8), new xml.Tag('note', { category: 'location' }, [
|
---|
44 | new xml.Text(`${source.filePath}:${source.startLine}${source.endLine !== source.startLine ? ',' + source.endLine : ''}`)
|
---|
45 | ]));
|
---|
46 | });
|
---|
47 | notes.children.push(new xml.CR(6));
|
---|
48 | unit.children.push(new xml.CR(6), notes);
|
---|
49 | const segment = new xml.Tag('segment');
|
---|
50 | segment.children.push(new xml.CR(8), new xml.Tag(_SOURCE_TAG, {}, visitor.serialize(message.nodes)), new xml.CR(6));
|
---|
51 | unit.children.push(new xml.CR(6), segment, new xml.CR(4));
|
---|
52 | units.push(new xml.CR(4), unit);
|
---|
53 | });
|
---|
54 | const file = new xml.Tag('file', { 'original': 'ng.template', id: 'ngi18n' }, [...units, new xml.CR(2)]);
|
---|
55 | const xliff = new xml.Tag(_XLIFF_TAG, { version: _VERSION, xmlns: _XMLNS, srcLang: locale || _DEFAULT_SOURCE_LANG }, [new xml.CR(2), file, new xml.CR()]);
|
---|
56 | return xml.serialize([
|
---|
57 | new xml.Declaration({ version: '1.0', encoding: 'UTF-8' }), new xml.CR(), xliff, new xml.CR()
|
---|
58 | ]);
|
---|
59 | }
|
---|
60 | load(content, url) {
|
---|
61 | // xliff to xml nodes
|
---|
62 | const xliff2Parser = new Xliff2Parser();
|
---|
63 | const { locale, msgIdToHtml, errors } = xliff2Parser.parse(content, url);
|
---|
64 | // xml nodes to i18n nodes
|
---|
65 | const i18nNodesByMsgId = {};
|
---|
66 | const converter = new XmlToI18n();
|
---|
67 | Object.keys(msgIdToHtml).forEach(msgId => {
|
---|
68 | const { i18nNodes, errors: e } = converter.convert(msgIdToHtml[msgId], url);
|
---|
69 | errors.push(...e);
|
---|
70 | i18nNodesByMsgId[msgId] = i18nNodes;
|
---|
71 | });
|
---|
72 | if (errors.length) {
|
---|
73 | throw new Error(`xliff2 parse errors:\n${errors.join('\n')}`);
|
---|
74 | }
|
---|
75 | return { locale: locale, i18nNodesByMsgId };
|
---|
76 | }
|
---|
77 | digest(message) {
|
---|
78 | return decimalDigest(message);
|
---|
79 | }
|
---|
80 | }
|
---|
81 | class _WriteVisitor {
|
---|
82 | visitText(text, context) {
|
---|
83 | return [new xml.Text(text.value)];
|
---|
84 | }
|
---|
85 | visitContainer(container, context) {
|
---|
86 | const nodes = [];
|
---|
87 | container.children.forEach((node) => nodes.push(...node.visit(this)));
|
---|
88 | return nodes;
|
---|
89 | }
|
---|
90 | visitIcu(icu, context) {
|
---|
91 | const nodes = [new xml.Text(`{${icu.expressionPlaceholder}, ${icu.type}, `)];
|
---|
92 | Object.keys(icu.cases).forEach((c) => {
|
---|
93 | nodes.push(new xml.Text(`${c} {`), ...icu.cases[c].visit(this), new xml.Text(`} `));
|
---|
94 | });
|
---|
95 | nodes.push(new xml.Text(`}`));
|
---|
96 | return nodes;
|
---|
97 | }
|
---|
98 | visitTagPlaceholder(ph, context) {
|
---|
99 | const type = getTypeForTag(ph.tag);
|
---|
100 | if (ph.isVoid) {
|
---|
101 | const tagPh = new xml.Tag(_PLACEHOLDER_TAG, {
|
---|
102 | id: (this._nextPlaceholderId++).toString(),
|
---|
103 | equiv: ph.startName,
|
---|
104 | type: type,
|
---|
105 | disp: `<${ph.tag}/>`,
|
---|
106 | });
|
---|
107 | return [tagPh];
|
---|
108 | }
|
---|
109 | const tagPc = new xml.Tag(_PLACEHOLDER_SPANNING_TAG, {
|
---|
110 | id: (this._nextPlaceholderId++).toString(),
|
---|
111 | equivStart: ph.startName,
|
---|
112 | equivEnd: ph.closeName,
|
---|
113 | type: type,
|
---|
114 | dispStart: `<${ph.tag}>`,
|
---|
115 | dispEnd: `</${ph.tag}>`,
|
---|
116 | });
|
---|
117 | const nodes = [].concat(...ph.children.map(node => node.visit(this)));
|
---|
118 | if (nodes.length) {
|
---|
119 | nodes.forEach((node) => tagPc.children.push(node));
|
---|
120 | }
|
---|
121 | else {
|
---|
122 | tagPc.children.push(new xml.Text(''));
|
---|
123 | }
|
---|
124 | return [tagPc];
|
---|
125 | }
|
---|
126 | visitPlaceholder(ph, context) {
|
---|
127 | const idStr = (this._nextPlaceholderId++).toString();
|
---|
128 | return [new xml.Tag(_PLACEHOLDER_TAG, {
|
---|
129 | id: idStr,
|
---|
130 | equiv: ph.name,
|
---|
131 | disp: `{{${ph.value}}}`,
|
---|
132 | })];
|
---|
133 | }
|
---|
134 | visitIcuPlaceholder(ph, context) {
|
---|
135 | const cases = Object.keys(ph.value.cases).map((value) => value + ' {...}').join(' ');
|
---|
136 | const idStr = (this._nextPlaceholderId++).toString();
|
---|
137 | return [new xml.Tag(_PLACEHOLDER_TAG, { id: idStr, equiv: ph.name, disp: `{${ph.value.expression}, ${ph.value.type}, ${cases}}` })];
|
---|
138 | }
|
---|
139 | serialize(nodes) {
|
---|
140 | this._nextPlaceholderId = 0;
|
---|
141 | return [].concat(...nodes.map(node => node.visit(this)));
|
---|
142 | }
|
---|
143 | }
|
---|
144 | // Extract messages as xml nodes from the xliff file
|
---|
145 | class Xliff2Parser {
|
---|
146 | constructor() {
|
---|
147 | this._locale = null;
|
---|
148 | }
|
---|
149 | parse(xliff, url) {
|
---|
150 | this._unitMlString = null;
|
---|
151 | this._msgIdToHtml = {};
|
---|
152 | const xml = new XmlParser().parse(xliff, url);
|
---|
153 | this._errors = xml.errors;
|
---|
154 | ml.visitAll(this, xml.rootNodes, null);
|
---|
155 | return {
|
---|
156 | msgIdToHtml: this._msgIdToHtml,
|
---|
157 | errors: this._errors,
|
---|
158 | locale: this._locale,
|
---|
159 | };
|
---|
160 | }
|
---|
161 | visitElement(element, context) {
|
---|
162 | switch (element.name) {
|
---|
163 | case _UNIT_TAG:
|
---|
164 | this._unitMlString = null;
|
---|
165 | const idAttr = element.attrs.find((attr) => attr.name === 'id');
|
---|
166 | if (!idAttr) {
|
---|
167 | this._addError(element, `<${_UNIT_TAG}> misses the "id" attribute`);
|
---|
168 | }
|
---|
169 | else {
|
---|
170 | const id = idAttr.value;
|
---|
171 | if (this._msgIdToHtml.hasOwnProperty(id)) {
|
---|
172 | this._addError(element, `Duplicated translations for msg ${id}`);
|
---|
173 | }
|
---|
174 | else {
|
---|
175 | ml.visitAll(this, element.children, null);
|
---|
176 | if (typeof this._unitMlString === 'string') {
|
---|
177 | this._msgIdToHtml[id] = this._unitMlString;
|
---|
178 | }
|
---|
179 | else {
|
---|
180 | this._addError(element, `Message ${id} misses a translation`);
|
---|
181 | }
|
---|
182 | }
|
---|
183 | }
|
---|
184 | break;
|
---|
185 | case _SOURCE_TAG:
|
---|
186 | // ignore source message
|
---|
187 | break;
|
---|
188 | case _TARGET_TAG:
|
---|
189 | const innerTextStart = element.startSourceSpan.end.offset;
|
---|
190 | const innerTextEnd = element.endSourceSpan.start.offset;
|
---|
191 | const content = element.startSourceSpan.start.file.content;
|
---|
192 | const innerText = content.slice(innerTextStart, innerTextEnd);
|
---|
193 | this._unitMlString = innerText;
|
---|
194 | break;
|
---|
195 | case _XLIFF_TAG:
|
---|
196 | const localeAttr = element.attrs.find((attr) => attr.name === 'trgLang');
|
---|
197 | if (localeAttr) {
|
---|
198 | this._locale = localeAttr.value;
|
---|
199 | }
|
---|
200 | const versionAttr = element.attrs.find((attr) => attr.name === 'version');
|
---|
201 | if (versionAttr) {
|
---|
202 | const version = versionAttr.value;
|
---|
203 | if (version !== '2.0') {
|
---|
204 | this._addError(element, `The XLIFF file version ${version} is not compatible with XLIFF 2.0 serializer`);
|
---|
205 | }
|
---|
206 | else {
|
---|
207 | ml.visitAll(this, element.children, null);
|
---|
208 | }
|
---|
209 | }
|
---|
210 | break;
|
---|
211 | default:
|
---|
212 | ml.visitAll(this, element.children, null);
|
---|
213 | }
|
---|
214 | }
|
---|
215 | visitAttribute(attribute, context) { }
|
---|
216 | visitText(text, context) { }
|
---|
217 | visitComment(comment, context) { }
|
---|
218 | visitExpansion(expansion, context) { }
|
---|
219 | visitExpansionCase(expansionCase, context) { }
|
---|
220 | _addError(node, message) {
|
---|
221 | this._errors.push(new I18nError(node.sourceSpan, message));
|
---|
222 | }
|
---|
223 | }
|
---|
224 | // Convert ml nodes (xliff syntax) to i18n nodes
|
---|
225 | class XmlToI18n {
|
---|
226 | convert(message, url) {
|
---|
227 | const xmlIcu = new XmlParser().parse(message, url, { tokenizeExpansionForms: true });
|
---|
228 | this._errors = xmlIcu.errors;
|
---|
229 | const i18nNodes = this._errors.length > 0 || xmlIcu.rootNodes.length == 0 ?
|
---|
230 | [] :
|
---|
231 | [].concat(...ml.visitAll(this, xmlIcu.rootNodes));
|
---|
232 | return {
|
---|
233 | i18nNodes,
|
---|
234 | errors: this._errors,
|
---|
235 | };
|
---|
236 | }
|
---|
237 | visitText(text, context) {
|
---|
238 | return new i18n.Text(text.value, text.sourceSpan);
|
---|
239 | }
|
---|
240 | visitElement(el, context) {
|
---|
241 | switch (el.name) {
|
---|
242 | case _PLACEHOLDER_TAG:
|
---|
243 | const nameAttr = el.attrs.find((attr) => attr.name === 'equiv');
|
---|
244 | if (nameAttr) {
|
---|
245 | return [new i18n.Placeholder('', nameAttr.value, el.sourceSpan)];
|
---|
246 | }
|
---|
247 | this._addError(el, `<${_PLACEHOLDER_TAG}> misses the "equiv" attribute`);
|
---|
248 | break;
|
---|
249 | case _PLACEHOLDER_SPANNING_TAG:
|
---|
250 | const startAttr = el.attrs.find((attr) => attr.name === 'equivStart');
|
---|
251 | const endAttr = el.attrs.find((attr) => attr.name === 'equivEnd');
|
---|
252 | if (!startAttr) {
|
---|
253 | this._addError(el, `<${_PLACEHOLDER_TAG}> misses the "equivStart" attribute`);
|
---|
254 | }
|
---|
255 | else if (!endAttr) {
|
---|
256 | this._addError(el, `<${_PLACEHOLDER_TAG}> misses the "equivEnd" attribute`);
|
---|
257 | }
|
---|
258 | else {
|
---|
259 | const startId = startAttr.value;
|
---|
260 | const endId = endAttr.value;
|
---|
261 | const nodes = [];
|
---|
262 | return nodes.concat(new i18n.Placeholder('', startId, el.sourceSpan), ...el.children.map(node => node.visit(this, null)), new i18n.Placeholder('', endId, el.sourceSpan));
|
---|
263 | }
|
---|
264 | break;
|
---|
265 | case _MARKER_TAG:
|
---|
266 | return [].concat(...ml.visitAll(this, el.children));
|
---|
267 | default:
|
---|
268 | this._addError(el, `Unexpected tag`);
|
---|
269 | }
|
---|
270 | return null;
|
---|
271 | }
|
---|
272 | visitExpansion(icu, context) {
|
---|
273 | const caseMap = {};
|
---|
274 | ml.visitAll(this, icu.cases).forEach((c) => {
|
---|
275 | caseMap[c.value] = new i18n.Container(c.nodes, icu.sourceSpan);
|
---|
276 | });
|
---|
277 | return new i18n.Icu(icu.switchValue, icu.type, caseMap, icu.sourceSpan);
|
---|
278 | }
|
---|
279 | visitExpansionCase(icuCase, context) {
|
---|
280 | return {
|
---|
281 | value: icuCase.value,
|
---|
282 | nodes: [].concat(...ml.visitAll(this, icuCase.expression)),
|
---|
283 | };
|
---|
284 | }
|
---|
285 | visitComment(comment, context) { }
|
---|
286 | visitAttribute(attribute, context) { }
|
---|
287 | _addError(node, message) {
|
---|
288 | this._errors.push(new I18nError(node.sourceSpan, message));
|
---|
289 | }
|
---|
290 | }
|
---|
291 | function getTypeForTag(tag) {
|
---|
292 | switch (tag.toLowerCase()) {
|
---|
293 | case 'br':
|
---|
294 | case 'b':
|
---|
295 | case 'i':
|
---|
296 | case 'u':
|
---|
297 | return 'fmt';
|
---|
298 | case 'img':
|
---|
299 | return 'image';
|
---|
300 | case 'a':
|
---|
301 | return 'link';
|
---|
302 | default:
|
---|
303 | return 'other';
|
---|
304 | }
|
---|
305 | }
|
---|
306 | //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoieGxpZmYyLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vLi4vLi4vLi4vcGFja2FnZXMvY29tcGlsZXIvc3JjL2kxOG4vc2VyaWFsaXplcnMveGxpZmYyLnRzIl0sIm5hbWVzIjpbXSwibWFwcG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UF0dHIudmFsdWU7XG4gICAgICAgIH1cblxuICAgICAgICBjb25zdCB2ZXJzaW9uQXR0ciA9IGVsZW1lbnQuYXR0cnMuZmluZCgoYXR0cikgPT4gYXR0ci5uYW1lID09PSAndmVyc2lvbicpO1xuICAgICAgICBpZiAodmVyc2lvbkF0dHIpIHtcbiAgICAgICAgICBjb25zdCB2ZXJzaW9uID0gdmVyc2lvbkF0dHIudmFsdWU7XG4gICAgICAgICAgaWYgKHZlcnNpb24gIT09ICcyLjAnKSB7XG4gICAgICAgICAgICB0aGlzLl9hZGRFcnJvcihcbiAgICAgICAgICAgICAgICBlbGVtZW50LFxuICAgICAgICAgICAgICAgIGBUaGUgWExJRkYgZmlsZSB2ZXJzaW9uICR7dmVyc2lvbn0gaXMgbm90IGNvbXBhdGlibGUgd2l0aCBYTElGRiAyLjAgc2VyaWFsaXplcmApO1xuICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICBtbC52aXNpdEFsbCh0aGlzLCBlbGVtZW50LmNoaWxkcmVuLCBudWxsKTtcbiAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgICAgYnJlYWs7XG4gICAgICBkZWZhdWx0OlxuICAgICAgICBtbC52aXNpdEFsbCh0aGlzLCBlbGVtZW50LmNoaWxkcmVuLCBudWxsKTtcbiAgICB9XG4gIH1cblxuICB2aXNpdEF0dHJpYnV0ZShhdHRyaWJ1dGU6IG1sLkF0dHJpYnV0ZSwgY29udGV4dDogYW55KTogYW55IHt9XG5cbiAgdmlzaXRUZXh0KHRleHQ6IG1sLlRleHQsIGNvbnRleHQ6IGFueSk6IGFueSB7fVxuXG4gIHZpc2l0Q29tbWVudChjb21tZW50OiBtbC5Db21tZW50LCBjb250ZXh0OiBhbnkpOiBhbnkge31cblxuICB2aXNpdEV4cGFuc2lvbihleHBhbnNpb246IG1sLkV4cGFuc2lvbiwgY29udGV4dDogYW55KTogYW55IHt9XG5cbiAgdmlzaXRFeHBhbnNpb25DYXNlKGV4cGFuc2l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