@intlify/core 12.0.0-alpha.3 → 12.0.0-alpha.5
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/README.md +1 -1
- package/dist/core.d.ts +1 -4
- package/dist/core.esm-browser.js +2327 -3053
- package/dist/core.esm-browser.prod.js +1402 -6
- package/dist/core.esm-bundler.js +1 -1
- package/dist/core.global.js +2617 -3344
- package/dist/core.global.prod.js +1424 -6
- package/dist/core.js +5 -30
- package/dist/core.node.js +5 -30
- package/dist/core.runtime.esm-browser.js +1387 -1854
- package/dist/core.runtime.esm-browser.prod.js +822 -6
- package/dist/core.runtime.esm-bundler.js +1 -1
- package/dist/core.runtime.global.js +1655 -2123
- package/dist/core.runtime.global.prod.js +824 -6
- package/dist/core.runtime.js +17 -25
- package/dist/core.runtime.node.js +17 -25
- package/package.json +40 -40
|
@@ -1,2124 +1,1656 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var IntlifyCore = (function
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
: context.fallbackWarn;
|
|
1657
|
-
const escapeParameter = isBoolean(options.escapeParameter)
|
|
1658
|
-
? options.escapeParameter
|
|
1659
|
-
: context.escapeParameter;
|
|
1660
|
-
const resolvedMessage = !!options.resolvedMessage;
|
|
1661
|
-
// prettier-ignore
|
|
1662
|
-
const defaultMsgOrKey = isString(options.default) || isBoolean(options.default) // default by function option
|
|
1663
|
-
? !isBoolean(options.default)
|
|
1664
|
-
? options.default
|
|
1665
|
-
: (!messageCompiler ? () => key : key)
|
|
1666
|
-
: fallbackFormat // default by `fallbackFormat` option
|
|
1667
|
-
? (!messageCompiler ? () => key : key)
|
|
1668
|
-
: null;
|
|
1669
|
-
const enableDefaultMsg = fallbackFormat ||
|
|
1670
|
-
(defaultMsgOrKey != null &&
|
|
1671
|
-
(isString(defaultMsgOrKey) || isFunction(defaultMsgOrKey)));
|
|
1672
|
-
const locale = getLocale(context, options);
|
|
1673
|
-
// escape params
|
|
1674
|
-
escapeParameter && escapeParams(options);
|
|
1675
|
-
// resolve message format
|
|
1676
|
-
// eslint-disable-next-line prefer-const
|
|
1677
|
-
let [formatScope, targetLocale, message] = !resolvedMessage
|
|
1678
|
-
? resolveMessageFormat(context, key, locale, fallbackLocale, fallbackWarn, missingWarn)
|
|
1679
|
-
: [
|
|
1680
|
-
key,
|
|
1681
|
-
locale,
|
|
1682
|
-
messages[locale] || create()
|
|
1683
|
-
];
|
|
1684
|
-
// NOTE:
|
|
1685
|
-
// Fix to work around `ssrTransfrom` bug in Vite.
|
|
1686
|
-
// https://github.com/vitejs/vite/issues/4306
|
|
1687
|
-
// To get around this, use temporary variables.
|
|
1688
|
-
// https://github.com/nuxt/framework/issues/1461#issuecomment-954606243
|
|
1689
|
-
let format = formatScope;
|
|
1690
|
-
// if you use default message, set it as message format!
|
|
1691
|
-
let cacheBaseKey = key;
|
|
1692
|
-
if (!resolvedMessage &&
|
|
1693
|
-
!(isString(format) ||
|
|
1694
|
-
isMessageAST(format) ||
|
|
1695
|
-
isMessageFunction(format))) {
|
|
1696
|
-
if (enableDefaultMsg) {
|
|
1697
|
-
format = defaultMsgOrKey;
|
|
1698
|
-
cacheBaseKey = format;
|
|
1699
|
-
}
|
|
1700
|
-
}
|
|
1701
|
-
// checking message format and target locale
|
|
1702
|
-
if (!resolvedMessage &&
|
|
1703
|
-
(!(isString(format) ||
|
|
1704
|
-
isMessageAST(format) ||
|
|
1705
|
-
isMessageFunction(format)) ||
|
|
1706
|
-
!isString(targetLocale))) {
|
|
1707
|
-
return unresolving ? NOT_RESOLVED : key;
|
|
1708
|
-
}
|
|
1709
|
-
// TODO: refactor
|
|
1710
|
-
if (isString(format) && context.messageCompiler == null) {
|
|
1711
|
-
warn(`The message format compilation is not supported in this build. ` +
|
|
1712
|
-
`Because message compiler isn't included. ` +
|
|
1713
|
-
`You need to pre-compilation all message format. ` +
|
|
1714
|
-
`So translate function return '${key}'.`);
|
|
1715
|
-
return key;
|
|
1716
|
-
}
|
|
1717
|
-
// setup compile error detecting
|
|
1718
|
-
let occurred = false;
|
|
1719
|
-
const onError = () => {
|
|
1720
|
-
occurred = true;
|
|
1721
|
-
};
|
|
1722
|
-
// compile message format
|
|
1723
|
-
const msg = !isMessageFunction(format)
|
|
1724
|
-
? compileMessageFormat(context, key, targetLocale, format, cacheBaseKey, onError)
|
|
1725
|
-
: format;
|
|
1726
|
-
// if occurred compile error, return the message format
|
|
1727
|
-
if (occurred) {
|
|
1728
|
-
return format;
|
|
1729
|
-
}
|
|
1730
|
-
// evaluate message with context
|
|
1731
|
-
const ctxOptions = getMessageContextOptions(context, targetLocale, message, options);
|
|
1732
|
-
const msgContext = createMessageContext(ctxOptions);
|
|
1733
|
-
const messaged = evaluateMessage(context, msg, msgContext);
|
|
1734
|
-
// if use post translation option, proceed it with handler
|
|
1735
|
-
const ret = postTranslation
|
|
1736
|
-
? postTranslation(messaged, key)
|
|
1737
|
-
: messaged;
|
|
1738
|
-
// NOTE: experimental !!
|
|
1739
|
-
{
|
|
1740
|
-
// prettier-ignore
|
|
1741
|
-
const payloads = {
|
|
1742
|
-
timestamp: Date.now(),
|
|
1743
|
-
key: isString(key)
|
|
1744
|
-
? key
|
|
1745
|
-
: isMessageFunction(format)
|
|
1746
|
-
? format.key
|
|
1747
|
-
: '',
|
|
1748
|
-
locale: targetLocale || (isMessageFunction(format)
|
|
1749
|
-
? format.locale
|
|
1750
|
-
: ''),
|
|
1751
|
-
format: isString(format)
|
|
1752
|
-
? format
|
|
1753
|
-
: isMessageFunction(format)
|
|
1754
|
-
? format.source
|
|
1755
|
-
: '',
|
|
1756
|
-
message: ret
|
|
1757
|
-
};
|
|
1758
|
-
payloads.meta = assign({}, context.__meta, getAdditionalMeta() || {});
|
|
1759
|
-
translateDevTools(payloads);
|
|
1760
|
-
}
|
|
1761
|
-
return ret;
|
|
1762
|
-
}
|
|
1763
|
-
function escapeParams(options) {
|
|
1764
|
-
if (isArray(options.list)) {
|
|
1765
|
-
options.list = options.list.map(item => isString(item) ? escapeHtml(item) : item);
|
|
1766
|
-
}
|
|
1767
|
-
else if (isObject(options.named)) {
|
|
1768
|
-
Object.keys(options.named).forEach(key => {
|
|
1769
|
-
if (isString(options.named[key])) {
|
|
1770
|
-
options.named[key] = escapeHtml(options.named[key]);
|
|
1771
|
-
}
|
|
1772
|
-
});
|
|
1773
|
-
}
|
|
1774
|
-
}
|
|
1775
|
-
function resolveMessageFormat(context, key, locale, fallbackLocale, fallbackWarn, missingWarn) {
|
|
1776
|
-
const { messages, onWarn, messageResolver: resolveValue, localeFallbacker } = context;
|
|
1777
|
-
const locales = localeFallbacker(context, fallbackLocale, locale); // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
1778
|
-
let message = create();
|
|
1779
|
-
let targetLocale;
|
|
1780
|
-
let format = null;
|
|
1781
|
-
let from = locale;
|
|
1782
|
-
let to = null;
|
|
1783
|
-
const type = 'translate';
|
|
1784
|
-
for (let i = 0; i < locales.length; i++) {
|
|
1785
|
-
targetLocale = to = locales[i];
|
|
1786
|
-
if (locale !== targetLocale &&
|
|
1787
|
-
!isAlmostSameLocale(locale, targetLocale) &&
|
|
1788
|
-
isTranslateFallbackWarn(fallbackWarn, key)) {
|
|
1789
|
-
onWarn(getWarnMessage(CoreWarnCodes.FALLBACK_TO_TRANSLATE, {
|
|
1790
|
-
key,
|
|
1791
|
-
target: targetLocale
|
|
1792
|
-
}));
|
|
1793
|
-
}
|
|
1794
|
-
// for vue-devtools timeline event
|
|
1795
|
-
if (locale !== targetLocale) {
|
|
1796
|
-
const emitter = context.__v_emitter;
|
|
1797
|
-
if (emitter) {
|
|
1798
|
-
emitter.emit('fallback', {
|
|
1799
|
-
type,
|
|
1800
|
-
key,
|
|
1801
|
-
from,
|
|
1802
|
-
to,
|
|
1803
|
-
groupId: `${type}:${key}`
|
|
1804
|
-
});
|
|
1805
|
-
}
|
|
1806
|
-
}
|
|
1807
|
-
message =
|
|
1808
|
-
messages[targetLocale] || create();
|
|
1809
|
-
// for vue-devtools timeline event
|
|
1810
|
-
let start = null;
|
|
1811
|
-
let startTag;
|
|
1812
|
-
let endTag;
|
|
1813
|
-
if (inBrowser) {
|
|
1814
|
-
start = window.performance.now();
|
|
1815
|
-
startTag = 'intlify-message-resolve-start';
|
|
1816
|
-
endTag = 'intlify-message-resolve-end';
|
|
1817
|
-
mark && mark(startTag);
|
|
1818
|
-
}
|
|
1819
|
-
if ((format = resolveValue(message, key)) === null) {
|
|
1820
|
-
// if null, resolve with object key path
|
|
1821
|
-
format = message[key]; // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
1822
|
-
}
|
|
1823
|
-
// for vue-devtools timeline event
|
|
1824
|
-
if (inBrowser) {
|
|
1825
|
-
const end = window.performance.now();
|
|
1826
|
-
const emitter = context.__v_emitter;
|
|
1827
|
-
if (emitter && start && format) {
|
|
1828
|
-
emitter.emit('message-resolve', {
|
|
1829
|
-
type: 'message-resolve',
|
|
1830
|
-
key,
|
|
1831
|
-
message: format,
|
|
1832
|
-
time: end - start,
|
|
1833
|
-
groupId: `${type}:${key}`
|
|
1834
|
-
});
|
|
1835
|
-
}
|
|
1836
|
-
if (startTag && endTag && mark && measure) {
|
|
1837
|
-
mark(endTag);
|
|
1838
|
-
measure('intlify message resolve', startTag, endTag);
|
|
1839
|
-
}
|
|
1840
|
-
}
|
|
1841
|
-
if (isString(format) || isMessageAST(format) || isMessageFunction(format)) {
|
|
1842
|
-
break;
|
|
1843
|
-
}
|
|
1844
|
-
if (!isImplicitFallback(targetLocale, locales)) {
|
|
1845
|
-
const missingRet = handleMissing(context, // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
1846
|
-
key, targetLocale, missingWarn, type);
|
|
1847
|
-
if (missingRet !== key) {
|
|
1848
|
-
format = missingRet;
|
|
1849
|
-
}
|
|
1850
|
-
}
|
|
1851
|
-
from = to;
|
|
1852
|
-
}
|
|
1853
|
-
return [format, targetLocale, message];
|
|
1854
|
-
}
|
|
1855
|
-
function compileMessageFormat(context, key, targetLocale, format, cacheBaseKey, onError) {
|
|
1856
|
-
const { messageCompiler, warnHtmlMessage } = context;
|
|
1857
|
-
if (isMessageFunction(format)) {
|
|
1858
|
-
const msg = format;
|
|
1859
|
-
msg.locale = msg.locale || targetLocale;
|
|
1860
|
-
msg.key = msg.key || key;
|
|
1861
|
-
return msg;
|
|
1862
|
-
}
|
|
1863
|
-
if (messageCompiler == null) {
|
|
1864
|
-
const msg = (() => format);
|
|
1865
|
-
msg.locale = targetLocale;
|
|
1866
|
-
msg.key = key;
|
|
1867
|
-
return msg;
|
|
1868
|
-
}
|
|
1869
|
-
// for vue-devtools timeline event
|
|
1870
|
-
let start = null;
|
|
1871
|
-
let startTag;
|
|
1872
|
-
let endTag;
|
|
1873
|
-
if (inBrowser) {
|
|
1874
|
-
start = window.performance.now();
|
|
1875
|
-
startTag = 'intlify-message-compilation-start';
|
|
1876
|
-
endTag = 'intlify-message-compilation-end';
|
|
1877
|
-
mark && mark(startTag);
|
|
1878
|
-
}
|
|
1879
|
-
const msg = messageCompiler(format, getCompileContext(context, targetLocale, cacheBaseKey, format, warnHtmlMessage, onError));
|
|
1880
|
-
// for vue-devtools timeline event
|
|
1881
|
-
if (inBrowser) {
|
|
1882
|
-
const end = window.performance.now();
|
|
1883
|
-
const emitter = context.__v_emitter;
|
|
1884
|
-
if (emitter && start) {
|
|
1885
|
-
emitter.emit('message-compilation', {
|
|
1886
|
-
type: 'message-compilation',
|
|
1887
|
-
message: format,
|
|
1888
|
-
time: end - start,
|
|
1889
|
-
groupId: `${'translate'}:${key}`
|
|
1890
|
-
});
|
|
1891
|
-
}
|
|
1892
|
-
if (startTag && endTag && mark && measure) {
|
|
1893
|
-
mark(endTag);
|
|
1894
|
-
measure('intlify message compilation', startTag, endTag);
|
|
1895
|
-
}
|
|
1896
|
-
}
|
|
1897
|
-
msg.locale = targetLocale;
|
|
1898
|
-
msg.key = key;
|
|
1899
|
-
msg.source = format;
|
|
1900
|
-
return msg;
|
|
1901
|
-
}
|
|
1902
|
-
function evaluateMessage(context, msg, msgCtx) {
|
|
1903
|
-
// for vue-devtools timeline event
|
|
1904
|
-
let start = null;
|
|
1905
|
-
let startTag;
|
|
1906
|
-
let endTag;
|
|
1907
|
-
if (inBrowser) {
|
|
1908
|
-
start = window.performance.now();
|
|
1909
|
-
startTag = 'intlify-message-evaluation-start';
|
|
1910
|
-
endTag = 'intlify-message-evaluation-end';
|
|
1911
|
-
mark && mark(startTag);
|
|
1912
|
-
}
|
|
1913
|
-
const messaged = msg(msgCtx);
|
|
1914
|
-
// for vue-devtools timeline event
|
|
1915
|
-
if (inBrowser) {
|
|
1916
|
-
const end = window.performance.now();
|
|
1917
|
-
const emitter = context.__v_emitter;
|
|
1918
|
-
if (emitter && start) {
|
|
1919
|
-
emitter.emit('message-evaluation', {
|
|
1920
|
-
type: 'message-evaluation',
|
|
1921
|
-
value: messaged,
|
|
1922
|
-
time: end - start,
|
|
1923
|
-
groupId: `${'translate'}:${msg.key}`
|
|
1924
|
-
});
|
|
1925
|
-
}
|
|
1926
|
-
if (startTag && endTag && mark && measure) {
|
|
1927
|
-
mark(endTag);
|
|
1928
|
-
measure('intlify message evaluation', startTag, endTag);
|
|
1929
|
-
}
|
|
1930
|
-
}
|
|
1931
|
-
return messaged;
|
|
1932
|
-
}
|
|
1933
|
-
/** @internal */
|
|
1934
|
-
function parseTranslateArgs(...args) {
|
|
1935
|
-
const [arg1, arg2, arg3] = args;
|
|
1936
|
-
const options = create();
|
|
1937
|
-
if (!isString(arg1) &&
|
|
1938
|
-
!isNumber(arg1) &&
|
|
1939
|
-
!isMessageFunction(arg1) &&
|
|
1940
|
-
!isMessageAST(arg1)) {
|
|
1941
|
-
throw createCoreError(CoreErrorCodes.INVALID_ARGUMENT);
|
|
1942
|
-
}
|
|
1943
|
-
// prettier-ignore
|
|
1944
|
-
const key = isNumber(arg1)
|
|
1945
|
-
? String(arg1)
|
|
1946
|
-
: isMessageFunction(arg1)
|
|
1947
|
-
? arg1
|
|
1948
|
-
: arg1;
|
|
1949
|
-
if (isNumber(arg2)) {
|
|
1950
|
-
options.plural = arg2;
|
|
1951
|
-
}
|
|
1952
|
-
else if (isString(arg2)) {
|
|
1953
|
-
options.default = arg2;
|
|
1954
|
-
}
|
|
1955
|
-
else if (isPlainObject(arg2) && !isEmptyObject(arg2)) {
|
|
1956
|
-
options.named = arg2;
|
|
1957
|
-
}
|
|
1958
|
-
else if (isArray(arg2)) {
|
|
1959
|
-
options.list = arg2;
|
|
1960
|
-
}
|
|
1961
|
-
if (isNumber(arg3)) {
|
|
1962
|
-
options.plural = arg3;
|
|
1963
|
-
}
|
|
1964
|
-
else if (isString(arg3)) {
|
|
1965
|
-
options.default = arg3;
|
|
1966
|
-
}
|
|
1967
|
-
else if (isPlainObject(arg3)) {
|
|
1968
|
-
assign(options, arg3);
|
|
1969
|
-
}
|
|
1970
|
-
return [key, options];
|
|
1971
|
-
}
|
|
1972
|
-
function getCompileContext(context, locale, key, source, warnHtmlMessage, onError) {
|
|
1973
|
-
return {
|
|
1974
|
-
locale,
|
|
1975
|
-
key,
|
|
1976
|
-
warnHtmlMessage,
|
|
1977
|
-
onError: (err) => {
|
|
1978
|
-
onError && onError(err);
|
|
1979
|
-
{
|
|
1980
|
-
const _source = getSourceForCodeFrame(source);
|
|
1981
|
-
const message = `Message compilation error: ${err.message}`;
|
|
1982
|
-
const codeFrame = err.location &&
|
|
1983
|
-
_source &&
|
|
1984
|
-
generateCodeFrame(_source, err.location.start.offset, err.location.end.offset);
|
|
1985
|
-
const emitter = context.__v_emitter;
|
|
1986
|
-
if (emitter && _source) {
|
|
1987
|
-
emitter.emit('compile-error', {
|
|
1988
|
-
message: _source,
|
|
1989
|
-
error: err.message,
|
|
1990
|
-
start: err.location && err.location.start.offset,
|
|
1991
|
-
end: err.location && err.location.end.offset,
|
|
1992
|
-
groupId: `${'translate'}:${key}`
|
|
1993
|
-
});
|
|
1994
|
-
}
|
|
1995
|
-
console.error(codeFrame ? `${message}\n${codeFrame}` : message);
|
|
1996
|
-
}
|
|
1997
|
-
},
|
|
1998
|
-
onCacheKey: (source) => generateFormatCacheKey(locale, key, source)
|
|
1999
|
-
};
|
|
2000
|
-
}
|
|
2001
|
-
function getSourceForCodeFrame(source) {
|
|
2002
|
-
if (isString(source)) {
|
|
2003
|
-
return source;
|
|
2004
|
-
}
|
|
2005
|
-
else {
|
|
2006
|
-
if (source.loc && source.loc.source) {
|
|
2007
|
-
return source.loc.source;
|
|
2008
|
-
}
|
|
2009
|
-
}
|
|
2010
|
-
}
|
|
2011
|
-
function getMessageContextOptions(context, locale, message, options) {
|
|
2012
|
-
const { modifiers, pluralRules, messageResolver: resolveValue, fallbackLocale, fallbackWarn, missingWarn, fallbackContext } = context;
|
|
2013
|
-
const resolveMessage = (key, useLinked) => {
|
|
2014
|
-
let val = resolveValue(message, key);
|
|
2015
|
-
// fallback
|
|
2016
|
-
if (val == null && (fallbackContext || useLinked)) {
|
|
2017
|
-
const [, , message] = resolveMessageFormat(fallbackContext || context, // NOTE: if has fallbackContext, fallback to root, else if use linked, fallback to local context
|
|
2018
|
-
key, locale, fallbackLocale, fallbackWarn, missingWarn);
|
|
2019
|
-
val = resolveValue(message, key);
|
|
2020
|
-
}
|
|
2021
|
-
if (isString(val) || isMessageAST(val)) {
|
|
2022
|
-
let occurred = false;
|
|
2023
|
-
const onError = () => {
|
|
2024
|
-
occurred = true;
|
|
2025
|
-
};
|
|
2026
|
-
const msg = compileMessageFormat(context, key, locale, val, key, onError);
|
|
2027
|
-
return !occurred
|
|
2028
|
-
? msg
|
|
2029
|
-
: NOOP_MESSAGE_FUNCTION;
|
|
2030
|
-
}
|
|
2031
|
-
else if (isMessageFunction(val)) {
|
|
2032
|
-
return val;
|
|
2033
|
-
}
|
|
2034
|
-
else {
|
|
2035
|
-
// TODO: should be implemented warning message
|
|
2036
|
-
return NOOP_MESSAGE_FUNCTION;
|
|
2037
|
-
}
|
|
2038
|
-
};
|
|
2039
|
-
const ctxOptions = {
|
|
2040
|
-
locale,
|
|
2041
|
-
modifiers,
|
|
2042
|
-
pluralRules,
|
|
2043
|
-
messages: resolveMessage
|
|
2044
|
-
};
|
|
2045
|
-
if (context.processor) {
|
|
2046
|
-
ctxOptions.processor = context.processor;
|
|
2047
|
-
}
|
|
2048
|
-
if (options.list) {
|
|
2049
|
-
ctxOptions.list = options.list;
|
|
2050
|
-
}
|
|
2051
|
-
if (options.named) {
|
|
2052
|
-
ctxOptions.named = options.named;
|
|
2053
|
-
}
|
|
2054
|
-
if (isNumber(options.plural)) {
|
|
2055
|
-
ctxOptions.pluralIndex = options.plural;
|
|
2056
|
-
}
|
|
2057
|
-
return ctxOptions;
|
|
2058
|
-
}
|
|
2059
|
-
|
|
2060
|
-
// register message compiler for jit compilation
|
|
2061
|
-
registerMessageCompiler(compile);
|
|
2062
|
-
// register message resolver at @intlify/core
|
|
2063
|
-
registerMessageResolver(resolveValue);
|
|
2064
|
-
// register fallback locale at @intlify/core
|
|
2065
|
-
registerLocaleFallbacker(fallbackWithLocaleChain);
|
|
2066
|
-
|
|
2067
|
-
exports.AST_NODE_PROPS_KEYS = AST_NODE_PROPS_KEYS;
|
|
2068
|
-
exports.CORE_ERROR_CODES_EXTEND_POINT = CORE_ERROR_CODES_EXTEND_POINT;
|
|
2069
|
-
exports.CORE_WARN_CODES_EXTEND_POINT = CORE_WARN_CODES_EXTEND_POINT;
|
|
2070
|
-
exports.CoreWarnCodes = CoreWarnCodes;
|
|
2071
|
-
exports.DATETIME_FORMAT_OPTIONS_KEYS = DATETIME_FORMAT_OPTIONS_KEYS;
|
|
2072
|
-
exports.DEFAULT_LOCALE = DEFAULT_LOCALE;
|
|
2073
|
-
exports.DEFAULT_MESSAGE_DATA_TYPE = DEFAULT_MESSAGE_DATA_TYPE;
|
|
2074
|
-
exports.MISSING_RESOLVE_VALUE = MISSING_RESOLVE_VALUE;
|
|
2075
|
-
exports.NOT_RESOLVED = NOT_RESOLVED;
|
|
2076
|
-
exports.NUMBER_FORMAT_OPTIONS_KEYS = NUMBER_FORMAT_OPTIONS_KEYS;
|
|
2077
|
-
exports.VERSION = VERSION;
|
|
2078
|
-
exports.clearCompileCache = clearCompileCache;
|
|
2079
|
-
exports.clearDateTimeFormat = clearDateTimeFormat;
|
|
2080
|
-
exports.clearNumberFormat = clearNumberFormat;
|
|
2081
|
-
exports.compile = compile;
|
|
2082
|
-
exports.createCompileError = createCompileError;
|
|
2083
|
-
exports.createCoreContext = createCoreContext;
|
|
2084
|
-
exports.createCoreError = createCoreError;
|
|
2085
|
-
exports.createMessageContext = createMessageContext;
|
|
2086
|
-
exports.datetime = datetime;
|
|
2087
|
-
exports.fallbackWithLocaleChain = fallbackWithLocaleChain;
|
|
2088
|
-
exports.fallbackWithSimple = fallbackWithSimple;
|
|
2089
|
-
exports.getAdditionalMeta = getAdditionalMeta;
|
|
2090
|
-
exports.getDevToolsHook = getDevToolsHook;
|
|
2091
|
-
exports.getFallbackContext = getFallbackContext;
|
|
2092
|
-
exports.getLocale = getLocale;
|
|
2093
|
-
exports.getLocaleMessage = getLocaleMessage;
|
|
2094
|
-
exports.getWarnMessage = getWarnMessage;
|
|
2095
|
-
exports.handleMissing = handleMissing;
|
|
2096
|
-
exports.initI18nDevTools = initI18nDevTools;
|
|
2097
|
-
exports.isAlmostSameLocale = isAlmostSameLocale;
|
|
2098
|
-
exports.isImplicitFallback = isImplicitFallback;
|
|
2099
|
-
exports.isMessageAST = isMessageAST;
|
|
2100
|
-
exports.isMessageFunction = isMessageFunction;
|
|
2101
|
-
exports.isTranslateFallbackWarn = isTranslateFallbackWarn;
|
|
2102
|
-
exports.isTranslateMissingWarn = isTranslateMissingWarn;
|
|
2103
|
-
exports.number = number;
|
|
2104
|
-
exports.parse = parse;
|
|
2105
|
-
exports.parseDateTimeArgs = parseDateTimeArgs;
|
|
2106
|
-
exports.parseNumberArgs = parseNumberArgs;
|
|
2107
|
-
exports.parseTranslateArgs = parseTranslateArgs;
|
|
2108
|
-
exports.registerLocaleFallbacker = registerLocaleFallbacker;
|
|
2109
|
-
exports.registerMessageCompiler = registerMessageCompiler;
|
|
2110
|
-
exports.registerMessageResolver = registerMessageResolver;
|
|
2111
|
-
exports.resolveLocale = resolveLocale;
|
|
2112
|
-
exports.resolveValue = resolveValue;
|
|
2113
|
-
exports.resolveWithKeyValue = resolveWithKeyValue;
|
|
2114
|
-
exports.setAdditionalMeta = setAdditionalMeta;
|
|
2115
|
-
exports.setDevToolsHook = setDevToolsHook;
|
|
2116
|
-
exports.setFallbackContext = setFallbackContext;
|
|
2117
|
-
exports.setLocaleMessage = setLocaleMessage;
|
|
2118
|
-
exports.translate = translate;
|
|
2119
|
-
exports.translateDevTools = translateDevTools;
|
|
2120
|
-
exports.updateFallbackLocale = updateFallbackLocale;
|
|
2121
|
-
|
|
2122
|
-
return exports;
|
|
2123
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @intlify/core v12.0.0-alpha.5
|
|
3
|
+
* (c) 2016-present kazuya kawaguchi and contributors
|
|
4
|
+
* @license MIT
|
|
5
|
+
**/
|
|
6
|
+
var IntlifyCore = (function(exports) {
|
|
7
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
8
|
+
//#region packages/shared/src/utils.ts
|
|
9
|
+
/**
|
|
10
|
+
* Original Utilities
|
|
11
|
+
* written by kazuya kawaguchi
|
|
12
|
+
*/
|
|
13
|
+
const inBrowser = typeof window !== "undefined";
|
|
14
|
+
let mark;
|
|
15
|
+
let measure;
|
|
16
|
+
{
|
|
17
|
+
const perf = inBrowser && window.performance;
|
|
18
|
+
if (perf && perf.mark && perf.measure && perf.clearMarks && perf.clearMeasures) {
|
|
19
|
+
mark = (tag) => {
|
|
20
|
+
perf.mark(tag);
|
|
21
|
+
};
|
|
22
|
+
measure = (name, startTag, endTag) => {
|
|
23
|
+
perf.measure(name, startTag, endTag);
|
|
24
|
+
perf.clearMarks(startTag);
|
|
25
|
+
perf.clearMarks(endTag);
|
|
26
|
+
perf.clearMeasures(name);
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
const RE_ARGS = /\{([0-9a-z]+)\}/gi;
|
|
31
|
+
function format$1(message, ...args) {
|
|
32
|
+
if (args.length === 1 && isObject(args[0])) args = args[0];
|
|
33
|
+
if (!args || !args.hasOwnProperty) args = {};
|
|
34
|
+
return message.replace(RE_ARGS, (_match, identifier) => {
|
|
35
|
+
return args.hasOwnProperty(identifier) ? args[identifier] : "";
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
const generateFormatCacheKey = (locale, key, source) => friendlyJSONstringify({
|
|
39
|
+
l: locale,
|
|
40
|
+
k: key,
|
|
41
|
+
s: source
|
|
42
|
+
});
|
|
43
|
+
const friendlyJSONstringify = (json) => JSON.stringify(json).replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029").replace(/\u0027/g, "\\u0027");
|
|
44
|
+
const isNumber = (val) => typeof val === "number" && isFinite(val);
|
|
45
|
+
function toDevtoolsGroupId(type, key) {
|
|
46
|
+
return isString(key) || isNumber(key) ? `${type}:${key}` : type;
|
|
47
|
+
}
|
|
48
|
+
const isDate = (val) => toTypeString(val) === "[object Date]";
|
|
49
|
+
const isRegExp = (val) => toTypeString(val) === "[object RegExp]";
|
|
50
|
+
const isKeylessObject = (val) => Object.keys(val).length === 0;
|
|
51
|
+
const assign = Object.assign;
|
|
52
|
+
const _create = Object.create;
|
|
53
|
+
const create = (obj = null) => _create(obj);
|
|
54
|
+
const hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
55
|
+
function hasOwn(obj, key) {
|
|
56
|
+
return hasOwnProperty.call(obj, key);
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Get `obj[key]` only when `key` is an own property of `obj`, so that a key such as `constructor`
|
|
60
|
+
* does not read a property inherited from `Object.prototype`.
|
|
61
|
+
* The property is read before the check, so that a reactive `obj` tracks `key` even when it is missing.
|
|
62
|
+
*/
|
|
63
|
+
function getOwn(obj, key) {
|
|
64
|
+
const value = obj[key];
|
|
65
|
+
return hasOwn(obj, key) ? value : void 0;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Whether `key` is a property name of `Object.prototype`, such as `__proto__`, `constructor` or `toString`.
|
|
69
|
+
* On a plain object, such a key reads a built-in, and assigning to `__proto__` replaces the prototype.
|
|
70
|
+
*/
|
|
71
|
+
function isObjectPrototypeKey(key) {
|
|
72
|
+
return hasOwn(Object.prototype, key);
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Useful Utilities By Evan you
|
|
76
|
+
* Modified by kazuya kawaguchi
|
|
77
|
+
* MIT License
|
|
78
|
+
* https://github.com/vuejs/vue-next/blob/master/packages/shared/src/index.ts
|
|
79
|
+
* https://github.com/vuejs/vue-next/blob/master/packages/shared/src/codeframe.ts
|
|
80
|
+
*/
|
|
81
|
+
const isArray = Array.isArray;
|
|
82
|
+
const isFunction = (val) => typeof val === "function";
|
|
83
|
+
const isString = (val) => typeof val === "string";
|
|
84
|
+
const isBoolean = (val) => typeof val === "boolean";
|
|
85
|
+
const isObject = (val) => val !== null && typeof val === "object";
|
|
86
|
+
const isPromise = (val) => {
|
|
87
|
+
return isObject(val) && isFunction(val.then) && isFunction(val.catch);
|
|
88
|
+
};
|
|
89
|
+
const objectToString = Object.prototype.toString;
|
|
90
|
+
const toTypeString = (value) => objectToString.call(value);
|
|
91
|
+
const isPlainObject = (val) => toTypeString(val) === "[object Object]";
|
|
92
|
+
const toDisplayString = (val) => {
|
|
93
|
+
return val == null ? "" : isArray(val) || isPlainObject(val) && val.toString === objectToString ? JSON.stringify(val, null, 2) : String(val);
|
|
94
|
+
};
|
|
95
|
+
function join(items, separator = "") {
|
|
96
|
+
return items.reduce((str, item, index) => index === 0 ? str + item : str + separator + item, "");
|
|
97
|
+
}
|
|
98
|
+
const RANGE = 2;
|
|
99
|
+
function generateCodeFrame(source, start = 0, end = source.length) {
|
|
100
|
+
const lines = source.split(/\r?\n/);
|
|
101
|
+
let count = 0;
|
|
102
|
+
const res = [];
|
|
103
|
+
for (let i = 0; i < lines.length; i++) {
|
|
104
|
+
count += lines[i].length + 1;
|
|
105
|
+
if (count >= start) {
|
|
106
|
+
for (let j = i - RANGE; j <= i + RANGE || end > count; j++) {
|
|
107
|
+
if (j < 0 || j >= lines.length) continue;
|
|
108
|
+
const line = j + 1;
|
|
109
|
+
res.push(`${line}${" ".repeat(3 - String(line).length)}| ${lines[j]}`);
|
|
110
|
+
const lineLength = lines[j].length;
|
|
111
|
+
if (j === i) {
|
|
112
|
+
const pad = start - (count - lineLength) + 1;
|
|
113
|
+
const length = Math.max(1, end > count ? lineLength - pad : end - start);
|
|
114
|
+
res.push(` | ` + " ".repeat(pad) + "^".repeat(length));
|
|
115
|
+
} else if (j > i) {
|
|
116
|
+
if (end > count) {
|
|
117
|
+
const length = Math.max(Math.min(end - count, lineLength), 1);
|
|
118
|
+
res.push(` | ` + "^".repeat(length));
|
|
119
|
+
}
|
|
120
|
+
count += lineLength + 1;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
break;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
return res.join("\n");
|
|
127
|
+
}
|
|
128
|
+
//#endregion
|
|
129
|
+
//#region packages/shared/src/warn.ts
|
|
130
|
+
function warn(msg, err) {
|
|
131
|
+
if (typeof console !== "undefined") {
|
|
132
|
+
console.warn(`[intlify] ` + msg);
|
|
133
|
+
/* istanbul ignore if */
|
|
134
|
+
if (err) console.warn(err.stack);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
const hasWarned = {};
|
|
138
|
+
function warnOnce(msg) {
|
|
139
|
+
if (!hasWarned[msg]) {
|
|
140
|
+
hasWarned[msg] = true;
|
|
141
|
+
warn(msg);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
//#endregion
|
|
145
|
+
//#region packages/shared/src/sanitize.ts
|
|
146
|
+
function escapeHtml(rawText) {
|
|
147
|
+
return rawText.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'").replace(/\//g, "/").replace(/=/g, "=");
|
|
148
|
+
}
|
|
149
|
+
function escapeAttributeValue(value) {
|
|
150
|
+
return value.replace(/&(?![a-z0-9#]{2,6};)/gi, "&").replace(/"/g, """).replace(/'/g, "'").replace(/</g, "<").replace(/>/g, ">");
|
|
151
|
+
}
|
|
152
|
+
const javascriptSchemePattern = /^javascript:/i;
|
|
153
|
+
const urlAttributePattern = /^(?:href|src|action|formaction)$/i;
|
|
154
|
+
const numericCharacterReferencePattern = /&#(?:x([0-9a-f]+)|(\d+));?/gi;
|
|
155
|
+
const namedWhitespaceCharacterReferencePattern = /&(?:Tab|NewLine);/g;
|
|
156
|
+
const colonCharacterReferencePattern = /:?/gi;
|
|
157
|
+
const controlOrWhitespacePattern = /[\u0000-\u0020\u007f-\u009f]/g;
|
|
158
|
+
const eventHandlerPattern = /(?:^|[\s"'<>/])on\w+\s*=\s*["']?[^"'>]+["']?/i;
|
|
159
|
+
const eventHandlerAttributePattern = /(^|[\s"'<>/])on(\w+\s*=)/gi;
|
|
160
|
+
const srcdocPattern = /(?:^|[\s"'<>/])srcdoc\s*=/i;
|
|
161
|
+
const srcdocAttributePattern = /(^|[\s"'<>/])s(rcdoc\s*=)/gi;
|
|
162
|
+
const unquotedUrlAttributePattern = /(^|[\s"'<>/])((?:href|src|action|formaction)\s*=\s*)([^\s"'=<>`]+)/gi;
|
|
163
|
+
function decodeNumericCharacterReference(match, hex, decimal) {
|
|
164
|
+
const digits = hex || decimal;
|
|
165
|
+
if (!digits) return match;
|
|
166
|
+
const codePoint = Number.parseInt(digits, hex ? 16 : 10);
|
|
167
|
+
return codePoint <= 127 ? String.fromCharCode(codePoint) : match;
|
|
168
|
+
}
|
|
169
|
+
function hasJavascriptScheme(value) {
|
|
170
|
+
const normalized = value.replace(numericCharacterReferencePattern, decodeNumericCharacterReference).replace(namedWhitespaceCharacterReferencePattern, "").replace(colonCharacterReferencePattern, ":").replace(controlOrWhitespacePattern, "");
|
|
171
|
+
return javascriptSchemePattern.test(normalized);
|
|
172
|
+
}
|
|
173
|
+
function sanitizeStyleValue(value) {
|
|
174
|
+
const urlPattern = /url\s*\(/gi;
|
|
175
|
+
let sanitized = "";
|
|
176
|
+
let cursor = 0;
|
|
177
|
+
let match;
|
|
178
|
+
while ((match = urlPattern.exec(value)) !== null) {
|
|
179
|
+
const urlStart = match.index;
|
|
180
|
+
const openParenIndex = urlPattern.lastIndex - 1;
|
|
181
|
+
let index = openParenIndex + 1;
|
|
182
|
+
let depth = 1;
|
|
183
|
+
let quote = null;
|
|
184
|
+
for (; index < value.length; index++) {
|
|
185
|
+
const char = value[index];
|
|
186
|
+
if (quote) {
|
|
187
|
+
if (char === quote) quote = null;
|
|
188
|
+
continue;
|
|
189
|
+
}
|
|
190
|
+
if (char === "\"" || char === "'") quote = char;
|
|
191
|
+
else if (char === "(") depth++;
|
|
192
|
+
else if (char === ")") {
|
|
193
|
+
depth--;
|
|
194
|
+
if (depth === 0) break;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
if (depth !== 0) break;
|
|
198
|
+
const rawUrlValue = value.slice(openParenIndex + 1, index).trim();
|
|
199
|
+
const unquotedUrlValue = rawUrlValue.startsWith("\"") && rawUrlValue.endsWith("\"") || rawUrlValue.startsWith("'") && rawUrlValue.endsWith("'") ? rawUrlValue.slice(1, -1).trim() : rawUrlValue;
|
|
200
|
+
sanitized += value.slice(cursor, urlStart);
|
|
201
|
+
sanitized += hasJavascriptScheme(unquotedUrlValue) ? "url(about:blank)" : value.slice(urlStart, index + 1);
|
|
202
|
+
cursor = index + 1;
|
|
203
|
+
}
|
|
204
|
+
return sanitized + value.slice(cursor);
|
|
205
|
+
}
|
|
206
|
+
function sanitizeAttributeValue(attrName, value) {
|
|
207
|
+
if (urlAttributePattern.test(attrName) && hasJavascriptScheme(value)) return "about:blank";
|
|
208
|
+
return escapeAttributeValue(attrName.toLowerCase() === "style" ? sanitizeStyleValue(value) : value);
|
|
209
|
+
}
|
|
210
|
+
function sanitizeTranslatedHtml(html) {
|
|
211
|
+
html = html.replace(/([\w:-]+)\s*=\s*"([^"]*)"/g, (_, attrName, attrValue) => `${attrName}="${sanitizeAttributeValue(attrName, attrValue)}"`);
|
|
212
|
+
html = html.replace(/([\w:-]+)\s*=\s*'([^']*)'/g, (_, attrName, attrValue) => `${attrName}='${sanitizeAttributeValue(attrName, attrValue)}'`);
|
|
213
|
+
if (eventHandlerPattern.test(html)) {
|
|
214
|
+
warn("Potentially dangerous event handlers detected in translation. Consider removing onclick, onerror, etc. from your translation messages.");
|
|
215
|
+
html = html.replace(eventHandlerAttributePattern, "$1on$2");
|
|
216
|
+
}
|
|
217
|
+
if (srcdocPattern.test(html)) {
|
|
218
|
+
warn("Potentially dangerous srcdoc attribute detected in translation. Consider removing srcdoc from your translation messages.");
|
|
219
|
+
html = html.replace(srcdocAttributePattern, "$1s$2");
|
|
220
|
+
}
|
|
221
|
+
html = html.replace(unquotedUrlAttributePattern, (match, boundary, prefix, attrValue) => hasJavascriptScheme(attrValue) ? `${boundary}${prefix}about:blank` : match);
|
|
222
|
+
return html;
|
|
223
|
+
}
|
|
224
|
+
//#endregion
|
|
225
|
+
//#region packages/shared/src/messages.ts
|
|
226
|
+
const isNotObjectOrIsArray = (val) => !isObject(val) || isArray(val);
|
|
227
|
+
function deepCopy(src, des) {
|
|
228
|
+
if (isNotObjectOrIsArray(src) || isNotObjectOrIsArray(des) || des === Object.prototype) throw new Error("Invalid value");
|
|
229
|
+
const stack = [src, des];
|
|
230
|
+
while (stack.length) {
|
|
231
|
+
const des = stack.pop();
|
|
232
|
+
const src = stack.pop();
|
|
233
|
+
const keys = Object.keys(src);
|
|
234
|
+
for (let i = 0; i < keys.length; i++) {
|
|
235
|
+
const key = keys[i];
|
|
236
|
+
if (key === "__proto__") continue;
|
|
237
|
+
const value = src[key];
|
|
238
|
+
if (!isObject(value)) {
|
|
239
|
+
des[key] = value;
|
|
240
|
+
continue;
|
|
241
|
+
}
|
|
242
|
+
if (isArray(value)) {
|
|
243
|
+
const copied = [];
|
|
244
|
+
copied.length = value.length;
|
|
245
|
+
des[key] = copied;
|
|
246
|
+
stack.push(value, copied);
|
|
247
|
+
continue;
|
|
248
|
+
}
|
|
249
|
+
let desValue = des[key];
|
|
250
|
+
if (!isObject(desValue) || isArray(desValue)) desValue = des[key] = create();
|
|
251
|
+
stack.push(value, desValue);
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
//#endregion
|
|
256
|
+
//#region packages/message-compiler/src/errors.ts
|
|
257
|
+
const CompileErrorCodes = {
|
|
258
|
+
EXPECTED_TOKEN: 1,
|
|
259
|
+
INVALID_TOKEN_IN_PLACEHOLDER: 2,
|
|
260
|
+
UNTERMINATED_SINGLE_QUOTE_IN_PLACEHOLDER: 3,
|
|
261
|
+
UNKNOWN_ESCAPE_SEQUENCE: 4,
|
|
262
|
+
INVALID_UNICODE_ESCAPE_SEQUENCE: 5,
|
|
263
|
+
UNBALANCED_CLOSING_BRACE: 6,
|
|
264
|
+
UNTERMINATED_CLOSING_BRACE: 7,
|
|
265
|
+
EMPTY_PLACEHOLDER: 8,
|
|
266
|
+
NOT_ALLOW_NEST_PLACEHOLDER: 9,
|
|
267
|
+
INVALID_LINKED_FORMAT: 10,
|
|
268
|
+
MUST_HAVE_MESSAGES_IN_PLURAL: 11,
|
|
269
|
+
UNEXPECTED_EMPTY_LINKED_MODIFIER: 12,
|
|
270
|
+
UNEXPECTED_EMPTY_LINKED_KEY: 13,
|
|
271
|
+
UNEXPECTED_LEXICAL_ANALYSIS: 14,
|
|
272
|
+
UNHANDLED_CODEGEN_NODE_TYPE: 15,
|
|
273
|
+
UNHANDLED_MINIFIER_NODE_TYPE: 16
|
|
274
|
+
};
|
|
275
|
+
/** @internal */
|
|
276
|
+
const errorMessages$1 = {
|
|
277
|
+
[CompileErrorCodes.EXPECTED_TOKEN]: `Expected token: '{0}'`,
|
|
278
|
+
[CompileErrorCodes.INVALID_TOKEN_IN_PLACEHOLDER]: `Invalid token in placeholder: '{0}'`,
|
|
279
|
+
[CompileErrorCodes.UNTERMINATED_SINGLE_QUOTE_IN_PLACEHOLDER]: `Unterminated single quote in placeholder`,
|
|
280
|
+
[CompileErrorCodes.UNKNOWN_ESCAPE_SEQUENCE]: `Unknown escape sequence: \\{0}`,
|
|
281
|
+
[CompileErrorCodes.INVALID_UNICODE_ESCAPE_SEQUENCE]: `Invalid unicode escape sequence: {0}`,
|
|
282
|
+
[CompileErrorCodes.UNBALANCED_CLOSING_BRACE]: `Unbalanced closing brace`,
|
|
283
|
+
[CompileErrorCodes.UNTERMINATED_CLOSING_BRACE]: `Unterminated closing brace`,
|
|
284
|
+
[CompileErrorCodes.EMPTY_PLACEHOLDER]: `Empty placeholder`,
|
|
285
|
+
[CompileErrorCodes.NOT_ALLOW_NEST_PLACEHOLDER]: `Not allowed nest placeholder`,
|
|
286
|
+
[CompileErrorCodes.INVALID_LINKED_FORMAT]: `Invalid linked format`,
|
|
287
|
+
[CompileErrorCodes.MUST_HAVE_MESSAGES_IN_PLURAL]: `Plural must have messages`,
|
|
288
|
+
[CompileErrorCodes.UNEXPECTED_EMPTY_LINKED_MODIFIER]: `Unexpected empty linked modifier`,
|
|
289
|
+
[CompileErrorCodes.UNEXPECTED_EMPTY_LINKED_KEY]: `Unexpected empty linked key`,
|
|
290
|
+
[CompileErrorCodes.UNEXPECTED_LEXICAL_ANALYSIS]: `Unexpected lexical analysis in token: '{0}'`,
|
|
291
|
+
[CompileErrorCodes.UNHANDLED_CODEGEN_NODE_TYPE]: `unhandled codegen node type: '{0}'`,
|
|
292
|
+
[CompileErrorCodes.UNHANDLED_MINIFIER_NODE_TYPE]: `unhandled mimifier node type: '{0}'`
|
|
293
|
+
};
|
|
294
|
+
function createCompileError(code, loc, options = {}) {
|
|
295
|
+
const { domain, messages, args } = options;
|
|
296
|
+
const msg = format$1((messages || errorMessages$1)[code] || "", ...args || []);
|
|
297
|
+
const error = new SyntaxError(String(msg));
|
|
298
|
+
error.code = code;
|
|
299
|
+
if (loc) error.location = loc;
|
|
300
|
+
error.domain = domain;
|
|
301
|
+
return error;
|
|
302
|
+
}
|
|
303
|
+
//#endregion
|
|
304
|
+
//#region packages/core-base/src/ast.ts
|
|
305
|
+
function isMessageAST(val) {
|
|
306
|
+
return isObject(val) && resolveType(val) === 0 && (hasOwn(val, "b") || hasOwn(val, "body"));
|
|
307
|
+
}
|
|
308
|
+
const PROPS_BODY = ["b", "body"];
|
|
309
|
+
function resolveBody(node) {
|
|
310
|
+
return resolveProps(node, PROPS_BODY);
|
|
311
|
+
}
|
|
312
|
+
const PROPS_CASES = ["c", "cases"];
|
|
313
|
+
function resolveCases(node) {
|
|
314
|
+
return resolveProps(node, PROPS_CASES, []);
|
|
315
|
+
}
|
|
316
|
+
const PROPS_STATIC = ["s", "static"];
|
|
317
|
+
function resolveStatic(node) {
|
|
318
|
+
return resolveProps(node, PROPS_STATIC);
|
|
319
|
+
}
|
|
320
|
+
const PROPS_ITEMS = ["i", "items"];
|
|
321
|
+
function resolveItems(node) {
|
|
322
|
+
return resolveProps(node, PROPS_ITEMS, []);
|
|
323
|
+
}
|
|
324
|
+
const PROPS_TYPE = ["t", "type"];
|
|
325
|
+
function resolveType(node) {
|
|
326
|
+
return resolveProps(node, PROPS_TYPE);
|
|
327
|
+
}
|
|
328
|
+
const PROPS_VALUE = ["v", "value"];
|
|
329
|
+
function resolveValue$1(node, type) {
|
|
330
|
+
const resolved = resolveProps(node, PROPS_VALUE);
|
|
331
|
+
if (resolved != null) return resolved;
|
|
332
|
+
else throw createUnhandleNodeError(type);
|
|
333
|
+
}
|
|
334
|
+
const PROPS_MODIFIER = ["m", "modifier"];
|
|
335
|
+
function resolveLinkedModifier(node) {
|
|
336
|
+
return resolveProps(node, PROPS_MODIFIER);
|
|
337
|
+
}
|
|
338
|
+
const PROPS_KEY = ["k", "key"];
|
|
339
|
+
function resolveLinkedKey(node) {
|
|
340
|
+
const resolved = resolveProps(node, PROPS_KEY);
|
|
341
|
+
if (resolved) return resolved;
|
|
342
|
+
else throw createUnhandleNodeError(6);
|
|
343
|
+
}
|
|
344
|
+
function resolveProps(node, props, defaultValue) {
|
|
345
|
+
for (let i = 0; i < props.length; i++) {
|
|
346
|
+
const prop = props[i];
|
|
347
|
+
if (hasOwn(node, prop) && node[prop] != null) return node[prop];
|
|
348
|
+
}
|
|
349
|
+
return defaultValue;
|
|
350
|
+
}
|
|
351
|
+
const AST_NODE_PROPS_KEYS = [
|
|
352
|
+
...PROPS_BODY,
|
|
353
|
+
...PROPS_CASES,
|
|
354
|
+
...PROPS_STATIC,
|
|
355
|
+
...PROPS_ITEMS,
|
|
356
|
+
...PROPS_KEY,
|
|
357
|
+
...PROPS_MODIFIER,
|
|
358
|
+
...PROPS_VALUE,
|
|
359
|
+
...PROPS_TYPE
|
|
360
|
+
];
|
|
361
|
+
function createUnhandleNodeError(type) {
|
|
362
|
+
return /* @__PURE__ */ new Error(`unhandled node type: ${type}`);
|
|
363
|
+
}
|
|
364
|
+
//#endregion
|
|
365
|
+
//#region packages/core-base/src/format.ts
|
|
366
|
+
function format(ast) {
|
|
367
|
+
return (ctx) => formatParts(ctx, ast);
|
|
368
|
+
}
|
|
369
|
+
function formatParts(ctx, ast) {
|
|
370
|
+
const body = resolveBody(ast);
|
|
371
|
+
if (body == null) throw createUnhandleNodeError(0);
|
|
372
|
+
if (resolveType(body) === 1) {
|
|
373
|
+
const cases = resolveCases(body);
|
|
374
|
+
return ctx.plural(cases.reduce((messages, c) => [...isArray(messages) ? messages : [messages], formatMessageParts(ctx, c)], []));
|
|
375
|
+
} else return formatMessageParts(ctx, body);
|
|
376
|
+
}
|
|
377
|
+
function formatMessageParts(ctx, node) {
|
|
378
|
+
const static_ = resolveStatic(node);
|
|
379
|
+
if (static_ != null) return ctx.type === "text" ? static_ : ctx.normalize([static_]);
|
|
380
|
+
else {
|
|
381
|
+
const messages = resolveItems(node).reduce((acm, c) => [...acm, formatMessagePart(ctx, c)], []);
|
|
382
|
+
return ctx.normalize(messages);
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
function formatMessagePart(ctx, node) {
|
|
386
|
+
const type = resolveType(node);
|
|
387
|
+
switch (type) {
|
|
388
|
+
case 3: return resolveValue$1(node, type);
|
|
389
|
+
case 9: return resolveValue$1(node, type);
|
|
390
|
+
case 4: {
|
|
391
|
+
const named = node;
|
|
392
|
+
if (hasOwn(named, "k") && named.k) return ctx.interpolate(ctx.named(named.k));
|
|
393
|
+
if (hasOwn(named, "key") && named.key) return ctx.interpolate(ctx.named(named.key));
|
|
394
|
+
throw createUnhandleNodeError(type);
|
|
395
|
+
}
|
|
396
|
+
case 5: {
|
|
397
|
+
const list = node;
|
|
398
|
+
if (hasOwn(list, "i") && isNumber(list.i)) return ctx.interpolate(ctx.list(list.i));
|
|
399
|
+
if (hasOwn(list, "index") && isNumber(list.index)) return ctx.interpolate(ctx.list(list.index));
|
|
400
|
+
throw createUnhandleNodeError(type);
|
|
401
|
+
}
|
|
402
|
+
case 6: {
|
|
403
|
+
const linked = node;
|
|
404
|
+
const modifier = resolveLinkedModifier(linked);
|
|
405
|
+
const key = resolveLinkedKey(linked);
|
|
406
|
+
return ctx.linked(formatMessagePart(ctx, key), modifier ? formatMessagePart(ctx, modifier) : void 0, ctx.type);
|
|
407
|
+
}
|
|
408
|
+
case 7: return resolveValue$1(node, type);
|
|
409
|
+
case 8: return resolveValue$1(node, type);
|
|
410
|
+
default: throw new Error(`unhandled node on format message part: ${type}`);
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
//#endregion
|
|
414
|
+
//#region packages/core-base/src/compilation.ts
|
|
415
|
+
let compileCache = create();
|
|
416
|
+
function clearCompileCache() {
|
|
417
|
+
compileCache = create();
|
|
418
|
+
}
|
|
419
|
+
/* #__NO_SIDE_EFFECTS__ */
|
|
420
|
+
function compile(message, context) {
|
|
421
|
+
{
|
|
422
|
+
if (!isMessageAST(message)) {
|
|
423
|
+
warn(`the message that is resolve with key '${context.key}' is not supported for jit compilation`);
|
|
424
|
+
return (() => message);
|
|
425
|
+
}
|
|
426
|
+
const cacheKey = message.cacheKey;
|
|
427
|
+
if (cacheKey) {
|
|
428
|
+
const cached = compileCache[cacheKey];
|
|
429
|
+
if (cached) return cached;
|
|
430
|
+
return compileCache[cacheKey] = format(message);
|
|
431
|
+
} else return format(message);
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
//#endregion
|
|
435
|
+
//#region packages/core-base/src/errors.ts
|
|
436
|
+
const CoreErrorCodes = {
|
|
437
|
+
INVALID_ARGUMENT: 17,
|
|
438
|
+
INVALID_DATE_ARGUMENT: 18,
|
|
439
|
+
INVALID_ISO_DATE_ARGUMENT: 19,
|
|
440
|
+
NOT_SUPPORT_LOCALE_PROMISE_VALUE: 20,
|
|
441
|
+
NOT_SUPPORT_LOCALE_ASYNC_FUNCTION: 21,
|
|
442
|
+
NOT_SUPPORT_LOCALE_TYPE: 22
|
|
443
|
+
};
|
|
444
|
+
const CORE_ERROR_CODES_EXTEND_POINT = 23;
|
|
445
|
+
function createCoreError(code) {
|
|
446
|
+
return createCompileError(code, null, { messages: errorMessages });
|
|
447
|
+
}
|
|
448
|
+
/** @internal */
|
|
449
|
+
const errorMessages = {
|
|
450
|
+
[CoreErrorCodes.INVALID_ARGUMENT]: "Invalid arguments",
|
|
451
|
+
[CoreErrorCodes.INVALID_DATE_ARGUMENT]: "The date provided is an invalid Date object.Make sure your Date represents a valid date.",
|
|
452
|
+
[CoreErrorCodes.INVALID_ISO_DATE_ARGUMENT]: "The argument provided is not a valid ISO date string",
|
|
453
|
+
[CoreErrorCodes.NOT_SUPPORT_LOCALE_PROMISE_VALUE]: "cannot support promise value",
|
|
454
|
+
[CoreErrorCodes.NOT_SUPPORT_LOCALE_ASYNC_FUNCTION]: "cannot support async function",
|
|
455
|
+
[CoreErrorCodes.NOT_SUPPORT_LOCALE_TYPE]: "cannot support locale type"
|
|
456
|
+
};
|
|
457
|
+
//#endregion
|
|
458
|
+
//#region packages/core-base/src/fallbacker.ts
|
|
459
|
+
/** @internal */
|
|
460
|
+
function getLocale(context, options) {
|
|
461
|
+
return options.locale != null ? resolveLocale(options.locale) : resolveLocale(context.locale);
|
|
462
|
+
}
|
|
463
|
+
let _resolveLocale;
|
|
464
|
+
/** @internal */
|
|
465
|
+
function resolveLocale(locale) {
|
|
466
|
+
if (isString(locale)) return locale;
|
|
467
|
+
else if (isFunction(locale)) {
|
|
468
|
+
if (locale.resolvedOnce && _resolveLocale != null) return _resolveLocale;
|
|
469
|
+
else if (locale.constructor.name === "Function") {
|
|
470
|
+
const resolve = locale();
|
|
471
|
+
if (isPromise(resolve)) throw createCoreError(CoreErrorCodes.NOT_SUPPORT_LOCALE_PROMISE_VALUE);
|
|
472
|
+
return _resolveLocale = resolve;
|
|
473
|
+
} else throw createCoreError(CoreErrorCodes.NOT_SUPPORT_LOCALE_ASYNC_FUNCTION);
|
|
474
|
+
} else throw createCoreError(CoreErrorCodes.NOT_SUPPORT_LOCALE_TYPE);
|
|
475
|
+
}
|
|
476
|
+
/**
|
|
477
|
+
* Fallback with simple implemenation
|
|
478
|
+
*
|
|
479
|
+
* @remarks
|
|
480
|
+
* A fallback locale function implemented with a simple fallback algorithm.
|
|
481
|
+
*
|
|
482
|
+
* Basically, the chain consists of `start` plus the specified fallback: for a string or array `fallbackLocale`, the value as specified in the props is used; for a map `fallbackLocale`, the map's **keys** are used and the `default` key is skipped since it is not a locale name.
|
|
483
|
+
*
|
|
484
|
+
* @param ctx - A {@link CoreContext | context}
|
|
485
|
+
* @param fallback - A {@link FallbackLocale | fallback locale}
|
|
486
|
+
* @param start - A starting {@link Locale | locale}
|
|
487
|
+
*
|
|
488
|
+
* @returns Fallback locales
|
|
489
|
+
*
|
|
490
|
+
* @VueI18nGeneral
|
|
491
|
+
*/
|
|
492
|
+
function fallbackWithSimple(_ctx, fallback, start) {
|
|
493
|
+
return [.../* @__PURE__ */ new Set([start, ...isArray(fallback) ? fallback : isObject(fallback) ? Object.keys(fallback).filter((locale) => locale !== "default") : isString(fallback) ? [fallback] : [start]])];
|
|
494
|
+
}
|
|
495
|
+
/**
|
|
496
|
+
* Fallback with locale chain
|
|
497
|
+
*
|
|
498
|
+
* @remarks
|
|
499
|
+
* A fallback locale function implemented with a fallback chain algorithm. It's used in VueI18n as default.
|
|
500
|
+
*
|
|
501
|
+
* Chains are cached per fallback identity. If you mutate an object or array fallback in place,
|
|
502
|
+
* pass a new object or array instead so that the chain is recomputed.
|
|
503
|
+
*
|
|
504
|
+
* @param ctx - A {@link CoreContext | context}
|
|
505
|
+
* @param fallback - A {@link FallbackLocale | fallback locale}
|
|
506
|
+
* @param start - A starting {@link Locale | locale}
|
|
507
|
+
*
|
|
508
|
+
* @returns Fallback locales
|
|
509
|
+
*
|
|
510
|
+
* @VueI18nSee [Fallbacking](../../guide/essentials/fallback)
|
|
511
|
+
*
|
|
512
|
+
* @VueI18nGeneral
|
|
513
|
+
*/
|
|
514
|
+
function fallbackWithLocaleChain(ctx, fallback, start) {
|
|
515
|
+
const startLocale = isString(start) ? start : DEFAULT_LOCALE;
|
|
516
|
+
const context = ctx;
|
|
517
|
+
let chains;
|
|
518
|
+
if (isObject(fallback)) {
|
|
519
|
+
if (!context.__localeChainObjectCache) context.__localeChainObjectCache = /* @__PURE__ */ new WeakMap();
|
|
520
|
+
chains = context.__localeChainObjectCache.get(fallback);
|
|
521
|
+
if (!chains) {
|
|
522
|
+
chains = /* @__PURE__ */ new Map();
|
|
523
|
+
context.__localeChainObjectCache.set(fallback, chains);
|
|
524
|
+
}
|
|
525
|
+
} else {
|
|
526
|
+
if (!context.__localeChainCache) context.__localeChainCache = /* @__PURE__ */ new Map();
|
|
527
|
+
chains = context.__localeChainCache.get(fallback);
|
|
528
|
+
if (!chains) {
|
|
529
|
+
chains = /* @__PURE__ */ new Map();
|
|
530
|
+
context.__localeChainCache.set(fallback, chains);
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
const cached = chains.get(startLocale);
|
|
534
|
+
if (cached) return cached;
|
|
535
|
+
const chain = [];
|
|
536
|
+
let block = [start];
|
|
537
|
+
while (isArray(block)) block = appendBlockToChain(chain, block, fallback);
|
|
538
|
+
const defaults = isArray(fallback) || !isPlainObject(fallback) ? fallback : fallback["default"] ? fallback["default"] : null;
|
|
539
|
+
block = isString(defaults) ? [defaults] : defaults;
|
|
540
|
+
if (isArray(block)) appendBlockToChain(chain, block, false);
|
|
541
|
+
chains.set(startLocale, chain);
|
|
542
|
+
return chain;
|
|
543
|
+
}
|
|
544
|
+
function appendBlockToChain(chain, block, blocks) {
|
|
545
|
+
let follow = true;
|
|
546
|
+
for (let i = 0; i < block.length && isBoolean(follow); i++) {
|
|
547
|
+
const locale = block[i];
|
|
548
|
+
if (isString(locale)) follow = appendLocaleToChain(chain, block[i], blocks);
|
|
549
|
+
}
|
|
550
|
+
return follow;
|
|
551
|
+
}
|
|
552
|
+
function appendLocaleToChain(chain, locale, blocks) {
|
|
553
|
+
let follow;
|
|
554
|
+
const tokens = locale.split("-");
|
|
555
|
+
do {
|
|
556
|
+
follow = appendItemToChain(chain, tokens.join("-"), blocks);
|
|
557
|
+
tokens.splice(-1, 1);
|
|
558
|
+
} while (tokens.length && follow === true);
|
|
559
|
+
return follow;
|
|
560
|
+
}
|
|
561
|
+
function appendItemToChain(chain, target, blocks) {
|
|
562
|
+
let follow = false;
|
|
563
|
+
if (!chain.includes(target)) {
|
|
564
|
+
follow = true;
|
|
565
|
+
if (target) {
|
|
566
|
+
follow = target[target.length - 1] !== "!";
|
|
567
|
+
const locale = target.replace(/!/g, "");
|
|
568
|
+
chain.push(locale);
|
|
569
|
+
if ((isArray(blocks) || isPlainObject(blocks)) && blocks[locale]) follow = blocks[locale];
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
return follow;
|
|
573
|
+
}
|
|
574
|
+
//#endregion
|
|
575
|
+
//#region packages/core-base/src/resolver.ts
|
|
576
|
+
const pathStateMachine = [];
|
|
577
|
+
pathStateMachine[0] = {
|
|
578
|
+
["w"]: [0],
|
|
579
|
+
["i"]: [3, 0],
|
|
580
|
+
["["]: [4],
|
|
581
|
+
["o"]: [7]
|
|
582
|
+
};
|
|
583
|
+
pathStateMachine[1] = {
|
|
584
|
+
["w"]: [1],
|
|
585
|
+
["."]: [2],
|
|
586
|
+
["["]: [4],
|
|
587
|
+
["o"]: [7]
|
|
588
|
+
};
|
|
589
|
+
pathStateMachine[2] = {
|
|
590
|
+
["w"]: [2],
|
|
591
|
+
["i"]: [3, 0],
|
|
592
|
+
["0"]: [3, 0]
|
|
593
|
+
};
|
|
594
|
+
pathStateMachine[3] = {
|
|
595
|
+
["i"]: [3, 0],
|
|
596
|
+
["0"]: [3, 0],
|
|
597
|
+
["w"]: [1, 1],
|
|
598
|
+
["."]: [2, 1],
|
|
599
|
+
["["]: [4, 1],
|
|
600
|
+
["o"]: [7, 1]
|
|
601
|
+
};
|
|
602
|
+
pathStateMachine[4] = {
|
|
603
|
+
["'"]: [5, 0],
|
|
604
|
+
["\""]: [6, 0],
|
|
605
|
+
["["]: [4, 2],
|
|
606
|
+
["]"]: [1, 3],
|
|
607
|
+
["o"]: 8,
|
|
608
|
+
["l"]: [4, 0]
|
|
609
|
+
};
|
|
610
|
+
pathStateMachine[5] = {
|
|
611
|
+
["'"]: [4, 0],
|
|
612
|
+
["o"]: 8,
|
|
613
|
+
["l"]: [5, 0]
|
|
614
|
+
};
|
|
615
|
+
pathStateMachine[6] = {
|
|
616
|
+
["\""]: [4, 0],
|
|
617
|
+
["o"]: 8,
|
|
618
|
+
["l"]: [6, 0]
|
|
619
|
+
};
|
|
620
|
+
/**
|
|
621
|
+
* Check if an expression is a literal value.
|
|
622
|
+
*/
|
|
623
|
+
const literalValueRE = /^\s?(?:true|false|-?[\d.]+|'[^']*'|"[^"]*")\s?$/;
|
|
624
|
+
function isLiteral(exp) {
|
|
625
|
+
return literalValueRE.test(exp);
|
|
626
|
+
}
|
|
627
|
+
/**
|
|
628
|
+
* Strip quotes from a string
|
|
629
|
+
*/
|
|
630
|
+
function stripQuotes(str) {
|
|
631
|
+
const a = str.charCodeAt(0);
|
|
632
|
+
return a === str.charCodeAt(str.length - 1) && (a === 34 || a === 39) ? str.slice(1, -1) : str;
|
|
633
|
+
}
|
|
634
|
+
/**
|
|
635
|
+
* Determine the type of a character in a keypath.
|
|
636
|
+
*/
|
|
637
|
+
function getPathCharType(ch) {
|
|
638
|
+
if (ch === void 0 || ch === null) return "o";
|
|
639
|
+
switch (ch.charCodeAt(0)) {
|
|
640
|
+
case 91:
|
|
641
|
+
case 93:
|
|
642
|
+
case 46:
|
|
643
|
+
case 34:
|
|
644
|
+
case 39: return ch;
|
|
645
|
+
case 95:
|
|
646
|
+
case 36:
|
|
647
|
+
case 45: return "i";
|
|
648
|
+
case 9:
|
|
649
|
+
case 10:
|
|
650
|
+
case 13:
|
|
651
|
+
case 160:
|
|
652
|
+
case 65279:
|
|
653
|
+
case 8232:
|
|
654
|
+
case 8233: return "w";
|
|
655
|
+
}
|
|
656
|
+
return "i";
|
|
657
|
+
}
|
|
658
|
+
/**
|
|
659
|
+
* Format a subPath, return its plain form if it is
|
|
660
|
+
* a literal string or number. Otherwise prepend the
|
|
661
|
+
* dynamic indicator (*).
|
|
662
|
+
*/
|
|
663
|
+
function formatSubPath(path) {
|
|
664
|
+
const trimmed = path.trim();
|
|
665
|
+
if (path.charAt(0) === "0" && isNaN(parseInt(path))) return false;
|
|
666
|
+
return isLiteral(trimmed) ? stripQuotes(trimmed) : "*" + trimmed;
|
|
667
|
+
}
|
|
668
|
+
/**
|
|
669
|
+
* Parse a string path into an array of segments
|
|
670
|
+
*/
|
|
671
|
+
function parse(path) {
|
|
672
|
+
const keys = [];
|
|
673
|
+
let index = -1;
|
|
674
|
+
let mode = 0;
|
|
675
|
+
let subPathDepth = 0;
|
|
676
|
+
let c;
|
|
677
|
+
let key;
|
|
678
|
+
let newChar;
|
|
679
|
+
let type;
|
|
680
|
+
let transition;
|
|
681
|
+
let action;
|
|
682
|
+
let typeMap;
|
|
683
|
+
const actions = [];
|
|
684
|
+
actions[0] = () => {
|
|
685
|
+
if (key === void 0) key = newChar;
|
|
686
|
+
else key += newChar;
|
|
687
|
+
};
|
|
688
|
+
actions[1] = () => {
|
|
689
|
+
if (key !== void 0) {
|
|
690
|
+
keys.push(key);
|
|
691
|
+
key = void 0;
|
|
692
|
+
}
|
|
693
|
+
};
|
|
694
|
+
actions[2] = () => {
|
|
695
|
+
actions[0]();
|
|
696
|
+
subPathDepth++;
|
|
697
|
+
};
|
|
698
|
+
actions[3] = () => {
|
|
699
|
+
if (subPathDepth > 0) {
|
|
700
|
+
subPathDepth--;
|
|
701
|
+
mode = 4;
|
|
702
|
+
actions[0]();
|
|
703
|
+
} else {
|
|
704
|
+
subPathDepth = 0;
|
|
705
|
+
if (key === void 0) return false;
|
|
706
|
+
key = formatSubPath(key);
|
|
707
|
+
if (key === false) return false;
|
|
708
|
+
else actions[1]();
|
|
709
|
+
}
|
|
710
|
+
};
|
|
711
|
+
function maybeUnescapeQuote() {
|
|
712
|
+
const nextChar = path[index + 1];
|
|
713
|
+
if (mode === 5 && nextChar === "'" || mode === 6 && nextChar === "\"") {
|
|
714
|
+
index++;
|
|
715
|
+
newChar = "\\" + nextChar;
|
|
716
|
+
actions[0]();
|
|
717
|
+
return true;
|
|
718
|
+
}
|
|
719
|
+
}
|
|
720
|
+
while (mode !== null) {
|
|
721
|
+
index++;
|
|
722
|
+
c = path[index];
|
|
723
|
+
if (c === "\\" && maybeUnescapeQuote()) continue;
|
|
724
|
+
type = getPathCharType(c);
|
|
725
|
+
typeMap = pathStateMachine[mode];
|
|
726
|
+
transition = typeMap[type] || typeMap["l"] || 8;
|
|
727
|
+
if (transition === 8) return;
|
|
728
|
+
mode = transition[0];
|
|
729
|
+
if (transition[1] !== void 0) {
|
|
730
|
+
action = actions[transition[1]];
|
|
731
|
+
if (action) {
|
|
732
|
+
newChar = c;
|
|
733
|
+
if (action() === false) return;
|
|
734
|
+
}
|
|
735
|
+
}
|
|
736
|
+
if (mode === 7) return keys;
|
|
737
|
+
}
|
|
738
|
+
}
|
|
739
|
+
const cache = /* @__PURE__ */ new Map();
|
|
740
|
+
/**
|
|
741
|
+
* key-value message resolver
|
|
742
|
+
*
|
|
743
|
+
* @remarks
|
|
744
|
+
* Resolves messages with the key-value structure. Note that messages with a hierarchical structure such as objects cannot be resolved
|
|
745
|
+
*
|
|
746
|
+
* @param obj - A target object to be resolved with path
|
|
747
|
+
* @param path - A {@link Path | path} to resolve the value of message
|
|
748
|
+
*
|
|
749
|
+
* @returns A resolved {@link PathValue | path value}
|
|
750
|
+
*
|
|
751
|
+
* @VueI18nGeneral
|
|
752
|
+
*/
|
|
753
|
+
function resolveWithKeyValue(obj, path) {
|
|
754
|
+
return isObject(obj) ? obj[path] : null;
|
|
755
|
+
}
|
|
756
|
+
/**
|
|
757
|
+
* message resolver
|
|
758
|
+
*
|
|
759
|
+
* @remarks
|
|
760
|
+
* Resolves messages. messages with a hierarchical structure such as objects can be resolved. This resolver is used in VueI18n as default.
|
|
761
|
+
*
|
|
762
|
+
* @param obj - A target object to be resolved with path
|
|
763
|
+
* @param path - A {@link Path | path} to resolve the value of message
|
|
764
|
+
*
|
|
765
|
+
* @returns A resolved {@link PathValue | path value}
|
|
766
|
+
*
|
|
767
|
+
* @VueI18nGeneral
|
|
768
|
+
*/
|
|
769
|
+
function resolveValue(obj, path) {
|
|
770
|
+
if (!isObject(obj)) return null;
|
|
771
|
+
let hit = cache.get(path);
|
|
772
|
+
if (!hit) {
|
|
773
|
+
hit = parse(path);
|
|
774
|
+
if (hit) cache.set(path, hit);
|
|
775
|
+
}
|
|
776
|
+
if (!hit) return null;
|
|
777
|
+
const len = hit.length;
|
|
778
|
+
let last = obj;
|
|
779
|
+
let i = 0;
|
|
780
|
+
while (i < len) {
|
|
781
|
+
const key = hit[i];
|
|
782
|
+
/**
|
|
783
|
+
* NOTE:
|
|
784
|
+
* if `key` is intlify message format AST node key and `last` is intlify message format AST, skip it.
|
|
785
|
+
* because the AST node is not a key-value structure.
|
|
786
|
+
*/
|
|
787
|
+
if (AST_NODE_PROPS_KEYS.includes(key) && isMessageAST(last)) return null;
|
|
788
|
+
if (!isObject(last)) return null;
|
|
789
|
+
if (!hasOwn(last, key)) return null;
|
|
790
|
+
const val = last[key];
|
|
791
|
+
if (val === void 0) return null;
|
|
792
|
+
if (isFunction(last)) return null;
|
|
793
|
+
last = val;
|
|
794
|
+
i++;
|
|
795
|
+
}
|
|
796
|
+
return last;
|
|
797
|
+
}
|
|
798
|
+
//#endregion
|
|
799
|
+
//#region packages/core-base/src/warnings.ts
|
|
800
|
+
const CoreWarnCodes = {
|
|
801
|
+
NOT_FOUND_KEY: 1,
|
|
802
|
+
FALLBACK_TO_TRANSLATE: 2,
|
|
803
|
+
CANNOT_FORMAT_NUMBER: 3,
|
|
804
|
+
FALLBACK_TO_NUMBER_FORMAT: 4,
|
|
805
|
+
CANNOT_FORMAT_DATE: 5,
|
|
806
|
+
FALLBACK_TO_DATE_FORMAT: 6,
|
|
807
|
+
EXPERIMENTAL_CUSTOM_MESSAGE_COMPILER: 7,
|
|
808
|
+
INVALID_NUMBER_ARGUMENT: 8,
|
|
809
|
+
INVALID_DATE_ARGUMENT: 9
|
|
810
|
+
};
|
|
811
|
+
const CORE_WARN_CODES_EXTEND_POINT = 10;
|
|
812
|
+
/** @internal */
|
|
813
|
+
const warnMessages = {
|
|
814
|
+
[CoreWarnCodes.NOT_FOUND_KEY]: `Not found '{key}' key in '{locale}' locale messages.`,
|
|
815
|
+
[CoreWarnCodes.FALLBACK_TO_TRANSLATE]: `Fall back to translate '{key}' key with '{target}' locale.`,
|
|
816
|
+
[CoreWarnCodes.CANNOT_FORMAT_NUMBER]: `Cannot format a number value due to not supported Intl.NumberFormat.`,
|
|
817
|
+
[CoreWarnCodes.FALLBACK_TO_NUMBER_FORMAT]: `Fall back to number format '{key}' key with '{target}' locale.`,
|
|
818
|
+
[CoreWarnCodes.CANNOT_FORMAT_DATE]: `Cannot format a date value due to not supported Intl.DateTimeFormat.`,
|
|
819
|
+
[CoreWarnCodes.FALLBACK_TO_DATE_FORMAT]: `Fall back to datetime format '{key}' key with '{target}' locale.`,
|
|
820
|
+
[CoreWarnCodes.EXPERIMENTAL_CUSTOM_MESSAGE_COMPILER]: `This project is using Custom Message Compiler, which is an experimental feature. It may receive breaking changes or be removed in the future.`,
|
|
821
|
+
[CoreWarnCodes.INVALID_NUMBER_ARGUMENT]: `Invalid argument for number formatting: expected a number but received '{value}'.`,
|
|
822
|
+
[CoreWarnCodes.INVALID_DATE_ARGUMENT]: `Invalid argument for datetime formatting: expected a Date, number, or ISO string but received '{value}'.`
|
|
823
|
+
};
|
|
824
|
+
function getWarnMessage(code, ...args) {
|
|
825
|
+
return format$1(warnMessages[code], ...args);
|
|
826
|
+
}
|
|
827
|
+
//#endregion
|
|
828
|
+
//#region packages/core-base/src/context.ts
|
|
829
|
+
/**
|
|
830
|
+
* Intlify core-base version
|
|
831
|
+
* @internal
|
|
832
|
+
*/
|
|
833
|
+
const VERSION = "12.0.0-alpha.5";
|
|
834
|
+
const NOT_RESOLVED = -1;
|
|
835
|
+
const DEFAULT_LOCALE = "en-US";
|
|
836
|
+
const MISSING_RESOLVE_VALUE = "";
|
|
837
|
+
const capitalize = (str) => `${str.charAt(0).toLocaleUpperCase()}${str.substr(1)}`;
|
|
838
|
+
function getDefaultLinkedModifiers() {
|
|
839
|
+
return {
|
|
840
|
+
upper: (val, type) => {
|
|
841
|
+
return type === "text" && isString(val) ? val.toUpperCase() : type === "vnode" && isObject(val) && "__v_isVNode" in val ? val.children.toUpperCase() : val;
|
|
842
|
+
},
|
|
843
|
+
lower: (val, type) => {
|
|
844
|
+
return type === "text" && isString(val) ? val.toLowerCase() : type === "vnode" && isObject(val) && "__v_isVNode" in val ? val.children.toLowerCase() : val;
|
|
845
|
+
},
|
|
846
|
+
capitalize: (val, type) => {
|
|
847
|
+
return type === "text" && isString(val) ? capitalize(val) : type === "vnode" && isObject(val) && "__v_isVNode" in val ? capitalize(val.children) : val;
|
|
848
|
+
}
|
|
849
|
+
};
|
|
850
|
+
}
|
|
851
|
+
let _compiler;
|
|
852
|
+
/**
|
|
853
|
+
* Register the message compiler
|
|
854
|
+
*
|
|
855
|
+
* @param compiler - A {@link MessageCompiler} function
|
|
856
|
+
*
|
|
857
|
+
* @deprecated Use `messageCompiler` option of `createI18n` or `createCoreContext` instead. This function will be removed in v13.
|
|
858
|
+
*
|
|
859
|
+
* @VueI18nGeneral
|
|
860
|
+
*/
|
|
861
|
+
function registerMessageCompiler(compiler) {
|
|
862
|
+
warnOnce(`registerMessageCompiler is deprecated. Use 'messageCompiler' option of 'createI18n' or 'createCoreContext' instead.`);
|
|
863
|
+
_compiler = compiler;
|
|
864
|
+
}
|
|
865
|
+
let _resolver;
|
|
866
|
+
/**
|
|
867
|
+
* Register the message resolver
|
|
868
|
+
*
|
|
869
|
+
* @param resolver - A {@link MessageResolver} function
|
|
870
|
+
*
|
|
871
|
+
* @deprecated Use `messageResolver` option of `createI18n` or `createCoreContext` instead. This function will be removed in v13.
|
|
872
|
+
*
|
|
873
|
+
* @VueI18nGeneral
|
|
874
|
+
*/
|
|
875
|
+
function registerMessageResolver(resolver) {
|
|
876
|
+
warnOnce(`registerMessageResolver is deprecated. Use 'messageResolver' option of 'createI18n' or 'createCoreContext' instead.`);
|
|
877
|
+
_resolver = resolver;
|
|
878
|
+
}
|
|
879
|
+
let _fallbacker;
|
|
880
|
+
/**
|
|
881
|
+
* Register the locale fallbacker
|
|
882
|
+
*
|
|
883
|
+
* @param fallbacker - A {@link LocaleFallbacker} function
|
|
884
|
+
*
|
|
885
|
+
* @deprecated Use `localeFallbacker` option of `createI18n` or `createCoreContext` instead. This function will be removed in v13.
|
|
886
|
+
*
|
|
887
|
+
* @VueI18nGeneral
|
|
888
|
+
*/
|
|
889
|
+
function registerLocaleFallbacker(fallbacker) {
|
|
890
|
+
warnOnce(`registerLocaleFallbacker is deprecated. Use 'localeFallbacker' option of 'createI18n' or 'createCoreContext' instead.`);
|
|
891
|
+
_fallbacker = fallbacker;
|
|
892
|
+
}
|
|
893
|
+
let _cid = 0;
|
|
894
|
+
function createCoreContext(options = {}) {
|
|
895
|
+
const onWarn = isFunction(options.onWarn) ? options.onWarn : warn;
|
|
896
|
+
const version = isString(options.version) ? options.version : VERSION;
|
|
897
|
+
const locale = isString(options.locale) || isFunction(options.locale) ? options.locale : DEFAULT_LOCALE;
|
|
898
|
+
const _locale = isFunction(locale) ? DEFAULT_LOCALE : locale;
|
|
899
|
+
const fallbackLocale = isArray(options.fallbackLocale) || isPlainObject(options.fallbackLocale) || isString(options.fallbackLocale) || options.fallbackLocale === false ? options.fallbackLocale : _locale;
|
|
900
|
+
const messages = isPlainObject(options.messages) ? options.messages : createResources(_locale);
|
|
901
|
+
const datetimeFormats = isPlainObject(options.datetimeFormats) ? options.datetimeFormats : createResources(_locale);
|
|
902
|
+
const numberFormats = isPlainObject(options.numberFormats) ? options.numberFormats : createResources(_locale);
|
|
903
|
+
const modifiers = assign(create(), options.modifiers, getDefaultLinkedModifiers());
|
|
904
|
+
const pluralRules = options.pluralRules || create();
|
|
905
|
+
const missing = isFunction(options.missing) ? options.missing : null;
|
|
906
|
+
const missingWarn = isBoolean(options.missingWarn) || isRegExp(options.missingWarn) ? options.missingWarn : true;
|
|
907
|
+
const fallbackWarn = isBoolean(options.fallbackWarn) || isRegExp(options.fallbackWarn) ? options.fallbackWarn : true;
|
|
908
|
+
const fallbackFormat = !!options.fallbackFormat;
|
|
909
|
+
const unresolving = !!options.unresolving;
|
|
910
|
+
const postTranslation = isFunction(options.postTranslation) ? options.postTranslation : null;
|
|
911
|
+
const processor = isPlainObject(options.processor) ? options.processor : null;
|
|
912
|
+
const warnHtmlMessage = isBoolean(options.warnHtmlMessage) ? options.warnHtmlMessage : true;
|
|
913
|
+
const escapeParameter = !!options.escapeParameter;
|
|
914
|
+
const messageCompiler = isFunction(options.messageCompiler) ? options.messageCompiler : _compiler || null;
|
|
915
|
+
const messageResolver = isFunction(options.messageResolver) ? options.messageResolver : _resolver || resolveWithKeyValue;
|
|
916
|
+
const localeFallbacker = isFunction(options.localeFallbacker) ? options.localeFallbacker : _fallbacker || fallbackWithSimple;
|
|
917
|
+
const fallbackContext = isObject(options.fallbackContext) ? options.fallbackContext : void 0;
|
|
918
|
+
const internalOptions = options;
|
|
919
|
+
const __datetimeFormatters = isObject(internalOptions.__datetimeFormatters) ? internalOptions.__datetimeFormatters : /* @__PURE__ */ new Map();
|
|
920
|
+
const __numberFormatters = isObject(internalOptions.__numberFormatters) ? internalOptions.__numberFormatters : /* @__PURE__ */ new Map();
|
|
921
|
+
_cid++;
|
|
922
|
+
const context = {
|
|
923
|
+
version,
|
|
924
|
+
cid: _cid,
|
|
925
|
+
locale,
|
|
926
|
+
fallbackLocale,
|
|
927
|
+
messages,
|
|
928
|
+
modifiers,
|
|
929
|
+
pluralRules,
|
|
930
|
+
missing,
|
|
931
|
+
missingWarn,
|
|
932
|
+
fallbackWarn,
|
|
933
|
+
fallbackFormat,
|
|
934
|
+
unresolving,
|
|
935
|
+
postTranslation,
|
|
936
|
+
processor,
|
|
937
|
+
warnHtmlMessage,
|
|
938
|
+
escapeParameter,
|
|
939
|
+
messageCompiler,
|
|
940
|
+
messageResolver,
|
|
941
|
+
localeFallbacker,
|
|
942
|
+
fallbackContext,
|
|
943
|
+
onWarn
|
|
944
|
+
};
|
|
945
|
+
context.datetimeFormats = datetimeFormats;
|
|
946
|
+
context.numberFormats = numberFormats;
|
|
947
|
+
context.__datetimeFormatters = __datetimeFormatters;
|
|
948
|
+
context.__numberFormatters = __numberFormatters;
|
|
949
|
+
context.__v_emitter = internalOptions.__v_emitter != null ? internalOptions.__v_emitter : void 0;
|
|
950
|
+
return context;
|
|
951
|
+
}
|
|
952
|
+
const createResources = (locale) => ({ [locale]: create() });
|
|
953
|
+
/**
|
|
954
|
+
* @version 12.0.0
|
|
955
|
+
*/
|
|
956
|
+
function getLocaleMessage(ctx, locale) {
|
|
957
|
+
const src = getOwn(ctx.messages, locale);
|
|
958
|
+
if (src == null) return;
|
|
959
|
+
const dest = create();
|
|
960
|
+
deepCopy(src, dest);
|
|
961
|
+
return dest;
|
|
962
|
+
}
|
|
963
|
+
/**
|
|
964
|
+
* @version 12.0.0
|
|
965
|
+
*/
|
|
966
|
+
function setLocaleMessage(ctx, locale, messages) {
|
|
967
|
+
if (isObjectPrototypeKey(locale)) return;
|
|
968
|
+
ctx.messages[locale] = messages;
|
|
969
|
+
}
|
|
970
|
+
/** @internal */
|
|
971
|
+
function isTranslateFallbackWarn(fallback, key) {
|
|
972
|
+
return isRegExp(fallback) ? fallback.test(key) : fallback;
|
|
973
|
+
}
|
|
974
|
+
/** @internal */
|
|
975
|
+
function isTranslateMissingWarn(missing, key) {
|
|
976
|
+
return isRegExp(missing) ? missing.test(key) : missing;
|
|
977
|
+
}
|
|
978
|
+
/** @internal */
|
|
979
|
+
function handleMissing(context, key, locale, missingWarn, type) {
|
|
980
|
+
const { missing, onWarn } = context;
|
|
981
|
+
{
|
|
982
|
+
const emitter = context.__v_emitter;
|
|
983
|
+
if (emitter) emitter.emit("missing", {
|
|
984
|
+
locale,
|
|
985
|
+
key,
|
|
986
|
+
type,
|
|
987
|
+
groupId: toDevtoolsGroupId(type, key)
|
|
988
|
+
});
|
|
989
|
+
}
|
|
990
|
+
if (missing !== null) {
|
|
991
|
+
const ret = missing(context, locale, key, type);
|
|
992
|
+
return isString(ret) ? ret : key;
|
|
993
|
+
} else {
|
|
994
|
+
if (isTranslateMissingWarn(missingWarn, key)) onWarn(getWarnMessage(CoreWarnCodes.NOT_FOUND_KEY, {
|
|
995
|
+
key,
|
|
996
|
+
locale
|
|
997
|
+
}));
|
|
998
|
+
return key;
|
|
999
|
+
}
|
|
1000
|
+
}
|
|
1001
|
+
function invalidateLocaleChainCache(ctx, fallback) {
|
|
1002
|
+
const context = ctx;
|
|
1003
|
+
if (isObject(fallback)) context.__localeChainObjectCache?.delete(fallback);
|
|
1004
|
+
else context.__localeChainCache?.delete(fallback);
|
|
1005
|
+
}
|
|
1006
|
+
/** @internal */
|
|
1007
|
+
function updateFallbackLocale(ctx, locale, fallback) {
|
|
1008
|
+
invalidateLocaleChainCache(ctx, fallback);
|
|
1009
|
+
if (ctx.fallbackContext) invalidateLocaleChainCache(ctx.fallbackContext, fallback);
|
|
1010
|
+
ctx.localeFallbacker(ctx, fallback, locale);
|
|
1011
|
+
}
|
|
1012
|
+
/** @internal */
|
|
1013
|
+
function isAlmostSameLocale(locale, compareLocale) {
|
|
1014
|
+
if (locale === compareLocale) return false;
|
|
1015
|
+
return locale.split("-")[0] === compareLocale.split("-")[0];
|
|
1016
|
+
}
|
|
1017
|
+
/** @internal */
|
|
1018
|
+
function isImplicitFallback(targetLocale, locales) {
|
|
1019
|
+
const index = locales.indexOf(targetLocale);
|
|
1020
|
+
if (index === -1) return false;
|
|
1021
|
+
for (let i = index + 1; i < locales.length; i++) if (isAlmostSameLocale(targetLocale, locales[i])) return true;
|
|
1022
|
+
return false;
|
|
1023
|
+
}
|
|
1024
|
+
//#endregion
|
|
1025
|
+
//#region packages/core-base/src/formatter.ts
|
|
1026
|
+
function resolveFormatLocale(context, key, locale, formats, missingWarn, fallbackWarn, type) {
|
|
1027
|
+
const { fallbackLocale, localeFallbacker, onWarn } = context;
|
|
1028
|
+
const locales = localeFallbacker(context, fallbackLocale, locale);
|
|
1029
|
+
let from = locale;
|
|
1030
|
+
for (let i = 0; i < locales.length; i++) {
|
|
1031
|
+
const targetLocale = locales[i];
|
|
1032
|
+
if (locale !== targetLocale && isTranslateFallbackWarn(fallbackWarn, key)) onWarn(getWarnMessage(type === "datetime format" ? CoreWarnCodes.FALLBACK_TO_DATE_FORMAT : CoreWarnCodes.FALLBACK_TO_NUMBER_FORMAT, {
|
|
1033
|
+
key,
|
|
1034
|
+
target: targetLocale
|
|
1035
|
+
}));
|
|
1036
|
+
if (locale !== targetLocale) {
|
|
1037
|
+
const emitter = context.__v_emitter;
|
|
1038
|
+
if (emitter) emitter.emit("fallback", {
|
|
1039
|
+
type,
|
|
1040
|
+
key,
|
|
1041
|
+
from,
|
|
1042
|
+
to: targetLocale,
|
|
1043
|
+
groupId: toDevtoolsGroupId(type, key)
|
|
1044
|
+
});
|
|
1045
|
+
}
|
|
1046
|
+
const format = (formats[targetLocale] || {})[key];
|
|
1047
|
+
if (isPlainObject(format) && isString(targetLocale)) return targetLocale;
|
|
1048
|
+
handleMissing(context, key, targetLocale, missingWarn, type);
|
|
1049
|
+
from = targetLocale;
|
|
1050
|
+
}
|
|
1051
|
+
return null;
|
|
1052
|
+
}
|
|
1053
|
+
function getFormatterCacheKey(locale, key, overrides) {
|
|
1054
|
+
let id = `${locale}__${key}`;
|
|
1055
|
+
if (isPlainObject(overrides) && !isKeylessObject(overrides)) id = `${id}__${JSON.stringify(overrides)}`;
|
|
1056
|
+
return id;
|
|
1057
|
+
}
|
|
1058
|
+
function clearFormatCache(formatters, locale, format) {
|
|
1059
|
+
for (const key in format) {
|
|
1060
|
+
const prefix = `${locale}__${key}`;
|
|
1061
|
+
for (const id of formatters.keys()) if (id === prefix || id.startsWith(`${prefix}__`)) formatters.delete(id);
|
|
1062
|
+
}
|
|
1063
|
+
}
|
|
1064
|
+
function parseFormatArgs(args, options, initialOverrides, optionsKeys) {
|
|
1065
|
+
const [, arg2, arg3, arg4] = args;
|
|
1066
|
+
let overrides = initialOverrides;
|
|
1067
|
+
if (isString(arg2)) options.key = arg2;
|
|
1068
|
+
else if (isPlainObject(arg2)) Object.keys(arg2).forEach((key) => {
|
|
1069
|
+
if (optionsKeys.includes(key)) overrides[key] = arg2[key];
|
|
1070
|
+
else options[key] = arg2[key];
|
|
1071
|
+
});
|
|
1072
|
+
if (isString(arg3)) options.locale = arg3;
|
|
1073
|
+
else if (isPlainObject(arg3)) overrides = arg3;
|
|
1074
|
+
if (isPlainObject(arg4)) overrides = arg4;
|
|
1075
|
+
return overrides;
|
|
1076
|
+
}
|
|
1077
|
+
//#endregion
|
|
1078
|
+
//#region packages/core-base/src/intl.ts
|
|
1079
|
+
const intlDefined = typeof Intl !== "undefined";
|
|
1080
|
+
const Availabilities = {
|
|
1081
|
+
dateTimeFormat: intlDefined && typeof Intl.DateTimeFormat !== "undefined",
|
|
1082
|
+
numberFormat: intlDefined && typeof Intl.NumberFormat !== "undefined"
|
|
1083
|
+
};
|
|
1084
|
+
//#endregion
|
|
1085
|
+
//#region packages/core-base/src/datetime.ts
|
|
1086
|
+
function datetime(context, ...args) {
|
|
1087
|
+
const { datetimeFormats, unresolving, onWarn } = context;
|
|
1088
|
+
const { __datetimeFormatters } = context;
|
|
1089
|
+
if (!Availabilities.dateTimeFormat) {
|
|
1090
|
+
onWarn(getWarnMessage(CoreWarnCodes.CANNOT_FORMAT_DATE));
|
|
1091
|
+
return "";
|
|
1092
|
+
}
|
|
1093
|
+
if (!isString(args[0]) && !isDate(args[0]) && !isNumber(args[0])) {
|
|
1094
|
+
onWarn(getWarnMessage(CoreWarnCodes.INVALID_DATE_ARGUMENT, { value: String(args[0]) }));
|
|
1095
|
+
return "";
|
|
1096
|
+
}
|
|
1097
|
+
const [key, value, options, overrides] = parseDateTimeArgs(...args);
|
|
1098
|
+
const missingWarn = isBoolean(options.missingWarn) ? options.missingWarn : context.missingWarn;
|
|
1099
|
+
const fallbackWarn = isBoolean(options.fallbackWarn) ? options.fallbackWarn : context.fallbackWarn;
|
|
1100
|
+
const part = !!options.part;
|
|
1101
|
+
const locale = getLocale(context, options);
|
|
1102
|
+
if (!isString(key) || key === "") {
|
|
1103
|
+
const formatter = new Intl.DateTimeFormat(locale.replace(/!/g, ""), overrides);
|
|
1104
|
+
return !part ? formatter.format(value) : formatter.formatToParts(value);
|
|
1105
|
+
}
|
|
1106
|
+
const targetLocale = resolveFormatLocale(context, key, locale, datetimeFormats, missingWarn, fallbackWarn, "datetime format");
|
|
1107
|
+
if (!isString(targetLocale)) return unresolving ? -1 : key;
|
|
1108
|
+
const format = datetimeFormats[targetLocale][key];
|
|
1109
|
+
const id = getFormatterCacheKey(targetLocale, key, overrides);
|
|
1110
|
+
let formatter = __datetimeFormatters.get(id);
|
|
1111
|
+
if (!formatter) {
|
|
1112
|
+
formatter = new Intl.DateTimeFormat(targetLocale, assign({}, format, overrides));
|
|
1113
|
+
__datetimeFormatters.set(id, formatter);
|
|
1114
|
+
}
|
|
1115
|
+
return !part ? formatter.format(value) : formatter.formatToParts(value);
|
|
1116
|
+
}
|
|
1117
|
+
/** @internal */
|
|
1118
|
+
const DATETIME_FORMAT_OPTIONS_KEYS = [
|
|
1119
|
+
"localeMatcher",
|
|
1120
|
+
"weekday",
|
|
1121
|
+
"era",
|
|
1122
|
+
"year",
|
|
1123
|
+
"month",
|
|
1124
|
+
"day",
|
|
1125
|
+
"hour",
|
|
1126
|
+
"minute",
|
|
1127
|
+
"second",
|
|
1128
|
+
"timeZoneName",
|
|
1129
|
+
"formatMatcher",
|
|
1130
|
+
"hour12",
|
|
1131
|
+
"timeZone",
|
|
1132
|
+
"dateStyle",
|
|
1133
|
+
"timeStyle",
|
|
1134
|
+
"calendar",
|
|
1135
|
+
"dayPeriod",
|
|
1136
|
+
"numberingSystem",
|
|
1137
|
+
"hourCycle",
|
|
1138
|
+
"fractionalSecondDigits"
|
|
1139
|
+
];
|
|
1140
|
+
/** @internal */
|
|
1141
|
+
function parseDateTimeArgs(...args) {
|
|
1142
|
+
const [arg1] = args;
|
|
1143
|
+
const options = create();
|
|
1144
|
+
const initialOverrides = create();
|
|
1145
|
+
let value;
|
|
1146
|
+
if (isString(arg1)) {
|
|
1147
|
+
const matches = arg1.match(/^(\d{4}-\d{2}-\d{2})(?:(T|\s)(.+))?$/);
|
|
1148
|
+
if (!matches) throw createCoreError(CoreErrorCodes.INVALID_ISO_DATE_ARGUMENT);
|
|
1149
|
+
const dateTime = matches[3] ? matches[3].trim().startsWith("T") ? `${matches[1].trim()}${matches[3].trim()}` : `${matches[1].trim()}T${matches[3].trim()}` : matches[1].trim();
|
|
1150
|
+
value = new Date(dateTime);
|
|
1151
|
+
try {
|
|
1152
|
+
value.toISOString();
|
|
1153
|
+
} catch {
|
|
1154
|
+
throw createCoreError(CoreErrorCodes.INVALID_ISO_DATE_ARGUMENT);
|
|
1155
|
+
}
|
|
1156
|
+
} else if (isDate(arg1)) {
|
|
1157
|
+
if (isNaN(arg1.getTime())) throw createCoreError(CoreErrorCodes.INVALID_DATE_ARGUMENT);
|
|
1158
|
+
value = arg1;
|
|
1159
|
+
} else if (isNumber(arg1)) value = arg1;
|
|
1160
|
+
else throw createCoreError(CoreErrorCodes.INVALID_ARGUMENT);
|
|
1161
|
+
const overrides = parseFormatArgs(args, options, initialOverrides, DATETIME_FORMAT_OPTIONS_KEYS);
|
|
1162
|
+
return [
|
|
1163
|
+
options.key || "",
|
|
1164
|
+
value,
|
|
1165
|
+
options,
|
|
1166
|
+
overrides
|
|
1167
|
+
];
|
|
1168
|
+
}
|
|
1169
|
+
/** @internal */
|
|
1170
|
+
function clearDateTimeFormat(ctx, locale, format) {
|
|
1171
|
+
clearFormatCache(ctx.__datetimeFormatters, locale, format);
|
|
1172
|
+
}
|
|
1173
|
+
//#endregion
|
|
1174
|
+
//#region packages/core-base/src/number.ts
|
|
1175
|
+
function number(context, ...args) {
|
|
1176
|
+
const { numberFormats, unresolving, onWarn } = context;
|
|
1177
|
+
const { __numberFormatters } = context;
|
|
1178
|
+
if (!Availabilities.numberFormat) {
|
|
1179
|
+
onWarn(getWarnMessage(CoreWarnCodes.CANNOT_FORMAT_NUMBER));
|
|
1180
|
+
return "";
|
|
1181
|
+
}
|
|
1182
|
+
if (!isNumber(args[0])) {
|
|
1183
|
+
onWarn(getWarnMessage(CoreWarnCodes.INVALID_NUMBER_ARGUMENT, { value: String(args[0]) }));
|
|
1184
|
+
return "";
|
|
1185
|
+
}
|
|
1186
|
+
const [key, value, options, overrides] = parseNumberArgs(...args);
|
|
1187
|
+
const missingWarn = isBoolean(options.missingWarn) ? options.missingWarn : context.missingWarn;
|
|
1188
|
+
const fallbackWarn = isBoolean(options.fallbackWarn) ? options.fallbackWarn : context.fallbackWarn;
|
|
1189
|
+
const part = !!options.part;
|
|
1190
|
+
const locale = getLocale(context, options);
|
|
1191
|
+
if (!isString(key) || key === "") {
|
|
1192
|
+
const formatter = new Intl.NumberFormat(locale.replace(/!/g, ""), overrides);
|
|
1193
|
+
return !part ? formatter.format(value) : formatter.formatToParts(value);
|
|
1194
|
+
}
|
|
1195
|
+
const targetLocale = resolveFormatLocale(context, key, locale, numberFormats, missingWarn, fallbackWarn, "number format");
|
|
1196
|
+
if (!isString(targetLocale)) return unresolving ? -1 : key;
|
|
1197
|
+
const format = numberFormats[targetLocale][key];
|
|
1198
|
+
const id = getFormatterCacheKey(targetLocale, key, overrides);
|
|
1199
|
+
let formatter = __numberFormatters.get(id);
|
|
1200
|
+
if (!formatter) {
|
|
1201
|
+
formatter = new Intl.NumberFormat(targetLocale, assign({}, format, overrides));
|
|
1202
|
+
__numberFormatters.set(id, formatter);
|
|
1203
|
+
}
|
|
1204
|
+
return !part ? formatter.format(value) : formatter.formatToParts(value);
|
|
1205
|
+
}
|
|
1206
|
+
/** @internal */
|
|
1207
|
+
const NUMBER_FORMAT_OPTIONS_KEYS = [
|
|
1208
|
+
"localeMatcher",
|
|
1209
|
+
"style",
|
|
1210
|
+
"currency",
|
|
1211
|
+
"currencyDisplay",
|
|
1212
|
+
"currencySign",
|
|
1213
|
+
"useGrouping",
|
|
1214
|
+
"minimumIntegerDigits",
|
|
1215
|
+
"minimumFractionDigits",
|
|
1216
|
+
"maximumFractionDigits",
|
|
1217
|
+
"minimumSignificantDigits",
|
|
1218
|
+
"maximumSignificantDigits",
|
|
1219
|
+
"compactDisplay",
|
|
1220
|
+
"notation",
|
|
1221
|
+
"signDisplay",
|
|
1222
|
+
"unit",
|
|
1223
|
+
"unitDisplay",
|
|
1224
|
+
"roundingMode",
|
|
1225
|
+
"roundingPriority",
|
|
1226
|
+
"roundingIncrement",
|
|
1227
|
+
"trailingZeroDisplay"
|
|
1228
|
+
];
|
|
1229
|
+
/** @internal */
|
|
1230
|
+
function parseNumberArgs(...args) {
|
|
1231
|
+
const [arg1] = args;
|
|
1232
|
+
const options = create();
|
|
1233
|
+
const initialOverrides = create();
|
|
1234
|
+
if (!isNumber(arg1)) throw createCoreError(CoreErrorCodes.INVALID_ARGUMENT);
|
|
1235
|
+
const value = arg1;
|
|
1236
|
+
const overrides = parseFormatArgs(args, options, initialOverrides, NUMBER_FORMAT_OPTIONS_KEYS);
|
|
1237
|
+
return [
|
|
1238
|
+
options.key || "",
|
|
1239
|
+
value,
|
|
1240
|
+
options,
|
|
1241
|
+
overrides
|
|
1242
|
+
];
|
|
1243
|
+
}
|
|
1244
|
+
/** @internal */
|
|
1245
|
+
function clearNumberFormat(ctx, locale, format) {
|
|
1246
|
+
clearFormatCache(ctx.__numberFormatters, locale, format);
|
|
1247
|
+
}
|
|
1248
|
+
//#endregion
|
|
1249
|
+
//#region packages/core-base/src/runtime.ts
|
|
1250
|
+
const DEFAULT_MODIFIER = (str) => str;
|
|
1251
|
+
const DEFAULT_MESSAGE = (_ctx) => "";
|
|
1252
|
+
const DEFAULT_MESSAGE_DATA_TYPE = "text";
|
|
1253
|
+
const DEFAULT_NORMALIZE = (values) => values.length === 0 ? "" : join(values);
|
|
1254
|
+
const DEFAULT_INTERPOLATE = toDisplayString;
|
|
1255
|
+
function pluralDefault(choice, choicesLength) {
|
|
1256
|
+
choice = Math.abs(choice);
|
|
1257
|
+
if (choicesLength === 2) return choice === 1 ? 0 : 1;
|
|
1258
|
+
return Math.min(choice, 2);
|
|
1259
|
+
}
|
|
1260
|
+
const PLURAL_CATEGORY_ORDER = [
|
|
1261
|
+
"zero",
|
|
1262
|
+
"one",
|
|
1263
|
+
"two",
|
|
1264
|
+
"few",
|
|
1265
|
+
"many",
|
|
1266
|
+
"other"
|
|
1267
|
+
];
|
|
1268
|
+
const intlPluralRulesCache = /* @__PURE__ */ new Map();
|
|
1269
|
+
function getIntlPluralRules(locale) {
|
|
1270
|
+
let cached = intlPluralRulesCache.get(locale);
|
|
1271
|
+
if (!cached) {
|
|
1272
|
+
const rules = new Intl.PluralRules(locale);
|
|
1273
|
+
cached = {
|
|
1274
|
+
rules,
|
|
1275
|
+
categories: rules.resolvedOptions().pluralCategories.slice().sort((a, b) => PLURAL_CATEGORY_ORDER.indexOf(a) - PLURAL_CATEGORY_ORDER.indexOf(b))
|
|
1276
|
+
};
|
|
1277
|
+
intlPluralRulesCache.set(locale, cached);
|
|
1278
|
+
}
|
|
1279
|
+
return cached;
|
|
1280
|
+
}
|
|
1281
|
+
function getPluralIndex(options) {
|
|
1282
|
+
if (isNumber(options.pluralIndex)) return options.pluralIndex;
|
|
1283
|
+
return isNumber(options.named?.count) ? options.named.count : isNumber(options.named?.n) ? options.named.n : -1;
|
|
1284
|
+
}
|
|
1285
|
+
function createMessageContext(options = {}) {
|
|
1286
|
+
const locale = options.locale;
|
|
1287
|
+
const pluralIndex = getPluralIndex(options);
|
|
1288
|
+
let resolvedPluralRule;
|
|
1289
|
+
if (isString(locale) && isFunction(options.pluralRules?.[locale])) resolvedPluralRule = options.pluralRules[locale];
|
|
1290
|
+
else if (isString(locale) && typeof Intl !== "undefined" && typeof Intl.PluralRules !== "undefined") resolvedPluralRule = (choice, choicesLength) => {
|
|
1291
|
+
const { rules, categories } = getIntlPluralRules(locale);
|
|
1292
|
+
if (choicesLength > categories.length) return pluralDefault(choice, choicesLength);
|
|
1293
|
+
const category = rules.select(Math.abs(choice));
|
|
1294
|
+
const index = categories.indexOf(category);
|
|
1295
|
+
return Math.min(index === -1 ? choicesLength - 1 : index, choicesLength - 1);
|
|
1296
|
+
};
|
|
1297
|
+
else resolvedPluralRule = pluralDefault;
|
|
1298
|
+
const orgPluralRule = resolvedPluralRule === pluralDefault ? void 0 : pluralDefault;
|
|
1299
|
+
const plural = (messages) => messages[resolvedPluralRule(pluralIndex, messages.length, orgPluralRule)];
|
|
1300
|
+
const _list = options.list || [];
|
|
1301
|
+
const list = (index) => _list[index];
|
|
1302
|
+
const _named = options.named || create();
|
|
1303
|
+
if (isNumber(options.pluralIndex)) {
|
|
1304
|
+
_named.count ??= options.pluralIndex;
|
|
1305
|
+
_named.n ??= options.pluralIndex;
|
|
1306
|
+
}
|
|
1307
|
+
const named = (key) => _named[key];
|
|
1308
|
+
function message(key, useLinked) {
|
|
1309
|
+
const msg = isFunction(options.messages) ? options.messages(key, !!useLinked) : isObject(options.messages) ? options.messages[key] : false;
|
|
1310
|
+
return !msg ? options.parent ? options.parent.message(key) : DEFAULT_MESSAGE : msg;
|
|
1311
|
+
}
|
|
1312
|
+
const _modifier = (name) => options.modifiers ? options.modifiers[name] : DEFAULT_MODIFIER;
|
|
1313
|
+
const normalize = isFunction(options.processor?.normalize) ? options.processor.normalize : DEFAULT_NORMALIZE;
|
|
1314
|
+
const interpolate = isFunction(options.processor?.interpolate) ? options.processor.interpolate : DEFAULT_INTERPOLATE;
|
|
1315
|
+
const type = isString(options.processor?.type) ? options.processor.type : DEFAULT_MESSAGE_DATA_TYPE;
|
|
1316
|
+
const linked = (key, ...args) => {
|
|
1317
|
+
const [arg1, arg2] = args;
|
|
1318
|
+
let type = "text";
|
|
1319
|
+
let modifier = "";
|
|
1320
|
+
if (args.length === 1) {
|
|
1321
|
+
if (isObject(arg1)) {
|
|
1322
|
+
modifier = arg1.modifier || modifier;
|
|
1323
|
+
type = arg1.type || type;
|
|
1324
|
+
} else if (isString(arg1)) modifier = arg1 || modifier;
|
|
1325
|
+
} else if (args.length === 2) {
|
|
1326
|
+
if (isString(arg1)) modifier = arg1 || modifier;
|
|
1327
|
+
if (isString(arg2)) type = arg2 || type;
|
|
1328
|
+
}
|
|
1329
|
+
const ret = message(key, true)(ctx);
|
|
1330
|
+
const resolved = ret === "" || ret === void 0 ? key : ret;
|
|
1331
|
+
const msg = type === "vnode" && isArray(resolved) && modifier ? resolved[0] : resolved;
|
|
1332
|
+
return modifier ? _modifier(modifier)(msg, type) : msg;
|
|
1333
|
+
};
|
|
1334
|
+
const ctx = {
|
|
1335
|
+
["list"]: list,
|
|
1336
|
+
["named"]: named,
|
|
1337
|
+
["plural"]: plural,
|
|
1338
|
+
["linked"]: linked,
|
|
1339
|
+
["message"]: message,
|
|
1340
|
+
["type"]: type,
|
|
1341
|
+
["interpolate"]: interpolate,
|
|
1342
|
+
["normalize"]: normalize,
|
|
1343
|
+
["values"]: assign(create(), _list, _named)
|
|
1344
|
+
};
|
|
1345
|
+
return ctx;
|
|
1346
|
+
}
|
|
1347
|
+
//#endregion
|
|
1348
|
+
//#region packages/core-base/src/translate.ts
|
|
1349
|
+
const NOOP_MESSAGE_FUNCTION = () => "";
|
|
1350
|
+
const isMessageFunction = (val) => isFunction(val);
|
|
1351
|
+
/** @internal */
|
|
1352
|
+
const isMessageFormat = (val) => isString(val) || isMessageAST(val) || isMessageFunction(val);
|
|
1353
|
+
function translate(context, ...args) {
|
|
1354
|
+
const [key, options] = parseTranslateArgs(...args);
|
|
1355
|
+
const locale = getLocale(context, options);
|
|
1356
|
+
const escapeParameter = isBoolean(options.escapeParameter) ? options.escapeParameter : context.escapeParameter;
|
|
1357
|
+
escapeParameter && escapeParams(options);
|
|
1358
|
+
const resolvedMessage = !!options.resolvedMessage;
|
|
1359
|
+
let [format, targetLocale, message] = !resolvedMessage ? resolveMessageFormat(context, key, locale, context.fallbackLocale, isBoolean(options.fallbackWarn) ? options.fallbackWarn : context.fallbackWarn, isBoolean(options.missingWarn) ? options.missingWarn : context.missingWarn) : [
|
|
1360
|
+
key,
|
|
1361
|
+
locale,
|
|
1362
|
+
context.messages[locale] || create()
|
|
1363
|
+
];
|
|
1364
|
+
let cacheBaseKey = key;
|
|
1365
|
+
if (!resolvedMessage && !isMessageFormat(format)) {
|
|
1366
|
+
const defaultMsgOrKey = isString(options.default) ? options.default : isBoolean(options.default) || context.fallbackFormat ? !context.messageCompiler ? () => key : key : null;
|
|
1367
|
+
if (context.fallbackFormat || defaultMsgOrKey != null && (isString(defaultMsgOrKey) || isFunction(defaultMsgOrKey))) {
|
|
1368
|
+
format = defaultMsgOrKey;
|
|
1369
|
+
cacheBaseKey = format;
|
|
1370
|
+
}
|
|
1371
|
+
}
|
|
1372
|
+
if (!resolvedMessage && (!isMessageFormat(format) || !isString(targetLocale))) return context.unresolving ? -1 : key;
|
|
1373
|
+
if (isString(format) && context.messageCompiler == null) {
|
|
1374
|
+
warn(`The message format compilation is not supported in this build. Because message compiler isn't included. You need to pre-compilation all message format. So translate function return '${stringifyKey(key)}'.`);
|
|
1375
|
+
return key;
|
|
1376
|
+
}
|
|
1377
|
+
let occurred = false;
|
|
1378
|
+
const onError = () => {
|
|
1379
|
+
occurred = true;
|
|
1380
|
+
};
|
|
1381
|
+
const msg = !isMessageFunction(format) ? compileMessageFormat(context, key, targetLocale, format, cacheBaseKey, onError) : format;
|
|
1382
|
+
if (occurred) return format;
|
|
1383
|
+
const msgContext = createMessageContext(getMessageContextOptions(context, targetLocale, message, options));
|
|
1384
|
+
const messaged = inBrowser ? measureEvaluateMessage(context, msg, msgContext) : msg(msgContext);
|
|
1385
|
+
let ret = context.postTranslation ? context.postTranslation(messaged, key) : messaged;
|
|
1386
|
+
if (escapeParameter && isString(ret)) ret = sanitizeTranslatedHtml(ret);
|
|
1387
|
+
return ret;
|
|
1388
|
+
}
|
|
1389
|
+
function escapeParams(options) {
|
|
1390
|
+
if (isArray(options.list)) options.list = options.list.map((item) => isString(item) ? escapeHtml(item) : item);
|
|
1391
|
+
if (isObject(options.named)) {
|
|
1392
|
+
const source = options.named;
|
|
1393
|
+
const named = create();
|
|
1394
|
+
for (const key of Object.keys(source)) {
|
|
1395
|
+
const value = source[key];
|
|
1396
|
+
named[key] = isString(value) ? escapeHtml(value) : value;
|
|
1397
|
+
}
|
|
1398
|
+
options.named = named;
|
|
1399
|
+
}
|
|
1400
|
+
}
|
|
1401
|
+
function resolveMessageFormat(context, key, locale, fallbackLocale, fallbackWarn, missingWarn) {
|
|
1402
|
+
const { messages, onWarn, messageResolver: resolveValue, localeFallbacker } = context;
|
|
1403
|
+
const locales = localeFallbacker(context, fallbackLocale, locale);
|
|
1404
|
+
let message = create();
|
|
1405
|
+
let targetLocale;
|
|
1406
|
+
let format = null;
|
|
1407
|
+
let from = locale;
|
|
1408
|
+
const type = "translate";
|
|
1409
|
+
for (let i = 0; i < locales.length; i++) {
|
|
1410
|
+
targetLocale = locales[i];
|
|
1411
|
+
if (locale !== targetLocale && !isAlmostSameLocale(locale, targetLocale) && isTranslateFallbackWarn(fallbackWarn, key)) onWarn(getWarnMessage(CoreWarnCodes.FALLBACK_TO_TRANSLATE, {
|
|
1412
|
+
key,
|
|
1413
|
+
target: targetLocale
|
|
1414
|
+
}));
|
|
1415
|
+
if (locale !== targetLocale) {
|
|
1416
|
+
const emitter = context.__v_emitter;
|
|
1417
|
+
if (emitter) emitter.emit("fallback", {
|
|
1418
|
+
type,
|
|
1419
|
+
key,
|
|
1420
|
+
from,
|
|
1421
|
+
to: targetLocale,
|
|
1422
|
+
groupId: toDevtoolsGroupId(type, key)
|
|
1423
|
+
});
|
|
1424
|
+
}
|
|
1425
|
+
message = messages[targetLocale] || create();
|
|
1426
|
+
let start = null;
|
|
1427
|
+
let startTag;
|
|
1428
|
+
let endTag;
|
|
1429
|
+
if (inBrowser) {
|
|
1430
|
+
start = window.performance.now();
|
|
1431
|
+
startTag = "intlify-message-resolve-start";
|
|
1432
|
+
endTag = "intlify-message-resolve-end";
|
|
1433
|
+
mark?.(startTag);
|
|
1434
|
+
}
|
|
1435
|
+
if ((format = resolveValue(message, key)) === null) format = message[key];
|
|
1436
|
+
if (inBrowser) {
|
|
1437
|
+
const end = window.performance.now();
|
|
1438
|
+
const emitter = context.__v_emitter;
|
|
1439
|
+
if (emitter && start && format) emitter.emit("message-resolve", {
|
|
1440
|
+
type: "message-resolve",
|
|
1441
|
+
key,
|
|
1442
|
+
message: format,
|
|
1443
|
+
time: end - start,
|
|
1444
|
+
groupId: toDevtoolsGroupId(type, key)
|
|
1445
|
+
});
|
|
1446
|
+
if (startTag && endTag && mark && measure) {
|
|
1447
|
+
mark(endTag);
|
|
1448
|
+
measure("intlify message resolve", startTag, endTag);
|
|
1449
|
+
}
|
|
1450
|
+
}
|
|
1451
|
+
if (isMessageFormat(format)) break;
|
|
1452
|
+
if (!isImplicitFallback(targetLocale, locales)) {
|
|
1453
|
+
const missingRet = handleMissing(context, key, targetLocale, missingWarn, type);
|
|
1454
|
+
if (missingRet !== key) format = missingRet;
|
|
1455
|
+
}
|
|
1456
|
+
from = targetLocale;
|
|
1457
|
+
}
|
|
1458
|
+
return [
|
|
1459
|
+
format,
|
|
1460
|
+
targetLocale,
|
|
1461
|
+
message
|
|
1462
|
+
];
|
|
1463
|
+
}
|
|
1464
|
+
function stringifyKey(key) {
|
|
1465
|
+
return isString(key) ? key : isObject(key) ? JSON.stringify(key) : isFunction(key) ? key.name || "function" : "";
|
|
1466
|
+
}
|
|
1467
|
+
function compileMessageFormat(context, key, targetLocale, format, cacheBaseKey, onError) {
|
|
1468
|
+
if (isMessageFunction(format)) {
|
|
1469
|
+
const msg = format;
|
|
1470
|
+
msg.locale = msg.locale || targetLocale;
|
|
1471
|
+
msg.key = msg.key || key;
|
|
1472
|
+
return msg;
|
|
1473
|
+
}
|
|
1474
|
+
if (context.messageCompiler == null) {
|
|
1475
|
+
const msg = (() => format);
|
|
1476
|
+
msg.locale = targetLocale;
|
|
1477
|
+
msg.key = key;
|
|
1478
|
+
return msg;
|
|
1479
|
+
}
|
|
1480
|
+
let start = null;
|
|
1481
|
+
let startTag;
|
|
1482
|
+
let endTag;
|
|
1483
|
+
if (inBrowser && mark) {
|
|
1484
|
+
start = window.performance.now();
|
|
1485
|
+
startTag = "intlify-message-compilation-start";
|
|
1486
|
+
endTag = "intlify-message-compilation-end";
|
|
1487
|
+
mark?.(startTag);
|
|
1488
|
+
}
|
|
1489
|
+
const msg = context.messageCompiler(format, getCompileContext(context, targetLocale, cacheBaseKey, format, context.warnHtmlMessage, onError));
|
|
1490
|
+
if (inBrowser) {
|
|
1491
|
+
const end = window.performance.now();
|
|
1492
|
+
const emitter = context.__v_emitter;
|
|
1493
|
+
if (emitter && start) emitter.emit("message-compilation", {
|
|
1494
|
+
type: "message-compilation",
|
|
1495
|
+
message: format,
|
|
1496
|
+
time: end - start,
|
|
1497
|
+
groupId: toDevtoolsGroupId("translate", key)
|
|
1498
|
+
});
|
|
1499
|
+
if (startTag && endTag && mark && measure) {
|
|
1500
|
+
mark(endTag);
|
|
1501
|
+
measure("intlify message compilation", startTag, endTag);
|
|
1502
|
+
}
|
|
1503
|
+
}
|
|
1504
|
+
msg.locale = targetLocale;
|
|
1505
|
+
msg.key = key;
|
|
1506
|
+
msg.source = format;
|
|
1507
|
+
return msg;
|
|
1508
|
+
}
|
|
1509
|
+
let measureEvaluateMessage;
|
|
1510
|
+
if (inBrowser) {
|
|
1511
|
+
const startTag = "intlify-message-evaluation-start";
|
|
1512
|
+
const endTag = "intlify-message-evaluation-end";
|
|
1513
|
+
measureEvaluateMessage = (context, msg, msgCtx) => {
|
|
1514
|
+
const start = window.performance.now();
|
|
1515
|
+
mark(startTag);
|
|
1516
|
+
const messaged = msg(msgCtx);
|
|
1517
|
+
const end = window.performance.now();
|
|
1518
|
+
context.__v_emitter?.emit("message-evaluation", {
|
|
1519
|
+
type: "message-evaluation",
|
|
1520
|
+
value: messaged,
|
|
1521
|
+
time: end - start,
|
|
1522
|
+
groupId: toDevtoolsGroupId("translate", msg.key)
|
|
1523
|
+
});
|
|
1524
|
+
mark(endTag);
|
|
1525
|
+
measure("intlify message evaluation", startTag, endTag);
|
|
1526
|
+
return messaged;
|
|
1527
|
+
};
|
|
1528
|
+
}
|
|
1529
|
+
/** @internal */
|
|
1530
|
+
function parseTranslateArgs(...args) {
|
|
1531
|
+
const [arg1, arg2, arg3] = args;
|
|
1532
|
+
if (!isString(arg1) && !isNumber(arg1) && !isMessageFunction(arg1) && !isMessageAST(arg1)) throw createCoreError(CoreErrorCodes.INVALID_ARGUMENT);
|
|
1533
|
+
const key = isNumber(arg1) ? String(arg1) : isMessageFunction(arg1) ? arg1 : arg1;
|
|
1534
|
+
const options = create();
|
|
1535
|
+
if (isNumber(arg2)) options.plural = arg2;
|
|
1536
|
+
else if (isString(arg2)) options.default = arg2;
|
|
1537
|
+
else if (isPlainObject(arg2) && !isKeylessObject(arg2)) options.named = arg2;
|
|
1538
|
+
else if (isArray(arg2)) options.list = arg2;
|
|
1539
|
+
if (isNumber(arg3)) options.plural = arg3;
|
|
1540
|
+
else if (isString(arg3)) options.default = arg3;
|
|
1541
|
+
else if (isPlainObject(arg3)) assign(options, arg3);
|
|
1542
|
+
return [key, options];
|
|
1543
|
+
}
|
|
1544
|
+
function getCompileContext(context, locale, key, source, warnHtmlMessage, onError) {
|
|
1545
|
+
return {
|
|
1546
|
+
locale,
|
|
1547
|
+
key,
|
|
1548
|
+
warnHtmlMessage,
|
|
1549
|
+
onError: (err) => {
|
|
1550
|
+
onError?.(err);
|
|
1551
|
+
{
|
|
1552
|
+
const _source = getSourceForCodeFrame(source);
|
|
1553
|
+
const codeFrame = err.location && _source && generateCodeFrame(_source, err.location.start.offset, err.location.end.offset);
|
|
1554
|
+
const emitter = context.__v_emitter;
|
|
1555
|
+
if (emitter && _source) emitter.emit("compile-error", {
|
|
1556
|
+
message: _source,
|
|
1557
|
+
error: err.message,
|
|
1558
|
+
start: err.location && err.location.start.offset,
|
|
1559
|
+
end: err.location && err.location.end.offset,
|
|
1560
|
+
groupId: toDevtoolsGroupId("translate", key)
|
|
1561
|
+
});
|
|
1562
|
+
const message = `Message compilation error: ${err.message}`;
|
|
1563
|
+
throw new SyntaxError(codeFrame ? `${message}\n${codeFrame}` : message);
|
|
1564
|
+
}
|
|
1565
|
+
},
|
|
1566
|
+
onCacheKey: (source) => generateFormatCacheKey(locale, key, source)
|
|
1567
|
+
};
|
|
1568
|
+
}
|
|
1569
|
+
function getSourceForCodeFrame(source) {
|
|
1570
|
+
if (isString(source)) return source;
|
|
1571
|
+
else if (source.loc?.source) return source.loc.source;
|
|
1572
|
+
}
|
|
1573
|
+
function getMessageContextOptions(context, locale, message, options) {
|
|
1574
|
+
const { modifiers, pluralRules, messageResolver: resolveValue, fallbackLocale, fallbackWarn, missingWarn, fallbackContext } = context;
|
|
1575
|
+
const resolveMessage = (key, useLinked) => {
|
|
1576
|
+
let val = resolveValue(message, key);
|
|
1577
|
+
if (val == null && (fallbackContext || useLinked)) {
|
|
1578
|
+
const [format, , message] = resolveMessageFormat(fallbackContext || context, key, locale, fallbackLocale, fallbackWarn, missingWarn);
|
|
1579
|
+
val = format ?? resolveValue(message, key);
|
|
1580
|
+
}
|
|
1581
|
+
if (isString(val) || isMessageAST(val)) {
|
|
1582
|
+
let occurred = false;
|
|
1583
|
+
const onError = () => {
|
|
1584
|
+
occurred = true;
|
|
1585
|
+
};
|
|
1586
|
+
const msg = compileMessageFormat(context, key, locale, val, key, onError);
|
|
1587
|
+
return !occurred ? msg : NOOP_MESSAGE_FUNCTION;
|
|
1588
|
+
} else if (isMessageFunction(val)) return val;
|
|
1589
|
+
else return NOOP_MESSAGE_FUNCTION;
|
|
1590
|
+
};
|
|
1591
|
+
return {
|
|
1592
|
+
locale,
|
|
1593
|
+
modifiers,
|
|
1594
|
+
pluralRules,
|
|
1595
|
+
messages: resolveMessage,
|
|
1596
|
+
processor: context.processor ?? void 0,
|
|
1597
|
+
list: options.list ?? void 0,
|
|
1598
|
+
named: options.named ?? void 0,
|
|
1599
|
+
pluralIndex: isNumber(options.plural) ? options.plural : void 0
|
|
1600
|
+
};
|
|
1601
|
+
}
|
|
1602
|
+
//#endregion
|
|
1603
|
+
//#region packages/core/src/runtime.ts
|
|
1604
|
+
registerMessageCompiler(compile);
|
|
1605
|
+
registerMessageResolver(resolveValue);
|
|
1606
|
+
registerLocaleFallbacker(fallbackWithLocaleChain);
|
|
1607
|
+
//#endregion
|
|
1608
|
+
exports.AST_NODE_PROPS_KEYS = AST_NODE_PROPS_KEYS;
|
|
1609
|
+
exports.CORE_ERROR_CODES_EXTEND_POINT = CORE_ERROR_CODES_EXTEND_POINT;
|
|
1610
|
+
exports.CORE_WARN_CODES_EXTEND_POINT = CORE_WARN_CODES_EXTEND_POINT;
|
|
1611
|
+
exports.CoreWarnCodes = CoreWarnCodes;
|
|
1612
|
+
exports.DATETIME_FORMAT_OPTIONS_KEYS = DATETIME_FORMAT_OPTIONS_KEYS;
|
|
1613
|
+
exports.DEFAULT_LOCALE = DEFAULT_LOCALE;
|
|
1614
|
+
exports.DEFAULT_MESSAGE_DATA_TYPE = DEFAULT_MESSAGE_DATA_TYPE;
|
|
1615
|
+
exports.MISSING_RESOLVE_VALUE = MISSING_RESOLVE_VALUE;
|
|
1616
|
+
exports.NOT_RESOLVED = NOT_RESOLVED;
|
|
1617
|
+
exports.NUMBER_FORMAT_OPTIONS_KEYS = NUMBER_FORMAT_OPTIONS_KEYS;
|
|
1618
|
+
exports.VERSION = VERSION;
|
|
1619
|
+
exports.clearCompileCache = clearCompileCache;
|
|
1620
|
+
exports.clearDateTimeFormat = clearDateTimeFormat;
|
|
1621
|
+
exports.clearNumberFormat = clearNumberFormat;
|
|
1622
|
+
exports.compile = compile;
|
|
1623
|
+
exports.createCompileError = createCompileError;
|
|
1624
|
+
exports.createCoreContext = createCoreContext;
|
|
1625
|
+
exports.createCoreError = createCoreError;
|
|
1626
|
+
exports.createMessageContext = createMessageContext;
|
|
1627
|
+
exports.datetime = datetime;
|
|
1628
|
+
exports.fallbackWithLocaleChain = fallbackWithLocaleChain;
|
|
1629
|
+
exports.fallbackWithSimple = fallbackWithSimple;
|
|
1630
|
+
exports.getLocale = getLocale;
|
|
1631
|
+
exports.getLocaleMessage = getLocaleMessage;
|
|
1632
|
+
exports.getWarnMessage = getWarnMessage;
|
|
1633
|
+
exports.handleMissing = handleMissing;
|
|
1634
|
+
exports.isAlmostSameLocale = isAlmostSameLocale;
|
|
1635
|
+
exports.isImplicitFallback = isImplicitFallback;
|
|
1636
|
+
exports.isMessageAST = isMessageAST;
|
|
1637
|
+
exports.isMessageFormat = isMessageFormat;
|
|
1638
|
+
exports.isMessageFunction = isMessageFunction;
|
|
1639
|
+
exports.isTranslateFallbackWarn = isTranslateFallbackWarn;
|
|
1640
|
+
exports.isTranslateMissingWarn = isTranslateMissingWarn;
|
|
1641
|
+
exports.number = number;
|
|
1642
|
+
exports.parse = parse;
|
|
1643
|
+
exports.parseDateTimeArgs = parseDateTimeArgs;
|
|
1644
|
+
exports.parseNumberArgs = parseNumberArgs;
|
|
1645
|
+
exports.parseTranslateArgs = parseTranslateArgs;
|
|
1646
|
+
exports.registerLocaleFallbacker = registerLocaleFallbacker;
|
|
1647
|
+
exports.registerMessageCompiler = registerMessageCompiler;
|
|
1648
|
+
exports.registerMessageResolver = registerMessageResolver;
|
|
1649
|
+
exports.resolveLocale = resolveLocale;
|
|
1650
|
+
exports.resolveValue = resolveValue;
|
|
1651
|
+
exports.resolveWithKeyValue = resolveWithKeyValue;
|
|
1652
|
+
exports.setLocaleMessage = setLocaleMessage;
|
|
1653
|
+
exports.translate = translate;
|
|
1654
|
+
exports.updateFallbackLocale = updateFallbackLocale;
|
|
1655
|
+
return exports;
|
|
2124
1656
|
})({});
|