source: trip-planner-front/node_modules/@angular/compiler/esm2015/src/i18n/serializers/xmb.js

Last change on this file was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 22.9 KB
Line 
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 */
8import { decimalDigest } from '../digest';
9import { Serializer, SimplePlaceholderMapper } from './serializer';
10import * as xml from './xml_helper';
11const _MESSAGES_TAG = 'messagebundle';
12const _MESSAGE_TAG = 'msg';
13const _PLACEHOLDER_TAG = 'ph';
14const _EXAMPLE_TAG = 'ex';
15const _SOURCE_TAG = 'source';
16const _DOCTYPE = `<!ELEMENT messagebundle (msg)*>
17<!ATTLIST messagebundle class CDATA #IMPLIED>
18
19<!ELEMENT msg (#PCDATA|ph|source)*>
20<!ATTLIST msg id CDATA #IMPLIED>
21<!ATTLIST msg seq CDATA #IMPLIED>
22<!ATTLIST msg name CDATA #IMPLIED>
23<!ATTLIST msg desc CDATA #IMPLIED>
24<!ATTLIST msg meaning CDATA #IMPLIED>
25<!ATTLIST msg obsolete (obsolete) #IMPLIED>
26<!ATTLIST msg xml:space (default|preserve) "default">
27<!ATTLIST msg is_hidden CDATA #IMPLIED>
28
29<!ELEMENT source (#PCDATA)>
30
31<!ELEMENT ph (#PCDATA|ex)*>
32<!ATTLIST ph name CDATA #REQUIRED>
33
34<!ELEMENT ex (#PCDATA)>`;
35export class Xmb extends Serializer {
36 write(messages, locale) {
37 const exampleVisitor = new ExampleVisitor();
38 const visitor = new _Visitor();
39 let rootNode = new xml.Tag(_MESSAGES_TAG);
40 messages.forEach(message => {
41 const attrs = { id: message.id };
42 if (message.description) {
43 attrs['desc'] = message.description;
44 }
45 if (message.meaning) {
46 attrs['meaning'] = message.meaning;
47 }
48 let sourceTags = [];
49 message.sources.forEach((source) => {
50 sourceTags.push(new xml.Tag(_SOURCE_TAG, {}, [new xml.Text(`${source.filePath}:${source.startLine}${source.endLine !== source.startLine ? ',' + source.endLine : ''}`)]));
51 });
52 rootNode.children.push(new xml.CR(2), new xml.Tag(_MESSAGE_TAG, attrs, [...sourceTags, ...visitor.serialize(message.nodes)]));
53 });
54 rootNode.children.push(new xml.CR());
55 return xml.serialize([
56 new xml.Declaration({ version: '1.0', encoding: 'UTF-8' }),
57 new xml.CR(),
58 new xml.Doctype(_MESSAGES_TAG, _DOCTYPE),
59 new xml.CR(),
60 exampleVisitor.addDefaultExamples(rootNode),
61 new xml.CR(),
62 ]);
63 }
64 load(content, url) {
65 throw new Error('Unsupported');
66 }
67 digest(message) {
68 return digest(message);
69 }
70 createNameMapper(message) {
71 return new SimplePlaceholderMapper(message, toPublicName);
72 }
73}
74class _Visitor {
75 visitText(text, context) {
76 return [new xml.Text(text.value)];
77 }
78 visitContainer(container, context) {
79 const nodes = [];
80 container.children.forEach((node) => nodes.push(...node.visit(this)));
81 return nodes;
82 }
83 visitIcu(icu, context) {
84 const nodes = [new xml.Text(`{${icu.expressionPlaceholder}, ${icu.type}, `)];
85 Object.keys(icu.cases).forEach((c) => {
86 nodes.push(new xml.Text(`${c} {`), ...icu.cases[c].visit(this), new xml.Text(`} `));
87 });
88 nodes.push(new xml.Text(`}`));
89 return nodes;
90 }
91 visitTagPlaceholder(ph, context) {
92 const startTagAsText = new xml.Text(`<${ph.tag}>`);
93 const startEx = new xml.Tag(_EXAMPLE_TAG, {}, [startTagAsText]);
94 // TC requires PH to have a non empty EX, and uses the text node to show the "original" value.
95 const startTagPh = new xml.Tag(_PLACEHOLDER_TAG, { name: ph.startName }, [startEx, startTagAsText]);
96 if (ph.isVoid) {
97 // void tags have no children nor closing tags
98 return [startTagPh];
99 }
100 const closeTagAsText = new xml.Text(`</${ph.tag}>`);
101 const closeEx = new xml.Tag(_EXAMPLE_TAG, {}, [closeTagAsText]);
102 // TC requires PH to have a non empty EX, and uses the text node to show the "original" value.
103 const closeTagPh = new xml.Tag(_PLACEHOLDER_TAG, { name: ph.closeName }, [closeEx, closeTagAsText]);
104 return [startTagPh, ...this.serialize(ph.children), closeTagPh];
105 }
106 visitPlaceholder(ph, context) {
107 const interpolationAsText = new xml.Text(`{{${ph.value}}}`);
108 // Example tag needs to be not-empty for TC.
109 const exTag = new xml.Tag(_EXAMPLE_TAG, {}, [interpolationAsText]);
110 return [
111 // TC requires PH to have a non empty EX, and uses the text node to show the "original" value.
112 new xml.Tag(_PLACEHOLDER_TAG, { name: ph.name }, [exTag, interpolationAsText])
113 ];
114 }
115 visitIcuPlaceholder(ph, context) {
116 const icuExpression = ph.value.expression;
117 const icuType = ph.value.type;
118 const icuCases = Object.keys(ph.value.cases).map((value) => value + ' {...}').join(' ');
119 const icuAsText = new xml.Text(`{${icuExpression}, ${icuType}, ${icuCases}}`);
120 const exTag = new xml.Tag(_EXAMPLE_TAG, {}, [icuAsText]);
121 return [
122 // TC requires PH to have a non empty EX, and uses the text node to show the "original" value.
123 new xml.Tag(_PLACEHOLDER_TAG, { name: ph.name }, [exTag, icuAsText])
124 ];
125 }
126 serialize(nodes) {
127 return [].concat(...nodes.map(node => node.visit(this)));
128 }
129}
130export function digest(message) {
131 return decimalDigest(message);
132}
133// TC requires at least one non-empty example on placeholders
134class ExampleVisitor {
135 addDefaultExamples(node) {
136 node.visit(this);
137 return node;
138 }
139 visitTag(tag) {
140 if (tag.name === _PLACEHOLDER_TAG) {
141 if (!tag.children || tag.children.length == 0) {
142 const exText = new xml.Text(tag.attrs['name'] || '...');
143 tag.children = [new xml.Tag(_EXAMPLE_TAG, {}, [exText])];
144 }
145 }
146 else if (tag.children) {
147 tag.children.forEach(node => node.visit(this));
148 }
149 }
150 visitText(text) { }
151 visitDeclaration(decl) { }
152 visitDoctype(doctype) { }
153}
154// XMB/XTB placeholders can only contain A-Z, 0-9 and _
155export function toPublicName(internalName) {
156 return internalName.toUpperCase().replace(/[^A-Z0-9_]/g, '_');
157}
158//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIj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