@lingui/macro 3.15.0 → 3.16.0

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.
package/CHANGELOG.md ADDED
@@ -0,0 +1,406 @@
1
+ # Change Log
2
+
3
+ All notable changes to this project will be documented in this file.
4
+ See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
+
6
+ # [3.16.0](https://github.com/lingui/js-lingui/compare/v3.15.0...v3.16.0) (2023-01-18)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * **macro:** Extraction outputting empty objects ([#1331](https://github.com/lingui/js-lingui/issues/1331)) ([261265f](https://github.com/lingui/js-lingui/commit/261265f8a838386caa13d153e56e25363d806c19))
12
+ * **types:** `<Trans>`can have an `i18n` props ([#1308](https://github.com/lingui/js-lingui/issues/1308)) ([de01f8d](https://github.com/lingui/js-lingui/commit/de01f8df0d814f2a42d26d7235c72d4592325ad3))
13
+
14
+
15
+
16
+
17
+
18
+ # [3.15.0](https://github.com/lingui/js-lingui/compare/v3.14.0...v3.15.0) (2022-11-07)
19
+
20
+
21
+ ### Features
22
+
23
+ * Reduce @lingui/macro CPU and memory usage ([#1298](https://github.com/lingui/js-lingui/issues/1298)) ([c993d9e](https://github.com/lingui/js-lingui/commit/c993d9e8dfd7f1aa1a750dc5ec69f94b5bbd5c39))
24
+
25
+
26
+
27
+
28
+
29
+ # [3.14.0](https://github.com/lingui/js-lingui/compare/v3.13.3...v3.14.0) (2022-06-22)
30
+
31
+
32
+ ### Bug Fixes
33
+
34
+ * JSX attribute parsing issue when using html entities ([#1234](https://github.com/lingui/js-lingui/issues/1234)) ([98e9332](https://github.com/lingui/js-lingui/commit/98e93322216ab0fc87b8b545fbdd9263b4b6b76b))
35
+
36
+
37
+
38
+
39
+
40
+ ## [3.13.3](https://github.com/lingui/js-lingui/compare/v3.13.2...v3.13.3) (2022-04-24)
41
+
42
+
43
+ ### Bug Fixes
44
+
45
+ * JSX attribute parsing issue when using double quotes ([#1226](https://github.com/lingui/js-lingui/issues/1226)) ([27a7ded](https://github.com/lingui/js-lingui/commit/27a7ded08be7299417ccebddfd25fa39bda99e77))
46
+ * specify children for react v18 types ([#1230](https://github.com/lingui/js-lingui/issues/1230)) ([ee69736](https://github.com/lingui/js-lingui/commit/ee69736089d4c48117d85582b56a26c09cdf82ea))
47
+
48
+
49
+
50
+
51
+
52
+ ## [3.13.2](https://github.com/lingui/js-lingui/compare/v3.13.1...v3.13.2) (2022-01-24)
53
+
54
+ **Note:** Version bump only for package @lingui/macro
55
+
56
+
57
+
58
+
59
+
60
+ ## [3.13.1](https://github.com/lingui/js-lingui/compare/v3.13.0...v3.13.1) (2022-01-21)
61
+
62
+
63
+ ### Bug Fixes
64
+
65
+ * add lingui core to macro peer dependencies ([#1187](https://github.com/lingui/js-lingui/issues/1187)) ([daaa773](https://github.com/lingui/js-lingui/commit/daaa7738c1ca08ee30d5bec4c32214bf665cbfbe))
66
+ * remove the obsolete `defineMessages` function from the typings. ([#1179](https://github.com/lingui/js-lingui/issues/1179)) ([19b032f](https://github.com/lingui/js-lingui/commit/19b032f2d3634722c6bb9cc69ae3ae6c99773cb7))
67
+
68
+
69
+
70
+
71
+
72
+ # [3.13.0](https://github.com/lingui/js-lingui/compare/v3.12.1...v3.13.0) (2021-11-26)
73
+
74
+
75
+ ### Features
76
+
77
+ * msgctxt support ([#1094](https://github.com/lingui/js-lingui/issues/1094)) ([8ee42cb](https://github.com/lingui/js-lingui/commit/8ee42cbfe26bc6d055748dcf2713ab8ade7ec827))
78
+
79
+
80
+
81
+
82
+
83
+ ## [3.12.1](https://github.com/lingui/js-lingui/compare/v3.12.0...v3.12.1) (2021-09-28)
84
+
85
+
86
+ ### Bug Fixes
87
+
88
+ * **types:** correct types for macro with custom i18n instance ([#1141](https://github.com/lingui/js-lingui/issues/1141)) ([a9bffdd](https://github.com/lingui/js-lingui/commit/a9bffddf2ae0c9b6ab6a48552d085cfd53140cca))
89
+
90
+
91
+
92
+
93
+
94
+ # [3.12.0](https://github.com/lingui/js-lingui/compare/v3.11.1...v3.12.0) (2021-09-28)
95
+
96
+
97
+ ### Features
98
+
99
+ * **macro:** Add support for passing custom i18n instance ([#1139](https://github.com/lingui/js-lingui/issues/1139)) ([5cad96f](https://github.com/lingui/js-lingui/commit/5cad96fc68a4219178d6caf6ad5c02e2f68f68fa))
100
+
101
+
102
+
103
+
104
+
105
+ ## [3.11.1](https://github.com/lingui/js-lingui/compare/v3.11.0...v3.11.1) (2021-09-07)
106
+
107
+ **Note:** Version bump only for package @lingui/macro
108
+
109
+
110
+
111
+
112
+
113
+ # [3.11.0](https://github.com/lingui/js-lingui/compare/v3.10.4...v3.11.0) (2021-09-07)
114
+
115
+
116
+ ### Bug Fixes
117
+
118
+ * fix testing suite [#1098](https://github.com/lingui/js-lingui/issues/1098) ([1144cc7](https://github.com/lingui/js-lingui/commit/1144cc782b25113366245922131e58bc40b2047d))
119
+ * unicode chars were removed from .po files when extracting ([#1125](https://github.com/lingui/js-lingui/issues/1125)) ([d688329](https://github.com/lingui/js-lingui/commit/d688329c0457a080d5cd485a95e94ffa5e00c5ae))
120
+
121
+
122
+
123
+
124
+
125
+ ## [3.10.4](https://github.com/lingui/js-lingui/compare/v3.10.3...v3.10.4) (2021-06-16)
126
+
127
+ **Note:** Version bump only for package @lingui/macro
128
+
129
+
130
+
131
+
132
+
133
+ ## [3.10.3](https://github.com/lingui/js-lingui/compare/v3.10.2...v3.10.3) (2021-06-14)
134
+
135
+ **Note:** Version bump only for package @lingui/macro
136
+
137
+
138
+
139
+
140
+
141
+ ## [3.10.2](https://github.com/lingui/js-lingui/compare/v3.10.1...v3.10.2) (2021-06-08)
142
+
143
+ **Note:** Version bump only for package @lingui/macro
144
+
145
+
146
+
147
+
148
+
149
+ ## [3.10.1](https://github.com/lingui/js-lingui/compare/v3.10.0...v3.10.1) (2021-06-08)
150
+
151
+ **Note:** Version bump only for package @lingui/macro
152
+
153
+
154
+
155
+
156
+
157
+ # [3.10.0](https://github.com/lingui/js-lingui/compare/v3.9.0...v3.10.0) (2021-06-08)
158
+
159
+ **Note:** Version bump only for package @lingui/macro
160
+
161
+
162
+
163
+
164
+
165
+ # [3.9.0](https://github.com/lingui/js-lingui/compare/v3.8.10...v3.9.0) (2021-05-18)
166
+
167
+ **Note:** Version bump only for package @lingui/macro
168
+
169
+
170
+
171
+
172
+
173
+ ## [3.8.10](https://github.com/lingui/js-lingui/compare/v3.8.9...v3.8.10) (2021-04-19)
174
+
175
+ **Note:** Version bump only for package @lingui/macro
176
+
177
+
178
+
179
+
180
+
181
+ ## [3.8.9](https://github.com/lingui/js-lingui/compare/v3.8.8...v3.8.9) (2021-04-09)
182
+
183
+ **Note:** Version bump only for package @lingui/macro
184
+
185
+
186
+
187
+
188
+
189
+ ## [3.8.8](https://github.com/lingui/js-lingui/compare/v3.8.7...v3.8.8) (2021-04-09)
190
+
191
+
192
+ ### Bug Fixes
193
+
194
+ * unicode char was not extracting correctly ([3653f6f](https://github.com/lingui/js-lingui/commit/3653f6f62043a095a2babaf16a54280db9996228))
195
+
196
+
197
+
198
+
199
+
200
+ ## [3.8.7](https://github.com/lingui/js-lingui/compare/v3.8.6...v3.8.7) (2021-04-09)
201
+
202
+
203
+ ### Bug Fixes
204
+
205
+ * unicode chars in native environments + event emitter refactor ([#1036](https://github.com/lingui/js-lingui/issues/1036)) ([39fa90d](https://github.com/lingui/js-lingui/commit/39fa90d95c08f105f3f7feb17b65d9b8f916b73a))
206
+
207
+
208
+
209
+
210
+
211
+ ## [3.8.6](https://github.com/lingui/js-lingui/compare/v3.8.5...v3.8.6) (2021-04-08)
212
+
213
+
214
+ ### Bug Fixes
215
+
216
+ * unicode chars were extracting with double slashes ([#1035](https://github.com/lingui/js-lingui/issues/1035)) ([aed49b1](https://github.com/lingui/js-lingui/commit/aed49b15f3d13635a4e4a8d19fc4cb9f6e4a6f70))
217
+
218
+
219
+
220
+
221
+
222
+ ## [3.8.5](https://github.com/lingui/js-lingui/compare/v3.8.4...v3.8.5) (2021-04-08)
223
+
224
+ **Note:** Version bump only for package @lingui/macro
225
+
226
+
227
+
228
+
229
+
230
+ ## [3.8.4](https://github.com/lingui/js-lingui/compare/v3.8.3...v3.8.4) (2021-04-08)
231
+
232
+
233
+ ### Bug Fixes
234
+
235
+ * respect unicode chars in t macro ([#1032](https://github.com/lingui/js-lingui/issues/1032)) ([7597621](https://github.com/lingui/js-lingui/commit/7597621827f66e81a4e1fdf6ec64c986c9c88c7d))
236
+
237
+
238
+
239
+
240
+
241
+ ## [3.8.3](https://github.com/lingui/js-lingui/compare/v3.8.2...v3.8.3) (2021-04-05)
242
+
243
+
244
+ ### Bug Fixes
245
+
246
+ * extract works with template string id's ([#1027](https://github.com/lingui/js-lingui/issues/1027)) ([a17d629](https://github.com/lingui/js-lingui/commit/a17d629d82395cd86cc080648ef2ebe2a9653225))
247
+
248
+
249
+
250
+
251
+
252
+ ## [3.8.2](https://github.com/lingui/js-lingui/compare/v3.8.1...v3.8.2) (2021-03-31)
253
+
254
+ **Note:** Version bump only for package @lingui/macro
255
+
256
+
257
+
258
+
259
+
260
+ ## [3.8.1](https://github.com/lingui/js-lingui/compare/v3.8.0...v3.8.1) (2021-03-23)
261
+
262
+ **Note:** Version bump only for package @lingui/macro
263
+
264
+
265
+
266
+
267
+
268
+ # [3.8.0](https://github.com/lingui/js-lingui/compare/v3.7.2...v3.8.0) (2021-03-23)
269
+
270
+ **Note:** Version bump only for package @lingui/macro
271
+
272
+
273
+
274
+
275
+
276
+ ## [3.7.2](https://github.com/lingui/js-lingui/compare/v3.7.1...v3.7.2) (2021-03-14)
277
+
278
+ **Note:** Version bump only for package @lingui/macro
279
+
280
+
281
+
282
+
283
+
284
+ ## [3.7.1](https://github.com/lingui/js-lingui/compare/v3.7.0...v3.7.1) (2021-03-07)
285
+
286
+
287
+ ### Bug Fixes
288
+
289
+ * exports attribute on package.json, expo compat ([#997](https://github.com/lingui/js-lingui/issues/997)) ([79aa509](https://github.com/lingui/js-lingui/commit/79aa50998185847064d80f2a38be0ebcb64424f9))
290
+
291
+
292
+
293
+
294
+
295
+ # [3.7.0](https://github.com/lingui/js-lingui/compare/v3.6.0...v3.7.0) (2021-03-04)
296
+
297
+
298
+ ### Bug Fixes
299
+
300
+ * macro components should omit key prop [#994](https://github.com/lingui/js-lingui/issues/994) ([f2a4da0](https://github.com/lingui/js-lingui/commit/f2a4da08542567b77fc2ae8ebf9385f6d8055f6f))
301
+
302
+
303
+
304
+
305
+
306
+ # [3.6.0](https://github.com/lingui/js-lingui/compare/v3.5.1...v3.6.0) (2021-02-23)
307
+
308
+ **Note:** Version bump only for package @lingui/macro
309
+
310
+
311
+
312
+
313
+
314
+ ## [3.5.1](https://github.com/lingui/js-lingui/compare/v3.5.0...v3.5.1) (2021-02-09)
315
+
316
+
317
+ ### Bug Fixes
318
+
319
+ * @lingui/macro types for global environments ([#973](https://github.com/lingui/js-lingui/issues/973)) ([92a5ce7](https://github.com/lingui/js-lingui/commit/92a5ce786d979d4bd0f65a50962fdb3bd27d91d7))
320
+
321
+
322
+
323
+
324
+
325
+ # [3.5.0](https://github.com/lingui/js-lingui/compare/v3.4.0...v3.5.0) (2021-02-02)
326
+
327
+
328
+ ### Bug Fixes
329
+
330
+ * React macros fixes ([#958](https://github.com/lingui/js-lingui/issues/958)) ([353c537](https://github.com/lingui/js-lingui/commit/353c5379a22473293aafcb4651db387e72c82a7a))
331
+ * wrong typing of Trans macro component prop ([#960](https://github.com/lingui/js-lingui/issues/960)) ([57482c0](https://github.com/lingui/js-lingui/commit/57482c0f1ecab7c266628e7c9be2bd10538c7a57))
332
+
333
+
334
+
335
+
336
+
337
+ # [3.4.0](https://github.com/lingui/js-lingui/compare/v3.3.0...v3.4.0) (2021-01-13)
338
+
339
+
340
+ ### Bug Fixes
341
+
342
+ * Last scaped brackets were not unscaped ([db2f768](https://github.com/lingui/js-lingui/commit/db2f7684f4a8b6babe1c87fef9fb2775ebf3a97c))
343
+
344
+
345
+
346
+
347
+
348
+ # [3.3.0](https://github.com/lingui/js-lingui/compare/v3.2.3...v3.3.0) (2020-12-08)
349
+
350
+
351
+ ### Bug Fixes
352
+
353
+ * macro underscore type ([#884](https://github.com/lingui/js-lingui/issues/884)) ([5cade19](https://github.com/lingui/js-lingui/commit/5cade1924dd038ba73ff85cdcf7ce80d31ddbd0f))
354
+ * scaped literals double backslash formatting ([#898](https://github.com/lingui/js-lingui/issues/898)) ([fc8c628](https://github.com/lingui/js-lingui/commit/fc8c628e05522167c5ad76e2cb8c6161be95b8b4))
355
+ * select prop types ([#890](https://github.com/lingui/js-lingui/issues/890)) ([672fb1f](https://github.com/lingui/js-lingui/commit/672fb1f5731fe0abeb2fa7ea0de78827e547873c))
356
+
357
+
358
+ ### Features
359
+
360
+ * add support for runtimeConfigModule w/ Trans ([#895](https://github.com/lingui/js-lingui/issues/895)) ([23b06b5](https://github.com/lingui/js-lingui/commit/23b06b5dfbf0db306cdfab83801898caceb5a8b0))
361
+
362
+
363
+
364
+
365
+
366
+ ## [3.2.3](https://github.com/lingui/js-lingui/compare/v3.2.2...v3.2.3) (2020-11-22)
367
+
368
+ **Note:** Version bump only for package @lingui/macro
369
+
370
+
371
+
372
+
373
+
374
+ ## [3.2.2](https://github.com/lingui/js-lingui/compare/v3.2.1...v3.2.2) (2020-11-20)
375
+
376
+
377
+ ### Bug Fixes
378
+
379
+ * parse template strings in t and defineMessage macros ([#862](https://github.com/lingui/js-lingui/issues/862)) ([024a7e6](https://github.com/lingui/js-lingui/commit/024a7e61e8d76efc2b4a8dd3bb4e0a3932945496))
380
+
381
+
382
+
383
+
384
+
385
+ # [3.2.0](https://github.com/lingui/js-lingui/compare/v3.1.0...v3.2.0) (2020-11-12)
386
+
387
+
388
+ ### Bug Fixes
389
+
390
+ * t macro as function not extracting ([#846](https://github.com/lingui/js-lingui/issues/846)) ([d819bfc](https://github.com/lingui/js-lingui/commit/d819bfc74707a8766bfe1b1a3d43edce97f8f265))
391
+
392
+
393
+
394
+
395
+
396
+ # [3.1.0](https://github.com/lingui/js-lingui/compare/v3.0.3...v3.1.0) (2020-11-10)
397
+
398
+
399
+ ### Bug Fixes
400
+
401
+ * add type for t macro as function ([#821](https://github.com/lingui/js-lingui/issues/821)) ([7f09c2d](https://github.com/lingui/js-lingui/commit/7f09c2d4ddd88d885a5df23e1b0c267f937abaaf))
402
+
403
+
404
+ ### Features
405
+
406
+ * accept t as function ([c0c08ba](https://github.com/lingui/js-lingui/commit/c0c08bab0f16d526d1f69734d6d0e5e1a89edd68))
package/build/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 Tomáš Ehrlich
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -4,13 +4,13 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.CONTEXT = exports.EXTRACT_MARK = exports.COMMENT = exports.MESSAGE = exports.ID = void 0;
7
- var ID = "id";
7
+ const ID = "id";
8
8
  exports.ID = ID;
9
- var MESSAGE = "message";
9
+ const MESSAGE = "message";
10
10
  exports.MESSAGE = MESSAGE;
11
- var COMMENT = "comment";
11
+ const COMMENT = "comment";
12
12
  exports.COMMENT = COMMENT;
13
- var EXTRACT_MARK = "i18n";
13
+ const EXTRACT_MARK = "i18n";
14
14
  exports.EXTRACT_MARK = EXTRACT_MARK;
15
- var CONTEXT = "context";
15
+ const CONTEXT = "context";
16
16
  exports.CONTEXT = CONTEXT;
File without changes
package/build/icu.js ADDED
@@ -0,0 +1,113 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _types = require("@babel/types");
9
+
10
+ const metaOptions = ["id", "comment", "props"];
11
+ const escapedMetaOptionsRe = new RegExp(`^_(${metaOptions.join("|")})$`);
12
+
13
+ class ICUMessageFormat {
14
+ fromTokens(tokens) {
15
+ return (Array.isArray(tokens) ? tokens : [tokens]).map(token => this.processToken(token)).filter(Boolean).reduce((props, message) => ({ ...message,
16
+ message: props.message + message.message,
17
+ values: { ...props.values,
18
+ ...message.values
19
+ },
20
+ jsxElements: { ...props.jsxElements,
21
+ ...message.jsxElements
22
+ }
23
+ }), {
24
+ message: "",
25
+ values: {},
26
+ jsxElements: {}
27
+ });
28
+ }
29
+
30
+ processToken(token) {
31
+ const jsxElements = {};
32
+
33
+ if (token.type === "text") {
34
+ return {
35
+ message: token.value
36
+ };
37
+ } else if (token.type === "arg") {
38
+ if (token.value !== undefined && (0, _types.isJSXEmptyExpression)(token.value)) {
39
+ return null;
40
+ }
41
+
42
+ const values = token.value !== undefined ? {
43
+ [token.name]: token.value
44
+ } : {};
45
+
46
+ switch (token.format) {
47
+ case "plural":
48
+ case "select":
49
+ case "selectordinal":
50
+ const formatOptions = Object.keys(token.options).filter(key => token.options[key] != null).map(key => {
51
+ let value = token.options[key];
52
+ key = key.replace(escapedMetaOptionsRe, "$1");
53
+
54
+ if (key === "offset") {
55
+ // offset has special syntax `offset:number`
56
+ return `offset:${value}`;
57
+ }
58
+
59
+ if (typeof value !== "string") {
60
+ // process tokens from nested formatters
61
+ const {
62
+ message,
63
+ values: childValues,
64
+ jsxElements: childJsxElements
65
+ } = this.fromTokens(value);
66
+ Object.assign(values, childValues);
67
+ Object.assign(jsxElements, childJsxElements);
68
+ value = message;
69
+ }
70
+
71
+ return `${key} {${value}}`;
72
+ }).join(" ");
73
+ return {
74
+ message: `{${token.name}, ${token.format}, ${formatOptions}}`,
75
+ values,
76
+ jsxElements
77
+ };
78
+
79
+ default:
80
+ return {
81
+ message: `{${token.name}}`,
82
+ values
83
+ };
84
+ }
85
+ } else if (token.type === "element") {
86
+ let message = "";
87
+ let elementValues = {};
88
+ Object.assign(jsxElements, {
89
+ [token.name]: token.value
90
+ });
91
+ token.children.forEach(child => {
92
+ const {
93
+ message: childMessage,
94
+ values: childValues,
95
+ jsxElements: childJsxElements
96
+ } = this.fromTokens(child);
97
+ message += childMessage;
98
+ Object.assign(elementValues, childValues);
99
+ Object.assign(jsxElements, childJsxElements);
100
+ });
101
+ return {
102
+ message: token.children.length ? `<${token.name}>${message}</${token.name}>` : `<${token.name}/>`,
103
+ values: elementValues,
104
+ jsxElements
105
+ };
106
+ }
107
+
108
+ throw new Error(`Unknown token type ${token.type}`);
109
+ }
110
+
111
+ }
112
+
113
+ exports.default = ICUMessageFormat;
@@ -175,6 +175,7 @@ export type TransProps = {
175
175
  children?: React.ReactNode
176
176
  component?: React.ComponentType<TransRenderProps>
177
177
  render?: (props: TransRenderProps) => ReactElement<any, any> | null
178
+ i18n?: I18n
178
179
  }
179
180
 
180
181
  export type ChoiceProps = {