@angular/localize 13.0.0-next.9 → 13.0.0-rc.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (138) hide show
  1. package/{esm2015/index.js → esm2020/index.mjs} +0 -0
  2. package/esm2020/init/index.mjs +12 -0
  3. package/{esm2015/localize.js → esm2020/localize.mjs} +0 -0
  4. package/{esm2015/private.js → esm2020/private.mjs} +0 -0
  5. package/{esm2015/src/localize/index.js → esm2020/src/localize/index.mjs} +0 -0
  6. package/{esm2015/src/localize/src/global.js → esm2020/src/localize/src/global.mjs} +0 -0
  7. package/{esm2015/src/localize/src/localize.js → esm2020/src/localize/src/localize.mjs} +2 -2
  8. package/{esm2015/src/translate.js → esm2020/src/translate.mjs} +0 -0
  9. package/{esm2015/src/utils/index.js → esm2020/src/utils/index.mjs} +0 -0
  10. package/{esm2015/src/utils/src/constants.js → esm2020/src/utils/src/constants.mjs} +0 -0
  11. package/esm2020/src/utils/src/messages.mjs +159 -0
  12. package/{esm2015/src/utils/src/translations.js → esm2020/src/utils/src/translations.mjs} +0 -0
  13. package/fesm2015/{init.js → init.mjs} +3 -3
  14. package/fesm2015/init.mjs.map +1 -0
  15. package/fesm2015/{localize.js → localize.mjs} +7 -7
  16. package/fesm2015/localize.mjs.map +1 -0
  17. package/fesm2020/init.mjs +204 -0
  18. package/fesm2020/init.mjs.map +1 -0
  19. package/fesm2020/localize.mjs +449 -0
  20. package/fesm2020/localize.mjs.map +1 -0
  21. package/init/index.d.ts +1 -1
  22. package/init/package.json +5 -5
  23. package/package.json +43 -18
  24. package/schematics/ng-add/index.js +1 -1
  25. package/src/localize/src/localize.d.ts +1 -1
  26. package/src/utils/src/messages.d.ts +1 -1
  27. package/tools/README.md +4 -0
  28. package/tools/bundles/index.js +1929 -0
  29. package/tools/bundles/index.js.map +6 -0
  30. package/tools/bundles/src/extract/cli.js +1278 -0
  31. package/tools/bundles/src/extract/cli.js.map +6 -0
  32. package/tools/bundles/src/migrate/cli.js +77 -0
  33. package/tools/bundles/src/migrate/cli.js.map +6 -0
  34. package/tools/bundles/src/translate/cli.js +1340 -0
  35. package/tools/bundles/src/translate/cli.js.map +6 -0
  36. package/tools/bundles_metadata.json +1 -0
  37. package/tools/index.d.ts +26 -0
  38. package/tools/src/babel_core.d.ts +38 -0
  39. package/{src/tools → tools}/src/diagnostics.d.ts +1 -1
  40. package/tools/src/extract/cli.d.ts +10 -0
  41. package/{src/tools → tools}/src/extract/duplicates.d.ts +2 -2
  42. package/{src/tools → tools}/src/extract/extraction.d.ts +2 -3
  43. package/{src/tools/src/extract/main.d.ts → tools/src/extract/index.d.ts} +2 -4
  44. package/{src/tools → tools}/src/extract/source_files/es2015_extract_plugin.d.ts +3 -3
  45. package/{src/tools → tools}/src/extract/source_files/es5_extract_plugin.d.ts +3 -3
  46. package/{src/tools → tools}/src/extract/translation_files/arb_translation_serializer.d.ts +2 -2
  47. package/{src/tools → tools}/src/extract/translation_files/format_options.d.ts +1 -1
  48. package/{src/tools → tools}/src/extract/translation_files/icu_parsing.d.ts +1 -1
  49. package/{src/tools → tools}/src/extract/translation_files/json_translation_serializer.d.ts +1 -1
  50. package/{src/tools → tools}/src/extract/translation_files/legacy_message_id_migration_serializer.d.ts +1 -1
  51. package/{src/tools → tools}/src/extract/translation_files/translation_serializer.d.ts +1 -1
  52. package/{src/tools → tools}/src/extract/translation_files/utils.d.ts +1 -1
  53. package/{src/tools → tools}/src/extract/translation_files/xliff1_translation_serializer.d.ts +2 -2
  54. package/{src/tools → tools}/src/extract/translation_files/xliff2_translation_serializer.d.ts +2 -2
  55. package/{src/tools → tools}/src/extract/translation_files/xmb_translation_serializer.d.ts +2 -2
  56. package/{src/tools → tools}/src/extract/translation_files/xml_file.d.ts +1 -1
  57. package/tools/src/migrate/cli.d.ts +10 -0
  58. package/{src/tools/src/migrate/main.d.ts → tools/src/migrate/index.d.ts} +9 -3
  59. package/{src/tools → tools}/src/migrate/migrate.d.ts +1 -1
  60. package/{src/tools → tools}/src/source_file_utils.d.ts +3 -3
  61. package/{src/tools → tools}/src/translate/asset_files/asset_translation_handler.d.ts +2 -2
  62. package/tools/src/translate/cli.d.ts +3 -0
  63. package/{src/tools/src/translate/main.d.ts → tools/src/translate/index.d.ts} +1 -2
  64. package/{src/tools → tools}/src/translate/output_path.d.ts +2 -2
  65. package/{src/tools → tools}/src/translate/source_files/es2015_translate_plugin.d.ts +3 -3
  66. package/{src/tools → tools}/src/translate/source_files/es5_translate_plugin.d.ts +3 -3
  67. package/{src/tools → tools}/src/translate/source_files/locale_plugin.d.ts +2 -2
  68. package/{src/tools → tools}/src/translate/source_files/source_file_translation_handler.d.ts +2 -2
  69. package/{src/tools → tools}/src/translate/translation_files/base_visitor.d.ts +1 -1
  70. package/{src/tools → tools}/src/translate/translation_files/message_serialization/message_renderer.d.ts +1 -1
  71. package/{src/tools → tools}/src/translate/translation_files/message_serialization/message_serializer.d.ts +1 -1
  72. package/{src/tools → tools}/src/translate/translation_files/message_serialization/target_message_renderer.d.ts +1 -1
  73. package/{src/tools → tools}/src/translate/translation_files/translation_loader.d.ts +2 -2
  74. package/{src/tools → tools}/src/translate/translation_files/translation_parsers/arb_translation_parser.d.ts +1 -1
  75. package/{src/tools → tools}/src/translate/translation_files/translation_parsers/serialize_translation_message.d.ts +1 -1
  76. package/{src/tools → tools}/src/translate/translation_files/translation_parsers/simple_json_translation_parser.d.ts +1 -1
  77. package/{src/tools → tools}/src/translate/translation_files/translation_parsers/translation_parse_error.d.ts +1 -1
  78. package/{src/tools → tools}/src/translate/translation_files/translation_parsers/translation_parser.d.ts +2 -2
  79. package/{src/tools → tools}/src/translate/translation_files/translation_parsers/translation_utils.d.ts +1 -1
  80. package/{src/tools → tools}/src/translate/translation_files/translation_parsers/xliff1_translation_parser.d.ts +1 -1
  81. package/{src/tools → tools}/src/translate/translation_files/translation_parsers/xliff2_translation_parser.d.ts +1 -1
  82. package/{src/tools → tools}/src/translate/translation_files/translation_parsers/xtb_translation_parser.d.ts +1 -1
  83. package/{src/tools → tools}/src/translate/translator.d.ts +2 -2
  84. package/bundles/localize-init.umd.js +0 -218
  85. package/bundles/localize-init.umd.js.map +0 -1
  86. package/bundles/localize.umd.js +0 -782
  87. package/bundles/localize.umd.js.map +0 -1
  88. package/esm2015/init/index.js +0 -12
  89. package/esm2015/init/init.externs.js +0 -0
  90. package/esm2015/localize.externs.js +0 -0
  91. package/esm2015/src/localize/localize.externs.js +0 -0
  92. package/esm2015/src/utils/src/messages.js +0 -159
  93. package/esm2015/src/utils/utils.externs.js +0 -0
  94. package/fesm2015/init.js.map +0 -1
  95. package/fesm2015/localize.js.map +0 -1
  96. package/init.d.ts +0 -7
  97. package/src/tools/src/diagnostics.js +0 -68
  98. package/src/tools/src/extract/duplicates.js +0 -84
  99. package/src/tools/src/extract/extraction.js +0 -134
  100. package/src/tools/src/extract/main.js +0 -184
  101. package/src/tools/src/extract/source_files/es2015_extract_plugin.js +0 -36
  102. package/src/tools/src/extract/source_files/es5_extract_plugin.js +0 -49
  103. package/src/tools/src/extract/translation_files/arb_translation_serializer.js +0 -107
  104. package/src/tools/src/extract/translation_files/format_options.js +0 -52
  105. package/src/tools/src/extract/translation_files/icu_parsing.js +0 -224
  106. package/src/tools/src/extract/translation_files/json_translation_serializer.js +0 -47
  107. package/src/tools/src/extract/translation_files/legacy_message_id_migration_serializer.js +0 -63
  108. package/src/tools/src/extract/translation_files/translation_serializer.js +0 -13
  109. package/src/tools/src/extract/translation_files/utils.js +0 -102
  110. package/src/tools/src/extract/translation_files/xliff1_translation_serializer.js +0 -242
  111. package/src/tools/src/extract/translation_files/xliff2_translation_serializer.js +0 -231
  112. package/src/tools/src/extract/translation_files/xmb_translation_serializer.js +0 -139
  113. package/src/tools/src/extract/translation_files/xml_file.js +0 -117
  114. package/src/tools/src/migrate/main.js +0 -79
  115. package/src/tools/src/migrate/migrate.js +0 -48
  116. package/src/tools/src/source_file_utils.js +0 -443
  117. package/src/tools/src/translate/asset_files/asset_translation_handler.js +0 -65
  118. package/src/tools/src/translate/main.js +0 -157
  119. package/src/tools/src/translate/output_path.js +0 -28
  120. package/src/tools/src/translate/source_files/es2015_translate_plugin.js +0 -60
  121. package/src/tools/src/translate/source_files/es5_translate_plugin.js +0 -58
  122. package/src/tools/src/translate/source_files/locale_plugin.js +0 -95
  123. package/src/tools/src/translate/source_files/source_file_translation_handler.js +0 -127
  124. package/src/tools/src/translate/translation_files/base_visitor.js +0 -31
  125. package/src/tools/src/translate/translation_files/message_serialization/message_renderer.js +0 -20
  126. package/src/tools/src/translate/translation_files/message_serialization/message_serializer.js +0 -100
  127. package/src/tools/src/translate/translation_files/message_serialization/target_message_renderer.js +0 -84
  128. package/src/tools/src/translate/translation_files/translation_loader.js +0 -148
  129. package/src/tools/src/translate/translation_files/translation_parsers/arb_translation_parser.js +0 -111
  130. package/src/tools/src/translate/translation_files/translation_parsers/serialize_translation_message.js +0 -32
  131. package/src/tools/src/translate/translation_files/translation_parsers/simple_json_translation_parser.js +0 -96
  132. package/src/tools/src/translate/translation_files/translation_parsers/translation_parse_error.js +0 -47
  133. package/src/tools/src/translate/translation_files/translation_parsers/translation_parser.js +0 -13
  134. package/src/tools/src/translate/translation_files/translation_parsers/translation_utils.js +0 -175
  135. package/src/tools/src/translate/translation_files/translation_parsers/xliff1_translation_parser.js +0 -175
  136. package/src/tools/src/translate/translation_files/translation_parsers/xliff2_translation_parser.js +0 -166
  137. package/src/tools/src/translate/translation_files/translation_parsers/xtb_translation_parser.js +0 -133
  138. package/src/tools/src/translate/translator.js +0 -53
@@ -1,782 +0,0 @@
1
- /**
2
- * @license Angular v13.0.0-next.9
3
- * (c) 2010-2021 Google LLC. https://angular.io/
4
- * License: MIT
5
- */
6
-
7
- (function (global, factory) {
8
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/compiler')) :
9
- typeof define === 'function' && define.amd ? define('@angular/localize', ['exports', '@angular/compiler'], factory) :
10
- (global = global || self, factory((global.ng = global.ng || {}, global.ng.localize = {}), global.ng.compiler));
11
- }(this, (function (exports, compiler) { 'use strict';
12
-
13
- /**
14
- * @license
15
- * Copyright Google LLC All Rights Reserved.
16
- *
17
- * Use of this source code is governed by an MIT-style license that can be
18
- * found in the LICENSE file at https://angular.io/license
19
- */
20
- /**
21
- * The character used to mark the start and end of a "block" in a `$localize` tagged string.
22
- * A block can indicate metadata about the message or specify a name of a placeholder for a
23
- * substitution expressions.
24
- *
25
- * For example:
26
- *
27
- * ```ts
28
- * $localize`Hello, ${title}:title:!`;
29
- * $localize`:meaning|description@@id:source message text`;
30
- * ```
31
- */
32
- var BLOCK_MARKER = ':';
33
- /**
34
- * The marker used to separate a message's "meaning" from its "description" in a metadata block.
35
- *
36
- * For example:
37
- *
38
- * ```ts
39
- * $localize `:correct|Indicates that the user got the answer correct: Right!`;
40
- * $localize `:movement|Button label for moving to the right: Right!`;
41
- * ```
42
- */
43
- var MEANING_SEPARATOR = '|';
44
- /**
45
- * The marker used to separate a message's custom "id" from its "description" in a metadata block.
46
- *
47
- * For example:
48
- *
49
- * ```ts
50
- * $localize `:A welcome message on the home page@@myApp-homepage-welcome: Welcome!`;
51
- * ```
52
- */
53
- var ID_SEPARATOR = '@@';
54
- /**
55
- * The marker used to separate legacy message ids from the rest of a metadata block.
56
- *
57
- * For example:
58
- *
59
- * ```ts
60
- * $localize `:@@custom-id␟2df64767cd895a8fabe3e18b94b5b6b6f9e2e3f0: Welcome!`;
61
- * ```
62
- *
63
- * Note that this character is the "symbol for the unit separator" (␟) not the "unit separator
64
- * character" itself, since that has no visual representation. See https://graphemica.com/%E2%90%9F.
65
- *
66
- * Here is some background for the original "unit separator character":
67
- * https://stackoverflow.com/questions/8695118/whats-the-file-group-record-unit-separator-control-characters-and-its-usage
68
- */
69
- var LEGACY_ID_INDICATOR = '\u241F';
70
-
71
- /*! *****************************************************************************
72
- Copyright (c) Microsoft Corporation.
73
-
74
- Permission to use, copy, modify, and/or distribute this software for any
75
- purpose with or without fee is hereby granted.
76
-
77
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
78
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
79
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
80
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
81
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
82
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
83
- PERFORMANCE OF THIS SOFTWARE.
84
- ***************************************************************************** */
85
- /* global Reflect, Promise */
86
- var extendStatics = function (d, b) {
87
- extendStatics = Object.setPrototypeOf ||
88
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
89
- function (d, b) { for (var p in b)
90
- if (Object.prototype.hasOwnProperty.call(b, p))
91
- d[p] = b[p]; };
92
- return extendStatics(d, b);
93
- };
94
- function __extends(d, b) {
95
- if (typeof b !== "function" && b !== null)
96
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
97
- extendStatics(d, b);
98
- function __() { this.constructor = d; }
99
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
100
- }
101
- var __assign = function () {
102
- __assign = Object.assign || function __assign(t) {
103
- for (var s, i = 1, n = arguments.length; i < n; i++) {
104
- s = arguments[i];
105
- for (var p in s)
106
- if (Object.prototype.hasOwnProperty.call(s, p))
107
- t[p] = s[p];
108
- }
109
- return t;
110
- };
111
- return __assign.apply(this, arguments);
112
- };
113
- function __rest(s, e) {
114
- var t = {};
115
- for (var p in s)
116
- if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
117
- t[p] = s[p];
118
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
119
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
120
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
121
- t[p[i]] = s[p[i]];
122
- }
123
- return t;
124
- }
125
- function __decorate(decorators, target, key, desc) {
126
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
127
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
128
- r = Reflect.decorate(decorators, target, key, desc);
129
- else
130
- for (var i = decorators.length - 1; i >= 0; i--)
131
- if (d = decorators[i])
132
- r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
133
- return c > 3 && r && Object.defineProperty(target, key, r), r;
134
- }
135
- function __param(paramIndex, decorator) {
136
- return function (target, key) { decorator(target, key, paramIndex); };
137
- }
138
- function __metadata(metadataKey, metadataValue) {
139
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
140
- return Reflect.metadata(metadataKey, metadataValue);
141
- }
142
- function __awaiter(thisArg, _arguments, P, generator) {
143
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
144
- return new (P || (P = Promise))(function (resolve, reject) {
145
- function fulfilled(value) { try {
146
- step(generator.next(value));
147
- }
148
- catch (e) {
149
- reject(e);
150
- } }
151
- function rejected(value) { try {
152
- step(generator["throw"](value));
153
- }
154
- catch (e) {
155
- reject(e);
156
- } }
157
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
158
- step((generator = generator.apply(thisArg, _arguments || [])).next());
159
- });
160
- }
161
- function __generator(thisArg, body) {
162
- var _ = { label: 0, sent: function () { if (t[0] & 1)
163
- throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
164
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function () { return this; }), g;
165
- function verb(n) { return function (v) { return step([n, v]); }; }
166
- function step(op) {
167
- if (f)
168
- throw new TypeError("Generator is already executing.");
169
- while (_)
170
- try {
171
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done)
172
- return t;
173
- if (y = 0, t)
174
- op = [op[0] & 2, t.value];
175
- switch (op[0]) {
176
- case 0:
177
- case 1:
178
- t = op;
179
- break;
180
- case 4:
181
- _.label++;
182
- return { value: op[1], done: false };
183
- case 5:
184
- _.label++;
185
- y = op[1];
186
- op = [0];
187
- continue;
188
- case 7:
189
- op = _.ops.pop();
190
- _.trys.pop();
191
- continue;
192
- default:
193
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
194
- _ = 0;
195
- continue;
196
- }
197
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) {
198
- _.label = op[1];
199
- break;
200
- }
201
- if (op[0] === 6 && _.label < t[1]) {
202
- _.label = t[1];
203
- t = op;
204
- break;
205
- }
206
- if (t && _.label < t[2]) {
207
- _.label = t[2];
208
- _.ops.push(op);
209
- break;
210
- }
211
- if (t[2])
212
- _.ops.pop();
213
- _.trys.pop();
214
- continue;
215
- }
216
- op = body.call(thisArg, _);
217
- }
218
- catch (e) {
219
- op = [6, e];
220
- y = 0;
221
- }
222
- finally {
223
- f = t = 0;
224
- }
225
- if (op[0] & 5)
226
- throw op[1];
227
- return { value: op[0] ? op[1] : void 0, done: true };
228
- }
229
- }
230
- var __createBinding = Object.create ? (function (o, m, k, k2) {
231
- if (k2 === undefined)
232
- k2 = k;
233
- Object.defineProperty(o, k2, { enumerable: true, get: function () { return m[k]; } });
234
- }) : (function (o, m, k, k2) {
235
- if (k2 === undefined)
236
- k2 = k;
237
- o[k2] = m[k];
238
- });
239
- function __exportStar(m, o) {
240
- for (var p in m)
241
- if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p))
242
- __createBinding(o, m, p);
243
- }
244
- function __values(o) {
245
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
246
- if (m)
247
- return m.call(o);
248
- if (o && typeof o.length === "number")
249
- return {
250
- next: function () {
251
- if (o && i >= o.length)
252
- o = void 0;
253
- return { value: o && o[i++], done: !o };
254
- }
255
- };
256
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
257
- }
258
- function __read(o, n) {
259
- var m = typeof Symbol === "function" && o[Symbol.iterator];
260
- if (!m)
261
- return o;
262
- var i = m.call(o), r, ar = [], e;
263
- try {
264
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done)
265
- ar.push(r.value);
266
- }
267
- catch (error) {
268
- e = { error: error };
269
- }
270
- finally {
271
- try {
272
- if (r && !r.done && (m = i["return"]))
273
- m.call(i);
274
- }
275
- finally {
276
- if (e)
277
- throw e.error;
278
- }
279
- }
280
- return ar;
281
- }
282
- /** @deprecated */
283
- function __spread() {
284
- for (var ar = [], i = 0; i < arguments.length; i++)
285
- ar = ar.concat(__read(arguments[i]));
286
- return ar;
287
- }
288
- /** @deprecated */
289
- function __spreadArrays() {
290
- for (var s = 0, i = 0, il = arguments.length; i < il; i++)
291
- s += arguments[i].length;
292
- for (var r = Array(s), k = 0, i = 0; i < il; i++)
293
- for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
294
- r[k] = a[j];
295
- return r;
296
- }
297
- function __spreadArray(to, from, pack) {
298
- if (pack || arguments.length === 2)
299
- for (var i = 0, l = from.length, ar; i < l; i++) {
300
- if (ar || !(i in from)) {
301
- if (!ar)
302
- ar = Array.prototype.slice.call(from, 0, i);
303
- ar[i] = from[i];
304
- }
305
- }
306
- return to.concat(ar || Array.prototype.slice.call(from));
307
- }
308
- function __await(v) {
309
- return this instanceof __await ? (this.v = v, this) : new __await(v);
310
- }
311
- function __asyncGenerator(thisArg, _arguments, generator) {
312
- if (!Symbol.asyncIterator)
313
- throw new TypeError("Symbol.asyncIterator is not defined.");
314
- var g = generator.apply(thisArg, _arguments || []), i, q = [];
315
- return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
316
- function verb(n) { if (g[n])
317
- i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
318
- function resume(n, v) { try {
319
- step(g[n](v));
320
- }
321
- catch (e) {
322
- settle(q[0][3], e);
323
- } }
324
- function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
325
- function fulfill(value) { resume("next", value); }
326
- function reject(value) { resume("throw", value); }
327
- function settle(f, v) { if (f(v), q.shift(), q.length)
328
- resume(q[0][0], q[0][1]); }
329
- }
330
- function __asyncDelegator(o) {
331
- var i, p;
332
- return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
333
- function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
334
- }
335
- function __asyncValues(o) {
336
- if (!Symbol.asyncIterator)
337
- throw new TypeError("Symbol.asyncIterator is not defined.");
338
- var m = o[Symbol.asyncIterator], i;
339
- return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
340
- function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
341
- function settle(resolve, reject, d, v) { Promise.resolve(v).then(function (v) { resolve({ value: v, done: d }); }, reject); }
342
- }
343
- function __makeTemplateObject(cooked, raw) {
344
- if (Object.defineProperty) {
345
- Object.defineProperty(cooked, "raw", { value: raw });
346
- }
347
- else {
348
- cooked.raw = raw;
349
- }
350
- return cooked;
351
- }
352
- ;
353
- var __setModuleDefault = Object.create ? (function (o, v) {
354
- Object.defineProperty(o, "default", { enumerable: true, value: v });
355
- }) : function (o, v) {
356
- o["default"] = v;
357
- };
358
- function __importStar(mod) {
359
- if (mod && mod.__esModule)
360
- return mod;
361
- var result = {};
362
- if (mod != null)
363
- for (var k in mod)
364
- if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k))
365
- __createBinding(result, mod, k);
366
- __setModuleDefault(result, mod);
367
- return result;
368
- }
369
- function __importDefault(mod) {
370
- return (mod && mod.__esModule) ? mod : { default: mod };
371
- }
372
- function __classPrivateFieldGet(receiver, state, kind, f) {
373
- if (kind === "a" && !f)
374
- throw new TypeError("Private accessor was defined without a getter");
375
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
376
- throw new TypeError("Cannot read private member from an object whose class did not declare it");
377
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
378
- }
379
- function __classPrivateFieldSet(receiver, state, value, kind, f) {
380
- if (kind === "m")
381
- throw new TypeError("Private method is not writable");
382
- if (kind === "a" && !f)
383
- throw new TypeError("Private accessor was defined without a setter");
384
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
385
- throw new TypeError("Cannot write private member to an object whose class did not declare it");
386
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
387
- }
388
-
389
- /**
390
- * Parse a `$localize` tagged string into a structure that can be used for translation or
391
- * extraction.
392
- *
393
- * See `ParsedMessage` for an example.
394
- */
395
- function parseMessage(messageParts, expressions, location, messagePartLocations, expressionLocations) {
396
- if (expressionLocations === void 0) { expressionLocations = []; }
397
- var substitutions = {};
398
- var substitutionLocations = {};
399
- var metadata = parseMetadata(messageParts[0], messageParts.raw[0]);
400
- var cleanedMessageParts = [metadata.text];
401
- var placeholderNames = [];
402
- var messageString = metadata.text;
403
- for (var i = 1; i < messageParts.length; i++) {
404
- var _a = splitBlock(messageParts[i], messageParts.raw[i]), messagePart = _a.text, _b = _a.block, placeholderName = _b === void 0 ? computePlaceholderName(i) : _b;
405
- messageString += "{$" + placeholderName + "}" + messagePart;
406
- if (expressions !== undefined) {
407
- substitutions[placeholderName] = expressions[i - 1];
408
- substitutionLocations[placeholderName] = expressionLocations[i - 1];
409
- }
410
- placeholderNames.push(placeholderName);
411
- cleanedMessageParts.push(messagePart);
412
- }
413
- var messageId = metadata.customId || compiler.computeMsgId(messageString, metadata.meaning || '');
414
- var legacyIds = metadata.legacyIds ? metadata.legacyIds.filter(function (id) { return id !== messageId; }) : [];
415
- return {
416
- id: messageId,
417
- legacyIds: legacyIds,
418
- substitutions: substitutions,
419
- substitutionLocations: substitutionLocations,
420
- text: messageString,
421
- customId: metadata.customId,
422
- meaning: metadata.meaning || '',
423
- description: metadata.description || '',
424
- messageParts: cleanedMessageParts,
425
- messagePartLocations: messagePartLocations,
426
- placeholderNames: placeholderNames,
427
- location: location,
428
- };
429
- }
430
- /**
431
- * Parse the given message part (`cooked` + `raw`) to extract the message metadata from the text.
432
- *
433
- * If the message part has a metadata block this function will extract the `meaning`,
434
- * `description`, `customId` and `legacyId` (if provided) from the block. These metadata properties
435
- * are serialized in the string delimited by `|`, `@@` and `␟` respectively.
436
- *
437
- * (Note that `␟` is the `LEGACY_ID_INDICATOR` - see `constants.ts`.)
438
- *
439
- * For example:
440
- *
441
- * ```ts
442
- * `:meaning|description@@custom-id`
443
- * `:meaning|@@custom-id`
444
- * `:meaning|description`
445
- * `description@@custom-id`
446
- * `meaning|`
447
- * `description`
448
- * `@@custom-id`
449
- * `:meaning|description@@custom-id␟legacy-id-1␟legacy-id-2`
450
- * ```
451
- *
452
- * @param cooked The cooked version of the message part to parse.
453
- * @param raw The raw version of the message part to parse.
454
- * @returns A object containing any metadata that was parsed from the message part.
455
- */
456
- function parseMetadata(cooked, raw) {
457
- var _a = splitBlock(cooked, raw), messageString = _a.text, block = _a.block;
458
- if (block === undefined) {
459
- return { text: messageString };
460
- }
461
- else {
462
- var _b = __read(block.split(LEGACY_ID_INDICATOR)), meaningDescAndId = _b[0], legacyIds = _b.slice(1);
463
- var _c = __read(meaningDescAndId.split(ID_SEPARATOR, 2), 2), meaningAndDesc = _c[0], customId = _c[1];
464
- var _d = __read(meaningAndDesc.split(MEANING_SEPARATOR, 2), 2), meaning = _d[0], description = _d[1];
465
- if (description === undefined) {
466
- description = meaning;
467
- meaning = undefined;
468
- }
469
- if (description === '') {
470
- description = undefined;
471
- }
472
- return { text: messageString, meaning: meaning, description: description, customId: customId, legacyIds: legacyIds };
473
- }
474
- }
475
- /**
476
- * Split a message part (`cooked` + `raw`) into an optional delimited "block" off the front and the
477
- * rest of the text of the message part.
478
- *
479
- * Blocks appear at the start of message parts. They are delimited by a colon `:` character at the
480
- * start and end of the block.
481
- *
482
- * If the block is in the first message part then it will be metadata about the whole message:
483
- * meaning, description, id. Otherwise it will be metadata about the immediately preceding
484
- * substitution: placeholder name.
485
- *
486
- * Since blocks are optional, it is possible that the content of a message block actually starts
487
- * with a block marker. In this case the marker must be escaped `\:`.
488
- *
489
- * @param cooked The cooked version of the message part to parse.
490
- * @param raw The raw version of the message part to parse.
491
- * @returns An object containing the `text` of the message part and the text of the `block`, if it
492
- * exists.
493
- * @throws an error if the `block` is unterminated
494
- */
495
- function splitBlock(cooked, raw) {
496
- if (raw.charAt(0) !== BLOCK_MARKER) {
497
- return { text: cooked };
498
- }
499
- else {
500
- var endOfBlock = findEndOfBlock(cooked, raw);
501
- return {
502
- block: cooked.substring(1, endOfBlock),
503
- text: cooked.substring(endOfBlock + 1),
504
- };
505
- }
506
- }
507
- function computePlaceholderName(index) {
508
- return index === 1 ? 'PH' : "PH_" + (index - 1);
509
- }
510
- /**
511
- * Find the end of a "marked block" indicated by the first non-escaped colon.
512
- *
513
- * @param cooked The cooked string (where escaped chars have been processed)
514
- * @param raw The raw string (where escape sequences are still in place)
515
- *
516
- * @returns the index of the end of block marker
517
- * @throws an error if the block is unterminated
518
- */
519
- function findEndOfBlock(cooked, raw) {
520
- /************************************************************************************************
521
- * This function is repeated in `src/localize/src/localize.ts` and the two should be kept in sync.
522
- * (See that file for more explanation of why.)
523
- ************************************************************************************************/
524
- for (var cookedIndex = 1, rawIndex = 1; cookedIndex < cooked.length; cookedIndex++, rawIndex++) {
525
- if (raw[rawIndex] === '\\') {
526
- rawIndex++;
527
- }
528
- else if (cooked[cookedIndex] === BLOCK_MARKER) {
529
- return cookedIndex;
530
- }
531
- }
532
- throw new Error("Unterminated $localize metadata block in \"" + raw + "\".");
533
- }
534
-
535
- var MissingTranslationError = /** @class */ (function (_super) {
536
- __extends(MissingTranslationError, _super);
537
- function MissingTranslationError(parsedMessage) {
538
- var _this = _super.call(this, "No translation found for " + describeMessage(parsedMessage) + ".") || this;
539
- _this.parsedMessage = parsedMessage;
540
- _this.type = 'MissingTranslationError';
541
- return _this;
542
- }
543
- return MissingTranslationError;
544
- }(Error));
545
- function isMissingTranslationError(e) {
546
- return e.type === 'MissingTranslationError';
547
- }
548
- /**
549
- * Translate the text of the `$localize` tagged-string (i.e. `messageParts` and
550
- * `substitutions`) using the given `translations`.
551
- *
552
- * The tagged-string is parsed to extract its `messageId` which is used to find an appropriate
553
- * `ParsedTranslation`. If this doesn't match and there are legacy ids then try matching a
554
- * translation using those.
555
- *
556
- * If one is found then it is used to translate the message into a new set of `messageParts` and
557
- * `substitutions`.
558
- * The translation may reorder (or remove) substitutions as appropriate.
559
- *
560
- * If there is no translation with a matching message id then an error is thrown.
561
- * If a translation contains a placeholder that is not found in the message being translated then an
562
- * error is thrown.
563
- */
564
- function translate(translations, messageParts, substitutions) {
565
- var message = parseMessage(messageParts, substitutions);
566
- // Look up the translation using the messageId, and then the legacyId if available.
567
- var translation = translations[message.id];
568
- // If the messageId did not match a translation, try matching the legacy ids instead
569
- if (message.legacyIds !== undefined) {
570
- for (var i = 0; i < message.legacyIds.length && translation === undefined; i++) {
571
- translation = translations[message.legacyIds[i]];
572
- }
573
- }
574
- if (translation === undefined) {
575
- throw new MissingTranslationError(message);
576
- }
577
- return [
578
- translation.messageParts, translation.placeholderNames.map(function (placeholder) {
579
- if (message.substitutions.hasOwnProperty(placeholder)) {
580
- return message.substitutions[placeholder];
581
- }
582
- else {
583
- throw new Error("There is a placeholder name mismatch with the translation provided for the message " + describeMessage(message) + ".\n" +
584
- ("The translation contains a placeholder with name " + placeholder + ", which does not exist in the message."));
585
- }
586
- })
587
- ];
588
- }
589
- /**
590
- * Parse the `messageParts` and `placeholderNames` out of a target `message`.
591
- *
592
- * Used by `loadTranslations()` to convert target message strings into a structure that is more
593
- * appropriate for doing translation.
594
- *
595
- * @param message the message to be parsed.
596
- */
597
- function parseTranslation(messageString) {
598
- var parts = messageString.split(/{\$([^}]*)}/);
599
- var messageParts = [parts[0]];
600
- var placeholderNames = [];
601
- for (var i = 1; i < parts.length - 1; i += 2) {
602
- placeholderNames.push(parts[i]);
603
- messageParts.push("" + parts[i + 1]);
604
- }
605
- var rawMessageParts = messageParts.map(function (part) { return part.charAt(0) === BLOCK_MARKER ? '\\' + part : part; });
606
- return {
607
- text: messageString,
608
- messageParts: makeTemplateObject(messageParts, rawMessageParts),
609
- placeholderNames: placeholderNames,
610
- };
611
- }
612
- /**
613
- * Create a `ParsedTranslation` from a set of `messageParts` and `placeholderNames`.
614
- *
615
- * @param messageParts The message parts to appear in the ParsedTranslation.
616
- * @param placeholderNames The names of the placeholders to intersperse between the `messageParts`.
617
- */
618
- function makeParsedTranslation(messageParts, placeholderNames) {
619
- if (placeholderNames === void 0) { placeholderNames = []; }
620
- var messageString = messageParts[0];
621
- for (var i = 0; i < placeholderNames.length; i++) {
622
- messageString += "{$" + placeholderNames[i] + "}" + messageParts[i + 1];
623
- }
624
- return {
625
- text: messageString,
626
- messageParts: makeTemplateObject(messageParts, messageParts),
627
- placeholderNames: placeholderNames
628
- };
629
- }
630
- /**
631
- * Create the specialized array that is passed to tagged-string tag functions.
632
- *
633
- * @param cooked The message parts with their escape codes processed.
634
- * @param raw The message parts with their escaped codes as-is.
635
- */
636
- function makeTemplateObject(cooked, raw) {
637
- Object.defineProperty(cooked, 'raw', { value: raw });
638
- return cooked;
639
- }
640
- function describeMessage(message) {
641
- var meaningString = message.meaning && " - \"" + message.meaning + "\"";
642
- var legacy = message.legacyIds && message.legacyIds.length > 0 ?
643
- " [" + message.legacyIds.map(function (l) { return "\"" + l + "\""; }).join(', ') + "]" :
644
- '';
645
- return "\"" + message.id + "\"" + legacy + " (\"" + message.text + "\"" + meaningString + ")";
646
- }
647
-
648
- /**
649
- * @license
650
- * Copyright Google LLC All Rights Reserved.
651
- *
652
- * Use of this source code is governed by an MIT-style license that can be
653
- * found in the LICENSE file at https://angular.io/license
654
- */
655
-
656
- /**
657
- * Load translations for use by `$localize`, if doing runtime translation.
658
- *
659
- * If the `$localize` tagged strings are not going to be replaced at compiled time, it is possible
660
- * to load a set of translations that will be applied to the `$localize` tagged strings at runtime,
661
- * in the browser.
662
- *
663
- * Loading a new translation will overwrite a previous translation if it has the same `MessageId`.
664
- *
665
- * Note that `$localize` messages are only processed once, when the tagged string is first
666
- * encountered, and does not provide dynamic language changing without refreshing the browser.
667
- * Loading new translations later in the application life-cycle will not change the translated text
668
- * of messages that have already been translated.
669
- *
670
- * The message IDs and translations are in the same format as that rendered to "simple JSON"
671
- * translation files when extracting messages. In particular, placeholders in messages are rendered
672
- * using the `{$PLACEHOLDER_NAME}` syntax. For example the message from the following template:
673
- *
674
- * ```html
675
- * <div i18n>pre<span>inner-pre<b>bold</b>inner-post</span>post</div>
676
- * ```
677
- *
678
- * would have the following form in the `translations` map:
679
- *
680
- * ```ts
681
- * {
682
- * "2932901491976224757":
683
- * "pre{$START_TAG_SPAN}inner-pre{$START_BOLD_TEXT}bold{$CLOSE_BOLD_TEXT}inner-post{$CLOSE_TAG_SPAN}post"
684
- * }
685
- * ```
686
- *
687
- * @param translations A map from message ID to translated message.
688
- *
689
- * These messages are processed and added to a lookup based on their `MessageId`.
690
- *
691
- * @see `clearTranslations()` for removing translations loaded using this function.
692
- * @see `$localize` for tagging messages as needing to be translated.
693
- * @publicApi
694
- */
695
- function loadTranslations(translations) {
696
- // Ensure the translate function exists
697
- if (!$localize.translate) {
698
- $localize.translate = translate$1;
699
- }
700
- if (!$localize.TRANSLATIONS) {
701
- $localize.TRANSLATIONS = {};
702
- }
703
- Object.keys(translations).forEach(function (key) {
704
- $localize.TRANSLATIONS[key] = parseTranslation(translations[key]);
705
- });
706
- }
707
- /**
708
- * Remove all translations for `$localize`, if doing runtime translation.
709
- *
710
- * All translations that had been loading into memory using `loadTranslations()` will be removed.
711
- *
712
- * @see `loadTranslations()` for loading translations at runtime.
713
- * @see `$localize` for tagging messages as needing to be translated.
714
- *
715
- * @publicApi
716
- */
717
- function clearTranslations() {
718
- $localize.translate = undefined;
719
- $localize.TRANSLATIONS = {};
720
- }
721
- /**
722
- * Translate the text of the given message, using the loaded translations.
723
- *
724
- * This function may reorder (or remove) substitutions as indicated in the matching translation.
725
- */
726
- function translate$1(messageParts, substitutions) {
727
- try {
728
- return translate($localize.TRANSLATIONS, messageParts, substitutions);
729
- }
730
- catch (e) {
731
- console.warn(e.message);
732
- return [messageParts, substitutions];
733
- }
734
- }
735
-
736
- /**
737
- * @license
738
- * Copyright Google LLC All Rights Reserved.
739
- *
740
- * Use of this source code is governed by an MIT-style license that can be
741
- * found in the LICENSE file at https://angular.io/license
742
- */
743
-
744
- /**
745
- * @license
746
- * Copyright Google LLC All Rights Reserved.
747
- *
748
- * Use of this source code is governed by an MIT-style license that can be
749
- * found in the LICENSE file at https://angular.io/license
750
- */
751
-
752
- /**
753
- * @license
754
- * Copyright Google LLC All Rights Reserved.
755
- *
756
- * Use of this source code is governed by an MIT-style license that can be
757
- * found in the LICENSE file at https://angular.io/license
758
- */
759
-
760
- Object.defineProperty(exports, 'ɵcomputeMsgId', {
761
- enumerable: true,
762
- get: function () {
763
- return compiler.computeMsgId;
764
- }
765
- });
766
- exports.clearTranslations = clearTranslations;
767
- exports.loadTranslations = loadTranslations;
768
- exports.ɵMissingTranslationError = MissingTranslationError;
769
- exports.ɵfindEndOfBlock = findEndOfBlock;
770
- exports.ɵisMissingTranslationError = isMissingTranslationError;
771
- exports.ɵmakeParsedTranslation = makeParsedTranslation;
772
- exports.ɵmakeTemplateObject = makeTemplateObject;
773
- exports.ɵparseMessage = parseMessage;
774
- exports.ɵparseMetadata = parseMetadata;
775
- exports.ɵparseTranslation = parseTranslation;
776
- exports.ɵsplitBlock = splitBlock;
777
- exports.ɵtranslate = translate;
778
-
779
- Object.defineProperty(exports, '__esModule', { value: true });
780
-
781
- })));
782
- //# sourceMappingURL=localize.umd.js.map