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