source: trip-planner-front/node_modules/@angular/compiler/src/i18n/serializers/serializer.js@ 1ad8e64

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

initial commit

  • Property mode set to 100644
File size: 11.7 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 */
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/serializer", ["require", "exports", "tslib", "@angular/compiler/src/i18n/i18n_ast"], factory);
15 }
16})(function (require, exports) {
17 "use strict";
18 Object.defineProperty(exports, "__esModule", { value: true });
19 exports.SimplePlaceholderMapper = exports.Serializer = void 0;
20 var tslib_1 = require("tslib");
21 var i18n = require("@angular/compiler/src/i18n/i18n_ast");
22 var Serializer = /** @class */ (function () {
23 function Serializer() {
24 }
25 // Creates a name mapper, see `PlaceholderMapper`
26 // Returning `null` means that no name mapping is used.
27 Serializer.prototype.createNameMapper = function (message) {
28 return null;
29 };
30 return Serializer;
31 }());
32 exports.Serializer = Serializer;
33 /**
34 * A simple mapper that take a function to transform an internal name to a public name
35 */
36 var SimplePlaceholderMapper = /** @class */ (function (_super) {
37 tslib_1.__extends(SimplePlaceholderMapper, _super);
38 // create a mapping from the message
39 function SimplePlaceholderMapper(message, mapName) {
40 var _this = _super.call(this) || this;
41 _this.mapName = mapName;
42 _this.internalToPublic = {};
43 _this.publicToNextId = {};
44 _this.publicToInternal = {};
45 message.nodes.forEach(function (node) { return node.visit(_this); });
46 return _this;
47 }
48 SimplePlaceholderMapper.prototype.toPublicName = function (internalName) {
49 return this.internalToPublic.hasOwnProperty(internalName) ?
50 this.internalToPublic[internalName] :
51 null;
52 };
53 SimplePlaceholderMapper.prototype.toInternalName = function (publicName) {
54 return this.publicToInternal.hasOwnProperty(publicName) ? this.publicToInternal[publicName] :
55 null;
56 };
57 SimplePlaceholderMapper.prototype.visitText = function (text, context) {
58 return null;
59 };
60 SimplePlaceholderMapper.prototype.visitTagPlaceholder = function (ph, context) {
61 this.visitPlaceholderName(ph.startName);
62 _super.prototype.visitTagPlaceholder.call(this, ph, context);
63 this.visitPlaceholderName(ph.closeName);
64 };
65 SimplePlaceholderMapper.prototype.visitPlaceholder = function (ph, context) {
66 this.visitPlaceholderName(ph.name);
67 };
68 SimplePlaceholderMapper.prototype.visitIcuPlaceholder = function (ph, context) {
69 this.visitPlaceholderName(ph.name);
70 };
71 // XMB placeholders could only contains A-Z, 0-9 and _
72 SimplePlaceholderMapper.prototype.visitPlaceholderName = function (internalName) {
73 if (!internalName || this.internalToPublic.hasOwnProperty(internalName)) {
74 return;
75 }
76 var publicName = this.mapName(internalName);
77 if (this.publicToInternal.hasOwnProperty(publicName)) {
78 // Create a new XMB when it has already been used
79 var nextId = this.publicToNextId[publicName];
80 this.publicToNextId[publicName] = nextId + 1;
81 publicName = publicName + "_" + nextId;
82 }
83 else {
84 this.publicToNextId[publicName] = 1;
85 }
86 this.internalToPublic[internalName] = publicName;
87 this.publicToInternal[publicName] = internalName;
88 };
89 return SimplePlaceholderMapper;
90 }(i18n.RecurseVisitor));
91 exports.SimplePlaceholderMapper = SimplePlaceholderMapper;
92});
93//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2VyaWFsaXplci5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uLy4uLy4uLy4uL3BhY2thZ2VzL2NvbXBpbGVyL3NyYy9pMThuL3NlcmlhbGl6ZXJzL3NlcmlhbGl6ZXIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUE7Ozs7OztHQU1HOzs7Ozs7Ozs7Ozs7OztJQUVILDBEQUFvQztJQUVwQztRQUFBO1FBZ0JBLENBQUM7UUFM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sZGVyLCBjb250ZXh0PzogYW55KTogYW55IHtcbiAgICB0aGlzLnZpc2l0UGxhY2Vob2xkZXJOYW1lKHBoLm5hbWUpO1xuICB9XG5cbiAgLy8gWE1CIHBsYWNlaG9sZGVycyBjb3VsZCBvbmx5IGNvbnRhaW5zIEEtWiwgMC05IGFuZCBfXG4gIHByaXZhdGUgdmlzaXRQbGFjZWhvbGRlck5hbWUoaW50ZXJuYWxOYW1lOiBzdHJpbmcpOiB2b2lkIHtcbiAgICBpZiAoIWludGVybmFsTmFtZSB8fCB0aGlzLmludGVybmFsVG9QdWJsaWMuaGFzT3duUHJvcGVydHkoaW50ZXJuYWxOYW1lKSkge1xuICAgICAgcmV0dXJuO1xuICAgIH1cblxuICAgIGxldCBwdWJsaWNOYW1lID0gdGhpcy5tYXBOYW1lKGludGVybmFsTmFtZSk7XG5cbiAgICBpZiAodGhpcy5wdWJsaWNUb0ludGVybmFsLmhhc093blByb3BlcnR5KHB1YmxpY05hbWUpKSB7XG4gICAgICAvLyBDcmVhdGUgYSBuZXcgWE1CIHdoZW4gaXQgaGFzIGFscmVhZHkgYmVlbiB1c2VkXG4gICAgICBjb25zdCBuZXh0SWQgPSB0aGlzLnB1YmxpY1RvTmV4dElkW3B1YmxpY05hbWVdO1xuICAgICAgdGhpcy5wdWJsaWNUb05leHRJZFtwdWJsaWNOYW1lXSA9IG5leHRJZCArIDE7XG4gICAgICBwdWJsaWNOYW1lID0gYCR7cHVibGljTmFtZX1fJHtuZXh0SWR9YDtcbiAgICB9IGVsc2Uge1xuICAgICAgdGhpcy5wdWJsaWNUb05leHRJZFtwdWJsaWNOYW1lXSA9IDE7XG4gICAgfVxuXG4gICAgdGhpcy5pbnRlcm5hbFRvUHVibGljW2ludGVybmFsTmFtZV0gPSBwdWJsaWNOYW1lO1xuICAgIHRoaXMucHVibGljVG9JbnRlcm5hbFtwdWJsaWNOYW1lXSA9IGludGVybmFsTmFtZTtcbiAgfVxufVxuIl19
Note: See TracBrowser for help on using the repository browser.