1 | (function (factory) {
|
---|
2 | if (typeof module === "object" && typeof module.exports === "object") {
|
---|
3 | var v = factory(require, exports);
|
---|
4 | if (v !== undefined) module.exports = v;
|
---|
5 | }
|
---|
6 | else if (typeof define === "function" && define.amd) {
|
---|
7 | define("@angular/compiler/src/render3/view/i18n/util", ["require", "exports", "tslib", "@angular/compiler/src/i18n/i18n_ast", "@angular/compiler/src/i18n/serializers/xmb", "@angular/compiler/src/output/output_ast"], factory);
|
---|
8 | }
|
---|
9 | })(function (require, exports) {
|
---|
10 | "use strict";
|
---|
11 | Object.defineProperty(exports, "__esModule", { value: true });
|
---|
12 | exports.declareI18nVariable = exports.getTranslationConstPrefix = exports.formatI18nPlaceholderName = exports.i18nFormatPlaceholderNames = exports.assembleBoundTextPlaceholders = exports.updatePlaceholderMap = exports.placeholdersToParams = exports.getSeqNumberGenerator = exports.assembleI18nBoundString = exports.wrapI18nPlaceholder = exports.icuFromI18nMessage = exports.hasI18nAttrs = exports.hasI18nMeta = exports.isSingleI18nIcu = exports.isI18nRootNode = exports.isI18nAttribute = exports.I18N_PLACEHOLDER_SYMBOL = exports.I18N_ICU_MAPPING_PREFIX = exports.I18N_ICU_VAR_PREFIX = exports.I18N_ATTR_PREFIX = exports.I18N_ATTR = exports.TRANSLATION_VAR_PREFIX = void 0;
|
---|
13 | var tslib_1 = require("tslib");
|
---|
14 | /**
|
---|
15 | * @license
|
---|
16 | * Copyright Google LLC All Rights Reserved.
|
---|
17 | *
|
---|
18 | * Use of this source code is governed by an MIT-style license that can be
|
---|
19 | * found in the LICENSE file at https://angular.io/license
|
---|
20 | */
|
---|
21 | var i18n = require("@angular/compiler/src/i18n/i18n_ast");
|
---|
22 | var xmb_1 = require("@angular/compiler/src/i18n/serializers/xmb");
|
---|
23 | var o = require("@angular/compiler/src/output/output_ast");
|
---|
24 | /* Closure variables holding messages must be named `MSG_[A-Z0-9]+` */
|
---|
25 | var CLOSURE_TRANSLATION_VAR_PREFIX = 'MSG_';
|
---|
26 | /**
|
---|
27 | * Prefix for non-`goog.getMsg` i18n-related vars.
|
---|
28 | * Note: the prefix uses lowercase characters intentionally due to a Closure behavior that
|
---|
29 | * considers variables like `I18N_0` as constants and throws an error when their value changes.
|
---|
30 | */
|
---|
31 | exports.TRANSLATION_VAR_PREFIX = 'i18n_';
|
---|
32 | /** Name of the i18n attributes **/
|
---|
33 | exports.I18N_ATTR = 'i18n';
|
---|
34 | exports.I18N_ATTR_PREFIX = 'i18n-';
|
---|
35 | /** Prefix of var expressions used in ICUs */
|
---|
36 | exports.I18N_ICU_VAR_PREFIX = 'VAR_';
|
---|
37 | /** Prefix of ICU expressions for post processing */
|
---|
38 | exports.I18N_ICU_MAPPING_PREFIX = 'I18N_EXP_';
|
---|
39 | /** Placeholder wrapper for i18n expressions **/
|
---|
40 | exports.I18N_PLACEHOLDER_SYMBOL = '�';
|
---|
41 | function isI18nAttribute(name) {
|
---|
42 | return name === exports.I18N_ATTR || name.startsWith(exports.I18N_ATTR_PREFIX);
|
---|
43 | }
|
---|
44 | exports.isI18nAttribute = isI18nAttribute;
|
---|
45 | function isI18nRootNode(meta) {
|
---|
46 | return meta instanceof i18n.Message;
|
---|
47 | }
|
---|
48 | exports.isI18nRootNode = isI18nRootNode;
|
---|
49 | function isSingleI18nIcu(meta) {
|
---|
50 | return isI18nRootNode(meta) && meta.nodes.length === 1 && meta.nodes[0] instanceof i18n.Icu;
|
---|
51 | }
|
---|
52 | exports.isSingleI18nIcu = isSingleI18nIcu;
|
---|
53 | function hasI18nMeta(node) {
|
---|
54 | return !!node.i18n;
|
---|
55 | }
|
---|
56 | exports.hasI18nMeta = hasI18nMeta;
|
---|
57 | function hasI18nAttrs(element) {
|
---|
58 | return element.attrs.some(function (attr) { return isI18nAttribute(attr.name); });
|
---|
59 | }
|
---|
60 | exports.hasI18nAttrs = hasI18nAttrs;
|
---|
61 | function icuFromI18nMessage(message) {
|
---|
62 | return message.nodes[0];
|
---|
63 | }
|
---|
64 | exports.icuFromI18nMessage = icuFromI18nMessage;
|
---|
65 | function wrapI18nPlaceholder(content, contextId) {
|
---|
66 | if (contextId === void 0) { contextId = 0; }
|
---|
67 | var blockId = contextId > 0 ? ":" + contextId : '';
|
---|
68 | return "" + exports.I18N_PLACEHOLDER_SYMBOL + content + blockId + exports.I18N_PLACEHOLDER_SYMBOL;
|
---|
69 | }
|
---|
70 | exports.wrapI18nPlaceholder = wrapI18nPlaceholder;
|
---|
71 | function assembleI18nBoundString(strings, bindingStartIndex, contextId) {
|
---|
72 | if (bindingStartIndex === void 0) { bindingStartIndex = 0; }
|
---|
73 | if (contextId === void 0) { contextId = 0; }
|
---|
74 | if (!strings.length)
|
---|
75 | return '';
|
---|
76 | var acc = '';
|
---|
77 | var lastIdx = strings.length - 1;
|
---|
78 | for (var i = 0; i < lastIdx; i++) {
|
---|
79 | acc += "" + strings[i] + wrapI18nPlaceholder(bindingStartIndex + i, contextId);
|
---|
80 | }
|
---|
81 | acc += strings[lastIdx];
|
---|
82 | return acc;
|
---|
83 | }
|
---|
84 | exports.assembleI18nBoundString = assembleI18nBoundString;
|
---|
85 | function getSeqNumberGenerator(startsAt) {
|
---|
86 | if (startsAt === void 0) { startsAt = 0; }
|
---|
87 | var current = startsAt;
|
---|
88 | return function () { return current++; };
|
---|
89 | }
|
---|
90 | exports.getSeqNumberGenerator = getSeqNumberGenerator;
|
---|
91 | function placeholdersToParams(placeholders) {
|
---|
92 | var params = {};
|
---|
93 | placeholders.forEach(function (values, key) {
|
---|
94 | params[key] = o.literal(values.length > 1 ? "[" + values.join('|') + "]" : values[0]);
|
---|
95 | });
|
---|
96 | return params;
|
---|
97 | }
|
---|
98 | exports.placeholdersToParams = placeholdersToParams;
|
---|
99 | function updatePlaceholderMap(map, name) {
|
---|
100 | var values = [];
|
---|
101 | for (var _i = 2; _i < arguments.length; _i++) {
|
---|
102 | values[_i - 2] = arguments[_i];
|
---|
103 | }
|
---|
104 | var current = map.get(name) || [];
|
---|
105 | current.push.apply(current, tslib_1.__spreadArray([], tslib_1.__read(values)));
|
---|
106 | map.set(name, current);
|
---|
107 | }
|
---|
108 | exports.updatePlaceholderMap = updatePlaceholderMap;
|
---|
109 | function assembleBoundTextPlaceholders(meta, bindingStartIndex, contextId) {
|
---|
110 | if (bindingStartIndex === void 0) { bindingStartIndex = 0; }
|
---|
111 | if (contextId === void 0) { contextId = 0; }
|
---|
112 | var startIdx = bindingStartIndex;
|
---|
113 | var placeholders = new Map();
|
---|
114 | var node = meta instanceof i18n.Message ? meta.nodes.find(function (node) { return node instanceof i18n.Container; }) : meta;
|
---|
115 | if (node) {
|
---|
116 | node
|
---|
117 | .children
|
---|
118 | .filter(function (child) { return child instanceof i18n.Placeholder; })
|
---|
119 | .forEach(function (child, idx) {
|
---|
120 | var content = wrapI18nPlaceholder(startIdx + idx, contextId);
|
---|
121 | updatePlaceholderMap(placeholders, child.name, content);
|
---|
122 | });
|
---|
123 | }
|
---|
124 | return placeholders;
|
---|
125 | }
|
---|
126 | exports.assembleBoundTextPlaceholders = assembleBoundTextPlaceholders;
|
---|
127 | /**
|
---|
128 | * Format the placeholder names in a map of placeholders to expressions.
|
---|
129 | *
|
---|
130 | * The placeholder names are converted from "internal" format (e.g. `START_TAG_DIV_1`) to "external"
|
---|
131 | * format (e.g. `startTagDiv_1`).
|
---|
132 | *
|
---|
133 | * @param params A map of placeholder names to expressions.
|
---|
134 | * @param useCamelCase whether to camelCase the placeholder name when formatting.
|
---|
135 | * @returns A new map of formatted placeholder names to expressions.
|
---|
136 | */
|
---|
137 | function i18nFormatPlaceholderNames(params, useCamelCase) {
|
---|
138 | if (params === void 0) { params = {}; }
|
---|
139 | var _params = {};
|
---|
140 | if (params && Object.keys(params).length) {
|
---|
141 | Object.keys(params).forEach(function (key) { return _params[formatI18nPlaceholderName(key, useCamelCase)] = params[key]; });
|
---|
142 | }
|
---|
143 | return _params;
|
---|
144 | }
|
---|
145 | exports.i18nFormatPlaceholderNames = i18nFormatPlaceholderNames;
|
---|
146 | /**
|
---|
147 | * Converts internal placeholder names to public-facing format
|
---|
148 | * (for example to use in goog.getMsg call).
|
---|
149 | * Example: `START_TAG_DIV_1` is converted to `startTagDiv_1`.
|
---|
150 | *
|
---|
151 | * @param name The placeholder name that should be formatted
|
---|
152 | * @returns Formatted placeholder name
|
---|
153 | */
|
---|
154 | function formatI18nPlaceholderName(name, useCamelCase) {
|
---|
155 | if (useCamelCase === void 0) { useCamelCase = true; }
|
---|
156 | var publicName = xmb_1.toPublicName(name);
|
---|
157 | if (!useCamelCase) {
|
---|
158 | return publicName;
|
---|
159 | }
|
---|
160 | var chunks = publicName.split('_');
|
---|
161 | if (chunks.length === 1) {
|
---|
162 | // if no "_" found - just lowercase the value
|
---|
163 | return name.toLowerCase();
|
---|
164 | }
|
---|
165 | var postfix;
|
---|
166 | // eject last element if it's a number
|
---|
167 | if (/^\d+$/.test(chunks[chunks.length - 1])) {
|
---|
168 | postfix = chunks.pop();
|
---|
169 | }
|
---|
170 | var raw = chunks.shift().toLowerCase();
|
---|
171 | if (chunks.length) {
|
---|
172 | raw += chunks.map(function (c) { return c.charAt(0).toUpperCase() + c.slice(1).toLowerCase(); }).join('');
|
---|
173 | }
|
---|
174 | return postfix ? raw + "_" + postfix : raw;
|
---|
175 | }
|
---|
176 | exports.formatI18nPlaceholderName = formatI18nPlaceholderName;
|
---|
177 | /**
|
---|
178 | * Generates a prefix for translation const name.
|
---|
179 | *
|
---|
180 | * @param extra Additional local prefix that should be injected into translation var name
|
---|
181 | * @returns Complete translation const prefix
|
---|
182 | */
|
---|
183 | function getTranslationConstPrefix(extra) {
|
---|
184 | return ("" + CLOSURE_TRANSLATION_VAR_PREFIX + extra).toUpperCase();
|
---|
185 | }
|
---|
186 | exports.getTranslationConstPrefix = getTranslationConstPrefix;
|
---|
187 | /**
|
---|
188 | * Generate AST to declare a variable. E.g. `var I18N_1;`.
|
---|
189 | * @param variable the name of the variable to declare.
|
---|
190 | */
|
---|
191 | function declareI18nVariable(variable) {
|
---|
192 | return new o.DeclareVarStmt(variable.name, undefined, o.INFERRED_TYPE, undefined, variable.sourceSpan);
|
---|
193 | }
|
---|
194 | exports.declareI18nVariable = declareI18nVariable;
|
---|
195 | });
|
---|
196 | //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidXRpbC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uLy4uLy4uLy4uLy4uL3BhY2thZ2VzL2NvbXBpbGVyL3NyYy9yZW5kZXIzL3ZpZXcvaTE4bi91dGlsLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7Ozs7Ozs7SUFBQTs7Ozs7O09BTUc7SUFDSCwwREFBK0M7SUFDL0Msa0VBQTJEO0lBRTNELDJEQUFnRDtJQUdoRCxzRUFBc0U7SUFDdEUsSUFBTSw4QkFBOEIsR0FBRyxNQUFNLENBQUM7SUFFOUM7Ozs7T0FJRztJQUNVLFFBQUEsc0JBQXNCLEdBQUcsT0FBTyxDQUFDO0lBRTlDLG1DQUFtQztJQUN0QixRQUFBLFNBQVMsR0FBRyxNQUFNLENBQUM7SUFDbkIsUUFBQSxnQkFBZ0IsR0FBRyxPQUFPLENBQUM7SUFFeEMsNkNBQTZDO0lBQ2hDLFFBQUEsbUJBQW1CLEdBQUcsTUFBTSxDQUFDO0lBRTFDLG9EQUFvRDtJQUN2QyxRQUFBLHVCQUF1QixHQUFHLFdBQVcsQ0FBQztJQUVuRCxnREFBZ0Q7SUFDbkMsUUFBQSx1QkFBdUIsR0FBRyxHQUFHLENBQUM7SUFFM0MsU0FBZ0IsZUFBZSxDQUFDLElBQVk7UUFDMUMsT0FBTyxJQUFJLEtBQUssaUJBQVMsSUFBSSxJQUFJLENBQUMsVUFBVSxDQUFDLHdCQUFnQixDQUFDLENBQUM7SUFDakUsQ0FBQztJQUZELDBDQUVDO0lBRUQsU0FBZ0IsY0FBYyxDQUFDLElBQW9CO1FBQ2pELE9BQ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