use-intl 2.10.0-alpha.3 → 2.10.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.
Files changed (80) hide show
  1. package/LICENSE +21 -0
  2. package/dist/core/use-intl.esm.js +27 -140
  3. package/dist/core/use-intl.esm.js.map +1 -1
  4. package/dist/core/use-intl.esm2.js +38 -41
  5. package/dist/core/use-intl.esm2.js.map +1 -1
  6. package/dist/core/use-intl.esm3.js +151 -35
  7. package/dist/core/use-intl.esm3.js.map +1 -1
  8. package/dist/core/use-intl.esm4.js +56 -12
  9. package/dist/core/use-intl.esm4.js.map +1 -1
  10. package/dist/core/use-intl.esm5.js +12 -56
  11. package/dist/core/use-intl.esm5.js.map +1 -1
  12. package/dist/core/use-intl.esm6.js +29 -7
  13. package/dist/core/use-intl.esm6.js.map +1 -1
  14. package/dist/core/use-intl.esm7.js +9 -9
  15. package/dist/core/use-intl.esm7.js.map +1 -1
  16. package/dist/core/use-intl.esm8.js +7 -29
  17. package/dist/core/use-intl.esm8.js.map +1 -1
  18. package/dist/react/IntlContext.d.ts +19 -2
  19. package/dist/react/IntlProvider.d.ts +16 -2
  20. package/dist/react/use-intl.esm.js +25 -6
  21. package/dist/react/use-intl.esm.js.map +1 -1
  22. package/dist/react/use-intl.esm2.js +21 -20
  23. package/dist/react/use-intl.esm2.js.map +1 -1
  24. package/dist/react/use-intl.esm3.js +20 -21
  25. package/dist/react/use-intl.esm3.js.map +1 -1
  26. package/dist/react/use-intl.esm4.js +4 -46
  27. package/dist/react/use-intl.esm4.js.map +1 -1
  28. package/dist/react/use-intl.esm5.js +46 -4
  29. package/dist/react/use-intl.esm5.js.map +1 -1
  30. package/dist/react/use-intl.esm6.js +1 -1
  31. package/dist/react/use-intl.esm7.js.map +1 -1
  32. package/dist/react/use-intl.esm8.js +8 -26
  33. package/dist/react/use-intl.esm8.js.map +1 -1
  34. package/dist/react/use-intl.esm9.js +38 -9
  35. package/dist/react/use-intl.esm9.js.map +1 -1
  36. package/dist/react/useIntlContext.d.ts +1 -1
  37. package/dist/src/core/createBaseTranslator.js +7 -11
  38. package/dist/src/core/createBaseTranslator.js.map +1 -1
  39. package/dist/src/core/createIntl.js +2 -2
  40. package/dist/src/core/createIntl.js.map +1 -1
  41. package/dist/src/core/createTranslatorImpl.js +1 -1
  42. package/dist/src/core/createTranslatorImpl.js.map +1 -1
  43. package/dist/src/react/IntlContext.d.ts +19 -2
  44. package/dist/src/react/IntlContext.js.map +1 -1
  45. package/dist/src/react/IntlProvider.d.ts +16 -2
  46. package/dist/src/react/IntlProvider.js +13 -4
  47. package/dist/src/react/IntlProvider.js.map +1 -1
  48. package/dist/src/react/useIntlContext.d.ts +1 -1
  49. package/dist/src/react/useIntlContext.js +1 -1
  50. package/dist/src/react/useIntlContext.js.map +1 -1
  51. package/dist/use-intl.cjs.development.js +28 -37
  52. package/dist/use-intl.cjs.development.js.map +1 -1
  53. package/dist/use-intl.cjs.production.min.js +1 -1
  54. package/dist/use-intl.cjs.production.min.js.map +1 -1
  55. package/dist/use-intl.esm.js +7 -7
  56. package/package.json +4 -3
  57. package/src/core/createBaseTranslator.tsx +7 -11
  58. package/src/core/createIntl.tsx +2 -2
  59. package/src/core/createTranslatorImpl.tsx +1 -1
  60. package/src/react/IntlContext.tsx +20 -2
  61. package/src/react/IntlProvider.tsx +36 -5
  62. package/src/react/useIntlContext.tsx +1 -1
  63. package/CHANGELOG.md +0 -463
  64. package/dist/react/IntlContextValue.d.ts +0 -19
  65. package/dist/react/IntlProviderProps.d.ts +0 -15
  66. package/dist/react/getIntlContextValue.d.ts +0 -18
  67. package/dist/react/use-intl.esm10.js +0 -44
  68. package/dist/react/use-intl.esm10.js.map +0 -1
  69. package/dist/src/react/IntlContextValue.d.ts +0 -19
  70. package/dist/src/react/IntlContextValue.js +0 -2
  71. package/dist/src/react/IntlContextValue.js.map +0 -1
  72. package/dist/src/react/IntlProviderProps.d.ts +0 -15
  73. package/dist/src/react/IntlProviderProps.js +0 -2
  74. package/dist/src/react/IntlProviderProps.js.map +0 -1
  75. package/dist/src/react/getIntlContextValue.d.ts +0 -18
  76. package/dist/src/react/getIntlContextValue.js +0 -21
  77. package/dist/src/react/getIntlContextValue.js.map +0 -1
  78. package/src/react/IntlContextValue.tsx +0 -21
  79. package/src/react/IntlProviderProps.tsx +0 -17
  80. package/src/react/getIntlContextValue.tsx +0 -30
package/CHANGELOG.md DELETED
@@ -1,463 +0,0 @@
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
- ## 2.9.1 (2022-11-03)
7
-
8
- **Note:** Version bump only for package use-intl
9
-
10
-
11
-
12
-
13
-
14
- # 2.9.0 (2022-10-27)
15
-
16
-
17
- ### Features
18
-
19
- * Next.js 13 compatibility ([#140](https://github.com/amannn/next-intl/tree/main/packages/use-intl/issues/140)) ([65326a0](https://github.com/amannn/next-intl/tree/main/packages/use-intl/commit/65326a0b47980f260df466a283a6e7a0aa5e1cd0)), closes [#139](https://github.com/amannn/next-intl/tree/main/packages/use-intl/issues/139)
20
-
21
-
22
-
23
-
24
-
25
- # 2.8.0 (2022-10-18)
26
-
27
-
28
- ### Features
29
-
30
- * Provide `createTranslator` and `createIntl` by extracting a React-agnostic core library. Thanks to David Brands from Marvia for sponsoring the work on this feature, participating in discussion and providing feedback! ([#137](https://github.com/amannn/next-intl/tree/main/packages/use-intl/issues/137)) ([91f7489](https://github.com/amannn/next-intl/tree/main/packages/use-intl/commit/91f748972008b8587553b48aa36c95d7348b4b0c))
31
-
32
-
33
-
34
-
35
-
36
- ## 2.7.6 (2022-09-22)
37
-
38
- **Note:** Version bump only for package use-intl
39
-
40
-
41
-
42
-
43
-
44
- ## 2.7.5 (2022-08-30)
45
-
46
- **Note:** Version bump only for package use-intl
47
-
48
-
49
-
50
-
51
-
52
- ## 2.7.4 (2022-05-30)
53
-
54
-
55
- ### Bug Fixes
56
-
57
- * Adapt TypeScript validation to work with messages files that only have a single top-level namespace ([#115](https://github.com/amannn/next-intl/tree/main/packages/use-intl/issues/115)) ([cf0b83e](https://github.com/amannn/next-intl/tree/main/packages/use-intl/commit/cf0b83e3a591cfe87e17537c3ca0c7000cc70b1e))
58
-
59
-
60
-
61
-
62
-
63
- ## 2.7.3 (2022-05-20)
64
-
65
-
66
- ### Bug Fixes
67
-
68
- * Add back the ability to render the provider without messages ([#113](https://github.com/amannn/next-intl/tree/main/packages/use-intl/issues/113)) ([8395822](https://github.com/amannn/next-intl/tree/main/packages/use-intl/commit/8395822fa17cd0a04b88f8edce3b20e5e613fc78))
69
-
70
-
71
-
72
-
73
-
74
- ## 2.7.2 (2022-05-10)
75
-
76
-
77
- ### Bug Fixes
78
-
79
- * Enable tree-shaking ([#108](https://github.com/amannn/next-intl/tree/main/packages/use-intl/issues/108)) ([157b0e2](https://github.com/amannn/next-intl/tree/main/packages/use-intl/commit/157b0e28376055e7e34e86007c51d008c8e214aa))
80
-
81
-
82
-
83
-
84
-
85
- ## 2.7.1 (2022-04-28)
86
-
87
-
88
- ### Bug Fixes
89
-
90
- * Allow null message values ([#110](https://github.com/amannn/next-intl/tree/main/packages/use-intl/issues/110)) ([14ae8ff](https://github.com/amannn/next-intl/tree/main/packages/use-intl/commit/14ae8ffdf1b295873f14081e2c3709d0f9bd2b9e))
91
-
92
-
93
-
94
-
95
-
96
- # 2.7.0 (2022-04-28)
97
-
98
-
99
- ### Features
100
-
101
- * Warn for invalid namespace keys ([#106](https://github.com/amannn/next-intl/tree/main/packages/use-intl/issues/106)) ([e86ab28](https://github.com/amannn/next-intl/tree/main/packages/use-intl/commit/e86ab28b9180b866ce1a0a9173355d4b686b7d07))
102
-
103
-
104
-
105
-
106
-
107
- # 2.6.0 (2022-04-08)
108
-
109
-
110
- ### Features
111
-
112
- * Support React 18 ([#98](https://github.com/amannn/next-intl/tree/main/packages/use-intl/issues/98)) ([38614eb](https://github.com/amannn/next-intl/tree/main/packages/use-intl/commit/38614eb9c6d6fb96704424d7f3ff8a67a24b789e))
113
-
114
-
115
-
116
-
117
-
118
- # 2.5.0 (2022-04-01)
119
-
120
-
121
- ### Features
122
-
123
- * Type safe messages ([#93](https://github.com/amannn/next-intl/tree/main/packages/use-intl/issues/93)) ([13b49b1](https://github.com/amannn/next-intl/tree/main/packages/use-intl/commit/13b49b138bc0ec3adbe661af6a70dfabfe7e86b0))
124
-
125
-
126
-
127
-
128
-
129
-
130
-
131
-
132
-
133
- ## 2.4.1 (2022-03-24)
134
-
135
-
136
- ### Bug Fixes
137
-
138
- * Overwrite prerelease ([6caf5c4](https://github.com/amannn/next-intl/tree/main/packages/use-intl/commit/6caf5c48a35179f802503bc6580469187765c837))
139
-
140
-
141
-
142
-
143
-
144
- # [2.4.0](https://github.com/amannn/next-intl/tree/main/packages/use-intl/compare/v2.3.5...v2.4.0) (2022-02-08)
145
-
146
-
147
- ### Features
148
-
149
- * Default translation values ([#86](https://github.com/amannn/next-intl/tree/main/packages/use-intl/issues/86)) ([0ed5e70](https://github.com/amannn/next-intl/tree/main/packages/use-intl/commit/0ed5e70ffc57dcdb1b7b9270dbce9e8475b3f478))
150
-
151
-
152
-
153
-
154
-
155
- ## 2.3.5 (2022-01-19)
156
-
157
-
158
- ### Bug Fixes
159
-
160
- * Support identical wrappers with identical text content in rich text ([#80](https://github.com/amannn/next-intl/tree/main/packages/use-intl/issues/80)) ([b35bb9f](https://github.com/amannn/next-intl/tree/main/packages/use-intl/commit/b35bb9ffc5fa56c6260b6b424be3cd875f199aef))
161
-
162
-
163
-
164
-
165
-
166
- ## 2.3.4 (2022-01-04)
167
-
168
-
169
- ### Bug Fixes
170
-
171
- * Allow usage outside of Next.js (e.g. Jest and Storybook) ([#76](https://github.com/amannn/next-intl/tree/main/packages/use-intl/issues/76)) ([7c6925b](https://github.com/amannn/next-intl/tree/main/packages/use-intl/commit/7c6925b39338be95c1c940c67a1ae2f5e3f85cdd))
172
-
173
-
174
-
175
-
176
-
177
- ## 2.3.3 (2021-12-23)
178
-
179
- **Note:** Version bump only for package use-intl
180
-
181
-
182
-
183
-
184
-
185
- ## 2.3.2 (2021-12-23)
186
-
187
- **Note:** Version bump only for package use-intl
188
-
189
-
190
-
191
-
192
-
193
- ## 2.3.1 (2021-12-23)
194
-
195
- **Note:** Version bump only for package use-intl
196
-
197
-
198
-
199
-
200
-
201
- # 2.3.0 (2021-11-24)
202
-
203
-
204
- ### Features
205
-
206
- * Add `useLocale` and `useTimeZone` ([#67](https://github.com/amannn/next-intl/tree/main/packages/use-intl/issues/67)) ([7833f4a](https://github.com/amannn/next-intl/tree/main/packages/use-intl/commit/7833f4adc1aadc937cbaa550a968ef6f7b4f5ee1))
207
-
208
-
209
-
210
-
211
-
212
- ## 2.2.1 (2021-11-23)
213
-
214
-
215
- ### Bug Fixes
216
-
217
- * Clearer error message when no messages are provided ([#66](https://github.com/amannn/next-intl/tree/main/packages/use-intl/issues/66)) ([742729a](https://github.com/amannn/next-intl/tree/main/packages/use-intl/commit/742729aaddd63367efc2b79ef0cdf93545abdfb0))
218
-
219
-
220
-
221
-
222
-
223
- # 2.2.0 (2021-11-02)
224
-
225
-
226
- ### Features
227
-
228
- * TypeScript improvements: Use enum type for `style` of `NumberFormatOptions`, only allow passing React children to messages rendered with `t.rich` and update `tslib` ([#63](https://github.com/amannn/next-intl/tree/main/packages/use-intl/issues/63)) ([d73e935](https://github.com/amannn/next-intl/tree/main/packages/use-intl/commit/d73e9358bf13c87c0a653bd9fbed35e41548ff1d))
229
-
230
-
231
-
232
-
233
-
234
- ## 2.1.1 (2021-10-28)
235
-
236
- **Note:** Version bump only for package use-intl
237
-
238
-
239
-
240
-
241
-
242
- # 2.1.0 (2021-10-27)
243
-
244
-
245
- ### Features
246
-
247
- * Support Next.js 12 ([#61](https://github.com/amannn/next-intl/tree/main/packages/use-intl/issues/61)) ([0391cc8](https://github.com/amannn/next-intl/tree/main/packages/use-intl/commit/0391cc85d3401bca9df29080a569957f6be93c85))
248
-
249
-
250
-
251
-
252
-
253
- ## 2.0.5 (2021-09-28)
254
-
255
- **Note:** Version bump only for package use-intl
256
-
257
-
258
-
259
-
260
-
261
- ## 2.0.4 (2021-09-28)
262
-
263
- **Note:** Version bump only for package use-intl
264
-
265
-
266
-
267
-
268
-
269
- ## 2.0.3 (2021-09-17)
270
-
271
- **Note:** Version bump only for package use-intl
272
-
273
-
274
-
275
-
276
-
277
- ## 2.0.2 (2021-09-17)
278
-
279
-
280
- ### Bug Fixes
281
-
282
- * Render correct messages when the namespace changes in `useTranslations` ([#58](https://github.com/amannn/next-intl/tree/main/packages/use-intl/issues/58)) ([b8f7dab](https://github.com/amannn/next-intl/tree/main/packages/use-intl/commit/b8f7dab0e3a213a91bdcd7929547cd01ba0b5f54))
283
-
284
-
285
-
286
-
287
-
288
- ## 2.0.1 (2021-09-04)
289
-
290
- **Note:** Version bump only for package use-intl
291
-
292
-
293
-
294
-
295
-
296
- # 2.0.0 (2021-08-26)
297
-
298
-
299
- * feat!: Use a separate API for rich text formatting to avoid type casting in TypeScript #54 ([4c13a64](https://github.com/amannn/next-intl/tree/main/packages/use-intl/commit/4c13a644ce99992d9e57887afe35a09b8e3d6572)), closes [#54](https://github.com/amannn/next-intl/tree/main/packages/use-intl/issues/54)
300
-
301
-
302
- ### BREAKING CHANGES
303
-
304
- * Instead of using the `t` function for formatting both regular messages and rich text, this function will only work for regular messages now. For rich text you can use `t.rich` instead now.
305
-
306
-
307
-
308
-
309
-
310
- ## 1.5.1 (2021-08-13)
311
-
312
-
313
- ### Bug Fixes
314
-
315
- * Improve API for rendering raw messages and add docs ([#51](https://github.com/amannn/next-intl/tree/main/packages/use-intl/issues/51)) ([19f4a7e](https://github.com/amannn/next-intl/tree/main/packages/use-intl/commit/19f4a7e4e81e1cff78dc7e3f337dce69800be280))
316
-
317
-
318
-
319
-
320
-
321
- # 1.5.0 (2021-08-10)
322
-
323
-
324
- ### Features
325
-
326
- * Add flag to return raw messages ([#48](https://github.com/amannn/next-intl/tree/main/packages/use-intl/issues/48)) ([b34e19f](https://github.com/amannn/next-intl/tree/main/packages/use-intl/commit/b34e19ff618308b7d0c01e7969975215d96ff608))
327
-
328
-
329
-
330
-
331
-
332
- ## 1.4.7 (2021-08-02)
333
-
334
-
335
- ### Bug Fixes
336
-
337
- * Adjust default for `onError` of the provider to log errors correctly ([#46](https://github.com/amannn/next-intl/tree/main/packages/use-intl/issues/46)) ([d0a1986](https://github.com/amannn/next-intl/tree/main/packages/use-intl/commit/d0a1986905e30acac40630e9ea6d099caad617fb))
338
-
339
-
340
-
341
-
342
-
343
- ## 1.4.6 (2021-08-02)
344
-
345
-
346
- ### Bug Fixes
347
-
348
- * Use `timeZone` in translation function from `useTranslations` ([#45](https://github.com/amannn/next-intl/tree/main/packages/use-intl/issues/45)) ([ebf75f2](https://github.com/amannn/next-intl/tree/main/packages/use-intl/commit/ebf75f2add0ddc46f89768e9481bb16c56f94720))
349
-
350
-
351
-
352
-
353
-
354
- ## 1.4.5 (2021-07-26)
355
-
356
- **Note:** Version bump only for package use-intl
357
-
358
-
359
-
360
-
361
-
362
- ## 1.4.4 (2021-07-08)
363
-
364
- **Note:** Version bump only for package use-intl
365
-
366
-
367
-
368
-
369
-
370
- ## 1.4.3 (2021-07-08)
371
-
372
- **Note:** Version bump only for package use-intl
373
-
374
-
375
-
376
-
377
-
378
- ## [1.4.2](https://github.com/amannn/next-intl/tree/main/packages/use-intl/compare/v1.4.1...v1.4.2) (2021-06-16)
379
-
380
-
381
- ### Bug Fixes
382
-
383
- * Don't require `react-dom` as a peer dependency ([#39](https://github.com/amannn/next-intl/tree/main/packages/use-intl/issues/39)) ([39edfcd](https://github.com/amannn/next-intl/tree/main/packages/use-intl/commit/39edfcd9091e09570fc2152cda6a1e9ae5e7c210))
384
-
385
-
386
-
387
-
388
-
389
- ## 1.3.11 (2021-05-07)
390
-
391
- **Note:** Version bump only for package use-intl
392
-
393
-
394
-
395
-
396
-
397
- ## 1.3.10 (2021-05-02)
398
-
399
- **Note:** Version bump only for package use-intl
400
-
401
-
402
-
403
-
404
-
405
- ## 1.3.9 (2021-05-02)
406
-
407
- **Note:** Version bump only for package use-intl
408
-
409
-
410
-
411
-
412
-
413
- ## 1.3.8 (2021-03-26)
414
-
415
- **Note:** Version bump only for package use-intl
416
-
417
-
418
-
419
-
420
-
421
- ## 1.3.7 (2021-02-12)
422
-
423
- **Note:** Version bump only for package use-intl
424
-
425
-
426
-
427
-
428
-
429
- ## 1.3.6 (2021-02-09)
430
-
431
- **Note:** Version bump only for package use-intl
432
-
433
-
434
-
435
-
436
-
437
- ## 1.3.5 (2021-02-09)
438
-
439
- **Note:** Version bump only for package use-intl
440
-
441
-
442
-
443
-
444
-
445
- ## 1.3.4 (2021-02-09)
446
-
447
- **Note:** Version bump only for package use-intl
448
-
449
-
450
-
451
-
452
-
453
- ## [1.3.3](https://github.com/amannn/next-intl/tree/main/packages/use-intl/compare/v1.3.2...v1.3.3) (2021-02-09)
454
-
455
-
456
- ### Bug Fixes
457
-
458
- * Update DateTimeFormatOptions ([#29](https://github.com/amannn/next-intl/tree/main/packages/use-intl/issues/29)) ([91a8f52](https://github.com/amannn/next-intl/tree/main/packages/use-intl/commit/91a8f5216a9ef2a0e76be6e3e8bd706f5c7496a3))
459
-
460
-
461
- ## Previous releases
462
-
463
- See [next-intl changelog](https://github.com/amannn/next-intl/blob/main/CHANGELOG.md).
@@ -1,19 +0,0 @@
1
- import AbstractIntlMessages from '../core/AbstractIntlMessages';
2
- import Formats from '../core/Formats';
3
- import IntlError from '../core/IntlError';
4
- import { RichTranslationValues } from '../core/TranslationValues';
5
- declare type IntlContextValue = {
6
- messages?: AbstractIntlMessages;
7
- locale: string;
8
- formats?: Partial<Formats>;
9
- timeZone?: string;
10
- onError(error: IntlError): void;
11
- getMessageFallback(info: {
12
- error: IntlError;
13
- key: string;
14
- namespace?: string;
15
- }): string;
16
- now?: Date;
17
- defaultTranslationValues?: RichTranslationValues;
18
- };
19
- export default IntlContextValue;
@@ -1,15 +0,0 @@
1
- import { ReactNode } from 'react';
2
- import { AbstractIntlMessages } from '../core';
3
- import IntlConfiguration from '../core/IntlConfiguration';
4
- import { RichTranslationValues } from '../core/TranslationValues';
5
- declare type IntlProviderProps = IntlConfiguration & {
6
- /** All components that use the provided hooks should be within this tree. */
7
- children: ReactNode;
8
- /** Global default values for translation values and rich text elements.
9
- * Can be used for consistent usage or styling of rich text elements.
10
- * Defaults will be overidden by locally provided values. */
11
- defaultTranslationValues?: RichTranslationValues;
12
- /** All messages that will be available in your components. */
13
- messages?: AbstractIntlMessages;
14
- };
15
- export default IntlProviderProps;
@@ -1,18 +0,0 @@
1
- import IntlProviderProps from './IntlProviderProps';
2
- /**
3
- * Enhances the incoming props with defaults.
4
- */
5
- export default function getIntlContextValue({ getMessageFallback, messages, onError, ...rest }: Omit<IntlProviderProps, 'children'>): {
6
- messages: import("../core/AbstractIntlMessages").default | undefined;
7
- onError: (error: import("..").IntlError) => void;
8
- getMessageFallback: (info: {
9
- error: import("..").IntlError;
10
- key: string;
11
- namespace?: string | undefined;
12
- }) => string;
13
- locale: string;
14
- formats?: Partial<import("../core/Formats").default> | undefined;
15
- timeZone?: string | undefined;
16
- now?: Date | undefined;
17
- defaultTranslationValues?: import("..").RichTranslationValues | undefined;
18
- };
@@ -1,44 +0,0 @@
1
- import { useRef, useMemo } from 'react';
2
- import createBaseTranslator, { getMessagesOrError } from '../core/use-intl.esm7.js';
3
- import resolveNamespace from '../core/use-intl.esm6.js';
4
- import useIntlContext from './use-intl.esm9.js';
5
-
6
- function useTranslationsImpl(allMessages, namespace, namespacePrefix) {
7
- var _useIntlContext = useIntlContext(),
8
- defaultTranslationValues = _useIntlContext.defaultTranslationValues,
9
- globalFormats = _useIntlContext.formats,
10
- getMessageFallback = _useIntlContext.getMessageFallback,
11
- locale = _useIntlContext.locale,
12
- onError = _useIntlContext.onError,
13
- timeZone = _useIntlContext.timeZone; // The `namespacePrefix` is part of the type system.
14
- // See the comment in the hook invocation.
15
-
16
-
17
- allMessages = allMessages[namespacePrefix];
18
- namespace = resolveNamespace(namespace, namespacePrefix);
19
- var cachedFormatsByLocaleRef = useRef({});
20
- var messagesOrError = useMemo(function () {
21
- return getMessagesOrError({
22
- messages: allMessages,
23
- namespace: namespace,
24
- onError: onError
25
- });
26
- }, [allMessages, namespace, onError]);
27
- var translate = useMemo(function () {
28
- return createBaseTranslator({
29
- cachedFormatsByLocale: cachedFormatsByLocaleRef.current,
30
- getMessageFallback: getMessageFallback,
31
- messagesOrError: messagesOrError,
32
- defaultTranslationValues: defaultTranslationValues,
33
- namespace: namespace,
34
- onError: onError,
35
- formats: globalFormats,
36
- locale: locale,
37
- timeZone: timeZone
38
- });
39
- }, [getMessageFallback, messagesOrError, defaultTranslationValues, namespace, onError, globalFormats, locale, timeZone]);
40
- return translate;
41
- }
42
-
43
- export { useTranslationsImpl as default };
44
- //# sourceMappingURL=use-intl.esm10.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"use-intl.esm10.js","sources":["../../src/react/useTranslationsImpl.tsx"],"sourcesContent":["import {IntlMessageFormat} from 'intl-messageformat';\nimport {useMemo, useRef} from 'react';\nimport AbstractIntlMessages from '../core/AbstractIntlMessages';\nimport createBaseTranslator, {\n getMessagesOrError\n} from '../core/createBaseTranslator';\nimport resolveNamespace from '../core/resolveNamespace';\nimport NestedKeyOf from '../core/utils/NestedKeyOf';\nimport useIntlContext from './useIntlContext';\n\nexport default function useTranslationsImpl<\n Messages extends AbstractIntlMessages,\n NestedKey extends NestedKeyOf<Messages>\n>(allMessages: Messages, namespace: NestedKey, namespacePrefix: string) {\n const {\n defaultTranslationValues,\n formats: globalFormats,\n getMessageFallback,\n locale,\n onError,\n timeZone\n } = useIntlContext();\n\n // The `namespacePrefix` is part of the type system.\n // See the comment in the hook invocation.\n allMessages = allMessages[namespacePrefix] as Messages;\n namespace = resolveNamespace(namespace, namespacePrefix) as NestedKey;\n\n const cachedFormatsByLocaleRef = useRef<\n Record<string, Record<string, IntlMessageFormat>>\n >({});\n\n const messagesOrError = useMemo(\n () => getMessagesOrError({messages: allMessages, namespace, onError}),\n [allMessages, namespace, onError]\n );\n\n const translate = useMemo(\n () =>\n createBaseTranslator({\n cachedFormatsByLocale: cachedFormatsByLocaleRef.current,\n getMessageFallback,\n messagesOrError,\n defaultTranslationValues,\n namespace,\n onError,\n formats: globalFormats,\n locale,\n timeZone\n }),\n [\n getMessageFallback,\n messagesOrError,\n defaultTranslationValues,\n namespace,\n onError,\n globalFormats,\n locale,\n timeZone\n ]\n );\n\n return translate;\n}\n"],"names":["useTranslationsImpl","allMessages","namespace","namespacePrefix","useIntlContext","defaultTranslationValues","globalFormats","formats","getMessageFallback","locale","onError","timeZone","resolveNamespace","cachedFormatsByLocaleRef","useRef","messagesOrError","useMemo","getMessagesOrError","messages","translate","createBaseTranslator","cachedFormatsByLocale","current"],"mappings":";;;;;AAUwB,SAAAA,mBAAA,CAGtBC,WAHsB,EAGCC,SAHD,EAGuBC,eAHvB,EAG8C;AACpE,EAAA,IAAA,eAAA,GAOIC,cAAc,EAPlB;AAAA,MACEC,wBADF,mBACEA,wBADF;AAAA,MAEWC,aAFX,mBAEEC,OAFF;AAAA,MAGEC,kBAHF,mBAGEA,kBAHF;AAAA,MAIEC,MAJF,mBAIEA,MAJF;AAAA,MAKEC,OALF,mBAKEA,OALF;AAAA,MAMEC,QANF,GAAA,eAAA,CAMEA,QANF,CADoE;AAWpE;;;AACAV,EAAAA,WAAW,GAAGA,WAAW,CAACE,eAAD,CAAzB,CAAA;AACAD,EAAAA,SAAS,GAAGU,gBAAgB,CAACV,SAAD,EAAYC,eAAZ,CAA5B,CAAA;AAEA,EAAA,IAAMU,wBAAwB,GAAGC,MAAM,CAErC,EAFqC,CAAvC,CAAA;AAIA,EAAMC,IAAAA,eAAe,GAAGC,OAAO,CAC7B,YAAA;AAAA,IAAA,OAAMC,kBAAkB,CAAC;AAACC,MAAAA,QAAQ,EAAEjB,WAAX;AAAwBC,MAAAA,SAAS,EAATA,SAAxB;AAAmCQ,MAAAA,OAAO,EAAPA,OAAAA;AAAnC,KAAD,CAAxB,CAAA;AAAA,GAD6B,EAE7B,CAACT,WAAD,EAAcC,SAAd,EAAyBQ,OAAzB,CAF6B,CAA/B,CAAA;AAKA,EAAMS,IAAAA,SAAS,GAAGH,OAAO,CACvB,YAAA;AAAA,IAAA,OACEI,oBAAoB,CAAC;AACnBC,MAAAA,qBAAqB,EAAER,wBAAwB,CAACS,OAD7B;AAEnBd,MAAAA,kBAAkB,EAAlBA,kBAFmB;AAGnBO,MAAAA,eAAe,EAAfA,eAHmB;AAInBV,MAAAA,wBAAwB,EAAxBA,wBAJmB;AAKnBH,MAAAA,SAAS,EAATA,SALmB;AAMnBQ,MAAAA,OAAO,EAAPA,OANmB;AAOnBH,MAAAA,OAAO,EAAED,aAPU;AAQnBG,MAAAA,MAAM,EAANA,MARmB;AASnBE,MAAAA,QAAQ,EAARA,QAAAA;AATmB,KAAD,CADtB,CAAA;AAAA,GADuB,EAavB,CACEH,kBADF,EAEEO,eAFF,EAGEV,wBAHF,EAIEH,SAJF,EAKEQ,OALF,EAMEJ,aANF,EAOEG,MAPF,EAQEE,QARF,CAbuB,CAAzB,CAAA;AAyBA,EAAA,OAAOQ,SAAP,CAAA;AACD;;;;"}
@@ -1,19 +0,0 @@
1
- import AbstractIntlMessages from '../core/AbstractIntlMessages';
2
- import Formats from '../core/Formats';
3
- import IntlError from '../core/IntlError';
4
- import { RichTranslationValues } from '../core/TranslationValues';
5
- declare type IntlContextValue = {
6
- messages?: AbstractIntlMessages;
7
- locale: string;
8
- formats?: Partial<Formats>;
9
- timeZone?: string;
10
- onError(error: IntlError): void;
11
- getMessageFallback(info: {
12
- error: IntlError;
13
- key: string;
14
- namespace?: string;
15
- }): string;
16
- now?: Date;
17
- defaultTranslationValues?: RichTranslationValues;
18
- };
19
- export default IntlContextValue;
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=IntlContextValue.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"IntlContextValue.js","sourceRoot":"","sources":["../../../src/react/IntlContextValue.tsx"],"names":[],"mappings":""}
@@ -1,15 +0,0 @@
1
- import { ReactNode } from 'react';
2
- import { AbstractIntlMessages } from '../core';
3
- import IntlConfiguration from '../core/IntlConfiguration';
4
- import { RichTranslationValues } from '../core/TranslationValues';
5
- declare type IntlProviderProps = IntlConfiguration & {
6
- /** All components that use the provided hooks should be within this tree. */
7
- children: ReactNode;
8
- /** Global default values for translation values and rich text elements.
9
- * Can be used for consistent usage or styling of rich text elements.
10
- * Defaults will be overidden by locally provided values. */
11
- defaultTranslationValues?: RichTranslationValues;
12
- /** All messages that will be available in your components. */
13
- messages?: AbstractIntlMessages;
14
- };
15
- export default IntlProviderProps;
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=IntlProviderProps.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"IntlProviderProps.js","sourceRoot":"","sources":["../../../src/react/IntlProviderProps.tsx"],"names":[],"mappings":""}
@@ -1,18 +0,0 @@
1
- import IntlProviderProps from './IntlProviderProps';
2
- /**
3
- * Enhances the incoming props with defaults.
4
- */
5
- export default function getIntlContextValue({ getMessageFallback, messages, onError, ...rest }: Omit<IntlProviderProps, 'children'>): {
6
- messages: import("../core/AbstractIntlMessages").default | undefined;
7
- onError: (error: import("..").IntlError) => void;
8
- getMessageFallback: (info: {
9
- error: import("..").IntlError;
10
- key: string;
11
- namespace?: string | undefined;
12
- }) => string;
13
- defaultTranslationValues?: import("..").RichTranslationValues | undefined;
14
- formats?: Partial<import("../core/Formats").default> | undefined;
15
- locale: string;
16
- timeZone?: string | undefined;
17
- now?: Date | undefined;
18
- };
@@ -1,21 +0,0 @@
1
- import { defaultGetMessageFallback, defaultOnError } from '../core/defaults';
2
- import validateMessages from '../core/validateMessages';
3
- /**
4
- * Enhances the incoming props with defaults.
5
- */
6
- export default function getIntlContextValue({ getMessageFallback, messages, onError, ...rest }) {
7
- const finalOnError = onError || defaultOnError;
8
- const finalGetMessageFallback = getMessageFallback || defaultGetMessageFallback;
9
- if (process.env.NODE_ENV !== 'production') {
10
- if (messages) {
11
- validateMessages(messages, finalOnError);
12
- }
13
- }
14
- return {
15
- ...rest,
16
- messages,
17
- onError: finalOnError,
18
- getMessageFallback: finalGetMessageFallback
19
- };
20
- }
21
- //# sourceMappingURL=getIntlContextValue.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"getIntlContextValue.js","sourceRoot":"","sources":["../../../src/react/getIntlContextValue.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,yBAAyB,EAAE,cAAc,EAAC,MAAM,kBAAkB,CAAC;AAC3E,OAAO,gBAAgB,MAAM,0BAA0B,CAAC;AAGxD;;GAEG;AACH,MAAM,CAAC,OAAO,UAAU,mBAAmB,CAAC,EAC1C,kBAAkB,EAClB,QAAQ,EACR,OAAO,EACP,GAAG,IAAI,EAC6B;IACpC,MAAM,YAAY,GAAG,OAAO,IAAI,cAAc,CAAC;IAC/C,MAAM,uBAAuB,GAC3B,kBAAkB,IAAI,yBAAyB,CAAC;IAElD,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,EAAE;QACzC,IAAI,QAAQ,EAAE;YACZ,gBAAgB,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC;SAC1C;KACF;IAED,OAAO;QACL,GAAG,IAAI;QACP,QAAQ;QACR,OAAO,EAAE,YAAY;QACrB,kBAAkB,EAAE,uBAAuB;KAC5C,CAAC;AACJ,CAAC"}