source: trip-planner-front/node_modules/@angular/compiler/esm2015/src/i18n/serializers/xtb.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: 24.2 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 * as ml from '../../ml_parser/ast';
9import { XmlParser } from '../../ml_parser/xml_parser';
10import * as i18n from '../i18n_ast';
11import { I18nError } from '../parse_util';
12import { Serializer, SimplePlaceholderMapper } from './serializer';
13import { digest, toPublicName } from './xmb';
14const _TRANSLATIONS_TAG = 'translationbundle';
15const _TRANSLATION_TAG = 'translation';
16const _PLACEHOLDER_TAG = 'ph';
17export class Xtb extends Serializer {
18 write(messages, locale) {
19 throw new Error('Unsupported');
20 }
21 load(content, url) {
22 // xtb to xml nodes
23 const xtbParser = new XtbParser();
24 const { locale, msgIdToHtml, errors } = xtbParser.parse(content, url);
25 // xml nodes to i18n nodes
26 const i18nNodesByMsgId = {};
27 const converter = new XmlToI18n();
28 // Because we should be able to load xtb files that rely on features not supported by angular,
29 // we need to delay the conversion of html to i18n nodes so that non angular messages are not
30 // converted
31 Object.keys(msgIdToHtml).forEach(msgId => {
32 const valueFn = function () {
33 const { i18nNodes, errors } = converter.convert(msgIdToHtml[msgId], url);
34 if (errors.length) {
35 throw new Error(`xtb parse errors:\n${errors.join('\n')}`);
36 }
37 return i18nNodes;
38 };
39 createLazyProperty(i18nNodesByMsgId, msgId, valueFn);
40 });
41 if (errors.length) {
42 throw new Error(`xtb parse errors:\n${errors.join('\n')}`);
43 }
44 return { locale: locale, i18nNodesByMsgId };
45 }
46 digest(message) {
47 return digest(message);
48 }
49 createNameMapper(message) {
50 return new SimplePlaceholderMapper(message, toPublicName);
51 }
52}
53function createLazyProperty(messages, id, valueFn) {
54 Object.defineProperty(messages, id, {
55 configurable: true,
56 enumerable: true,
57 get: function () {
58 const value = valueFn();
59 Object.defineProperty(messages, id, { enumerable: true, value });
60 return value;
61 },
62 set: _ => {
63 throw new Error('Could not overwrite an XTB translation');
64 },
65 });
66}
67// Extract messages as xml nodes from the xtb file
68class XtbParser {
69 constructor() {
70 this._locale = null;
71 }
72 parse(xtb, url) {
73 this._bundleDepth = 0;
74 this._msgIdToHtml = {};
75 // We can not parse the ICU messages at this point as some messages might not originate
76 // from Angular that could not be lex'd.
77 const xml = new XmlParser().parse(xtb, url);
78 this._errors = xml.errors;
79 ml.visitAll(this, xml.rootNodes);
80 return {
81 msgIdToHtml: this._msgIdToHtml,
82 errors: this._errors,
83 locale: this._locale,
84 };
85 }
86 visitElement(element, context) {
87 switch (element.name) {
88 case _TRANSLATIONS_TAG:
89 this._bundleDepth++;
90 if (this._bundleDepth > 1) {
91 this._addError(element, `<${_TRANSLATIONS_TAG}> elements can not be nested`);
92 }
93 const langAttr = element.attrs.find((attr) => attr.name === 'lang');
94 if (langAttr) {
95 this._locale = langAttr.value;
96 }
97 ml.visitAll(this, element.children, null);
98 this._bundleDepth--;
99 break;
100 case _TRANSLATION_TAG:
101 const idAttr = element.attrs.find((attr) => attr.name === 'id');
102 if (!idAttr) {
103 this._addError(element, `<${_TRANSLATION_TAG}> misses the "id" attribute`);
104 }
105 else {
106 const id = idAttr.value;
107 if (this._msgIdToHtml.hasOwnProperty(id)) {
108 this._addError(element, `Duplicated translations for msg ${id}`);
109 }
110 else {
111 const innerTextStart = element.startSourceSpan.end.offset;
112 const innerTextEnd = element.endSourceSpan.start.offset;
113 const content = element.startSourceSpan.start.file.content;
114 const innerText = content.slice(innerTextStart, innerTextEnd);
115 this._msgIdToHtml[id] = innerText;
116 }
117 }
118 break;
119 default:
120 this._addError(element, 'Unexpected tag');
121 }
122 }
123 visitAttribute(attribute, context) { }
124 visitText(text, context) { }
125 visitComment(comment, context) { }
126 visitExpansion(expansion, context) { }
127 visitExpansionCase(expansionCase, context) { }
128 _addError(node, message) {
129 this._errors.push(new I18nError(node.sourceSpan, message));
130 }
131}
132// Convert ml nodes (xtb syntax) to i18n nodes
133class XmlToI18n {
134 convert(message, url) {
135 const xmlIcu = new XmlParser().parse(message, url, { tokenizeExpansionForms: true });
136 this._errors = xmlIcu.errors;
137 const i18nNodes = this._errors.length > 0 || xmlIcu.rootNodes.length == 0 ?
138 [] :
139 ml.visitAll(this, xmlIcu.rootNodes);
140 return {
141 i18nNodes,
142 errors: this._errors,
143 };
144 }
145 visitText(text, context) {
146 return new i18n.Text(text.value, text.sourceSpan);
147 }
148 visitExpansion(icu, context) {
149 const caseMap = {};
150 ml.visitAll(this, icu.cases).forEach(c => {
151 caseMap[c.value] = new i18n.Container(c.nodes, icu.sourceSpan);
152 });
153 return new i18n.Icu(icu.switchValue, icu.type, caseMap, icu.sourceSpan);
154 }
155 visitExpansionCase(icuCase, context) {
156 return {
157 value: icuCase.value,
158 nodes: ml.visitAll(this, icuCase.expression),
159 };
160 }
161 visitElement(el, context) {
162 if (el.name === _PLACEHOLDER_TAG) {
163 const nameAttr = el.attrs.find((attr) => attr.name === 'name');
164 if (nameAttr) {
165 return new i18n.Placeholder('', nameAttr.value, el.sourceSpan);
166 }
167 this._addError(el, `<${_PLACEHOLDER_TAG}> misses the "name" attribute`);
168 }
169 else {
170 this._addError(el, `Unexpected tag`);
171 }
172 return null;
173 }
174 visitComment(comment, context) { }
175 visitAttribute(attribute, context) { }
176 _addError(node, message) {
177 this._errors.push(new I18nError(node.sourceSpan, message));
178 }
179}
180//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoieHRiLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vLi4vLi4vLi4vcGFja2FnZXMvY29tcGlsZXIvc3JjL2kxOG4vc2VyaWFsaXplcnMveHRiLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBOzs7Ozs7R0FNRztBQUVILE9BQU8sS0FBSyxFQUFFLE1BQU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cnLCBuYW1lQXR0ci52YWx1ZSwgZWwuc291cmNlU3Bhbik7XG4gICAgICB9XG5cbiAgICAgIHRoaXMuX2FkZEVycm9yKGVsLCBgPCR7X1BMQUNFSE9MREVSX1RBR30+IG1pc3NlcyB0aGUgXCJuYW1lXCIgYXR0cmlidXRlYCk7XG4gICAgfSBlbHNlIHtcbiAgICAgIHRoaXMuX2FkZEVycm9yKGVsLCBgVW5leHBlY3RlZCB0YWdgKTtcbiAgICB9XG4gICAgcmV0dXJuIG51bGw7XG4gIH1cblxuICB2aXNpdENvbW1lbnQoY29tbWVudDogbWwuQ29tbWVudCwgY29udGV4dDogYW55KSB7fVxuXG4gIHZpc2l0QXR0cmlidXRlKGF0dHJpYnV0ZTogbWwuQXR0cmlidXRlLCBjb250ZXh0OiBhbnkpIHt9XG5cbiAgcHJpdmF0ZSBfYWRkRXJyb3Iobm9kZTogbWwuTm9kZSwgbWVzc2FnZTogc3RyaW5nKTogdm9pZCB7XG4gICAgdGhpcy5fZXJyb3JzLnB1c2gobmV3IEkxOG5FcnJvcihub2RlLnNvdXJjZVNwYW4sIG1lc3NhZ2UpKTtcbiAgfVxufVxuIl19
Note: See TracBrowser for help on using the repository browser.