@cocoar/vue-localization 1.6.3 → 1.6.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/dist/index.js +584 -650
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,651 +1,585 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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
|
-
function
|
|
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
|
-
try {
|
|
462
|
-
const a = await fetch(this.urlBuilder(t));
|
|
463
|
-
if (a.ok) {
|
|
464
|
-
const o = await a.json();
|
|
465
|
-
e ? e = I(e, o) : e = o;
|
|
466
|
-
}
|
|
467
|
-
} catch {
|
|
468
|
-
}
|
|
469
|
-
return e;
|
|
470
|
-
}
|
|
471
|
-
}
|
|
472
|
-
class H {
|
|
473
|
-
constructor(t) {
|
|
474
|
-
this.urlBuilder = t;
|
|
475
|
-
}
|
|
476
|
-
async load(t) {
|
|
477
|
-
const n = t.includes("-") ? t.split("-")[0] : null;
|
|
478
|
-
let e = null;
|
|
479
|
-
if (n)
|
|
480
|
-
try {
|
|
481
|
-
const a = await fetch(this.urlBuilder(n));
|
|
482
|
-
a.ok && (e = await a.json());
|
|
483
|
-
} catch {
|
|
484
|
-
}
|
|
485
|
-
try {
|
|
486
|
-
const a = await fetch(this.urlBuilder(t));
|
|
487
|
-
if (a.ok) {
|
|
488
|
-
const o = await a.json();
|
|
489
|
-
e ? e = { ...e, ...o } : e = o;
|
|
490
|
-
}
|
|
491
|
-
} catch {
|
|
492
|
-
}
|
|
493
|
-
return e;
|
|
494
|
-
}
|
|
495
|
-
}
|
|
496
|
-
function D(r, t, n) {
|
|
497
|
-
const e = n ?? 2, a = Math.abs(r).toFixed(e), [o, s] = a.split(".");
|
|
498
|
-
let c = "";
|
|
499
|
-
const i = o, m = t.grouping[0] ?? 3;
|
|
500
|
-
let u = i.length;
|
|
501
|
-
for (; u > 0; ) {
|
|
502
|
-
const l = Math.max(0, u - m);
|
|
503
|
-
c = i.slice(l, u) + (c ? t.group + c : ""), u = l;
|
|
504
|
-
}
|
|
505
|
-
const h = r < 0 ? "-" : "";
|
|
506
|
-
return e > 0 && s ? `${h}${c}${t.decimal}${s}` : `${h}${c}`;
|
|
507
|
-
}
|
|
508
|
-
function K(r, t, n) {
|
|
509
|
-
const e = t.currency, a = n ?? e.default, o = e.symbols[a] ?? O(t.code, a), s = D(r, t.number, e.decimals), c = e.spacing ? " " : "";
|
|
510
|
-
return e.position === "before" ? `${o}${c}${s}` : `${s}${c}${o}`;
|
|
511
|
-
}
|
|
512
|
-
const T = /* @__PURE__ */ new Map();
|
|
513
|
-
function O(r, t) {
|
|
514
|
-
const n = `${r}:${t}`;
|
|
515
|
-
let e = T.get(n);
|
|
516
|
-
if (e != null) return e;
|
|
517
|
-
try {
|
|
518
|
-
e = new Intl.NumberFormat(r, { style: "currency", currency: t }).formatToParts(0).find((o) => o.type === "currency")?.value ?? t;
|
|
519
|
-
} catch {
|
|
520
|
-
e = t;
|
|
521
|
-
}
|
|
522
|
-
return T.set(n, e), e;
|
|
523
|
-
}
|
|
524
|
-
function Z(r, t, n) {
|
|
525
|
-
const e = t.percent, a = n ?? e.decimals, o = D(r * 100, t.number, a), s = e.spacing ? " " : "";
|
|
526
|
-
return `${o}${s}${e.symbol}`;
|
|
527
|
-
}
|
|
528
|
-
function G(r, t, n = !1) {
|
|
529
|
-
const e = typeof r == "string" ? new Date(r) : r;
|
|
530
|
-
if (isNaN(e.getTime())) return String(r);
|
|
531
|
-
const a = t.zeroPad !== !1, o = a ? String(e.getDate()).padStart(2, "0") : String(e.getDate()), s = a ? String(e.getMonth() + 1).padStart(2, "0") : String(e.getMonth() + 1), c = String(e.getFullYear());
|
|
532
|
-
let i;
|
|
533
|
-
switch (t.pattern) {
|
|
534
|
-
case "mm/dd/yyyy":
|
|
535
|
-
i = `${s}/${o}/${c}`;
|
|
536
|
-
break;
|
|
537
|
-
case "yyyy-mm-dd":
|
|
538
|
-
i = `${c}-${s}-${o}`;
|
|
539
|
-
break;
|
|
540
|
-
case "yyyy/mm/dd":
|
|
541
|
-
i = `${c}/${s}/${o}`;
|
|
542
|
-
break;
|
|
543
|
-
case "dd/mm/yyyy":
|
|
544
|
-
i = `${o}/${s}/${c}`;
|
|
545
|
-
break;
|
|
546
|
-
default:
|
|
547
|
-
i = `${o}.${s}.${c}`;
|
|
548
|
-
break;
|
|
549
|
-
}
|
|
550
|
-
if (n) {
|
|
551
|
-
const m = String(e.getHours()).padStart(2, "0"), u = String(e.getMinutes()).padStart(2, "0");
|
|
552
|
-
i += ` ${m}:${u}`;
|
|
553
|
-
}
|
|
554
|
-
return i;
|
|
555
|
-
}
|
|
556
|
-
const p = /* @__PURE__ */ Symbol("coar-localization");
|
|
557
|
-
function j(r = {}) {
|
|
558
|
-
const t = new B(r);
|
|
559
|
-
return {
|
|
560
|
-
service: t,
|
|
561
|
-
install(e) {
|
|
562
|
-
e.provide(p, t), t.setLanguage(t.getDefaultLanguage());
|
|
563
|
-
}
|
|
564
|
-
};
|
|
565
|
-
}
|
|
566
|
-
function J() {
|
|
567
|
-
return v(p, null);
|
|
568
|
-
}
|
|
569
|
-
function V() {
|
|
570
|
-
const r = v(p, null), t = r ? r.language : d(() => navigator.language || "en"), n = r ? r.localeData : d(() => {
|
|
571
|
-
});
|
|
572
|
-
return {
|
|
573
|
-
/** Current language (reactive) */
|
|
574
|
-
language: t,
|
|
575
|
-
/** Current locale data (reactive) */
|
|
576
|
-
localeData: n,
|
|
577
|
-
/** Format a number */
|
|
578
|
-
fmtNumber: (e, a) => {
|
|
579
|
-
const o = n.value;
|
|
580
|
-
return o ? D(e, o.number, a) : e.toFixed(a ?? 2);
|
|
581
|
-
},
|
|
582
|
-
/** Format a currency value */
|
|
583
|
-
fmtCurrency: (e, a) => {
|
|
584
|
-
const o = n.value;
|
|
585
|
-
return o ? K(e, o, a) : e.toFixed(2);
|
|
586
|
-
},
|
|
587
|
-
/** Format a percentage (0.25 → "25%") */
|
|
588
|
-
fmtPercent: (e, a) => {
|
|
589
|
-
const o = n.value;
|
|
590
|
-
return o ? Z(e, o, a) : `${(e * 100).toFixed(a ?? 0)}%`;
|
|
591
|
-
},
|
|
592
|
-
/** Format a date */
|
|
593
|
-
fmtDate: (e, a = !1) => {
|
|
594
|
-
const o = n.value;
|
|
595
|
-
return o ? G(e, o.date, a) : String(e);
|
|
596
|
-
}
|
|
597
|
-
};
|
|
598
|
-
}
|
|
599
|
-
function X() {
|
|
600
|
-
const r = v(p, null);
|
|
601
|
-
return {
|
|
602
|
-
/** Current language (reactive) */
|
|
603
|
-
language: r ? r.language : d(() => navigator.language || "en"),
|
|
604
|
-
/**
|
|
605
|
-
* Translate a key. Returns the key if no translation found.
|
|
606
|
-
* Reactive — updates when language changes.
|
|
607
|
-
*/
|
|
608
|
-
t: (t, n, e) => r ? r.t(t, n, e) : e ?? t,
|
|
609
|
-
/**
|
|
610
|
-
* Create a computed translation ref that reacts to language changes.
|
|
611
|
-
*/
|
|
612
|
-
tRef: (t, n, e) => r ? d(() => r.t(t, n, e)) : d(() => e ?? t)
|
|
613
|
-
};
|
|
614
|
-
}
|
|
615
|
-
function q() {
|
|
616
|
-
const r = v(p, null);
|
|
617
|
-
return {
|
|
618
|
-
/** Current timezone (reactive IANA identifier) */
|
|
619
|
-
timezone: r ? r.timezoneService.timezone : d(() => {
|
|
620
|
-
try {
|
|
621
|
-
return Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
622
|
-
} catch {
|
|
623
|
-
return "UTC";
|
|
624
|
-
}
|
|
625
|
-
}),
|
|
626
|
-
/** Re-resolve timezone from providers */
|
|
627
|
-
refresh: () => r?.timezoneService.refresh()
|
|
628
|
-
};
|
|
629
|
-
}
|
|
630
|
-
export {
|
|
631
|
-
k as BrowserTimezoneProvider,
|
|
632
|
-
p as COAR_LOCALIZATION_KEY,
|
|
633
|
-
P as CoarLocalizationDataStore,
|
|
634
|
-
B as CoarLocalizationService,
|
|
635
|
-
A as CoarTimezoneService,
|
|
636
|
-
C as CoarTranslationStore,
|
|
637
|
-
$ as IntlLocaleDataSource,
|
|
638
|
-
M as IntlTranslationSource,
|
|
639
|
-
j as createCoarLocalization,
|
|
640
|
-
K as formatCurrency,
|
|
641
|
-
G as formatDate,
|
|
642
|
-
D as formatNumber,
|
|
643
|
-
Z as formatPercent,
|
|
644
|
-
E as interpolate,
|
|
645
|
-
Y as isMissingTranslation,
|
|
646
|
-
I as mergeLocalizationData,
|
|
647
|
-
X as useI18n,
|
|
648
|
-
V as useL10n,
|
|
649
|
-
J as useLocalization,
|
|
650
|
-
q as useTimezone
|
|
1
|
+
import { computed as e, inject as t, ref as n } from "vue";
|
|
2
|
+
//#region src/l10n/localization-data-store.ts
|
|
3
|
+
var r = class {
|
|
4
|
+
data = /* @__PURE__ */ new Map();
|
|
5
|
+
_version = n(0);
|
|
6
|
+
version = this._version;
|
|
7
|
+
setLocaleData(e, t) {
|
|
8
|
+
this.data.set(e, t), this._version.value++;
|
|
9
|
+
}
|
|
10
|
+
getLocaleData(e) {
|
|
11
|
+
return this._version.value, this.data.get(e);
|
|
12
|
+
}
|
|
13
|
+
hasLocaleData(e) {
|
|
14
|
+
return this._version.value, this.data.has(e);
|
|
15
|
+
}
|
|
16
|
+
removeLocaleData(e) {
|
|
17
|
+
this.data.delete(e), this._version.value++;
|
|
18
|
+
}
|
|
19
|
+
clear() {
|
|
20
|
+
this.data.clear(), this._version.value++;
|
|
21
|
+
}
|
|
22
|
+
}, i = class {
|
|
23
|
+
async load(e) {
|
|
24
|
+
return {
|
|
25
|
+
code: e,
|
|
26
|
+
date: a(e),
|
|
27
|
+
number: u(e),
|
|
28
|
+
currency: d(e),
|
|
29
|
+
percent: f(e)
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
function a(e) {
|
|
34
|
+
let t = [], n = [], r = [], i = [], a = new Intl.DateTimeFormat(e, { month: "long" }), c = new Intl.DateTimeFormat(e, { month: "short" });
|
|
35
|
+
for (let e = 0; e < 12; e++) {
|
|
36
|
+
let r = new Date(2024, e, 1);
|
|
37
|
+
t.push(a.format(r)), n.push(c.format(r));
|
|
38
|
+
}
|
|
39
|
+
let u = new Intl.DateTimeFormat(e, { weekday: "long" }), d = new Intl.DateTimeFormat(e, { weekday: "short" });
|
|
40
|
+
for (let e = 0; e < 7; e++) {
|
|
41
|
+
let t = new Date(2024, 0, 7 + e);
|
|
42
|
+
r.push(u.format(t)), i.push(d.format(t));
|
|
43
|
+
}
|
|
44
|
+
let { pattern: f, zeroPad: p } = o(e);
|
|
45
|
+
return {
|
|
46
|
+
pattern: f,
|
|
47
|
+
firstDayOfWeek: s(e),
|
|
48
|
+
monthNames: t,
|
|
49
|
+
monthNamesShort: n,
|
|
50
|
+
dayNames: r,
|
|
51
|
+
dayNamesShort: i,
|
|
52
|
+
amPm: l(e),
|
|
53
|
+
zeroPad: p
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
function o(e) {
|
|
57
|
+
let t = new Intl.DateTimeFormat(e, {
|
|
58
|
+
year: "numeric",
|
|
59
|
+
month: "2-digit",
|
|
60
|
+
day: "2-digit"
|
|
61
|
+
}).formatToParts(new Date(2024, 11, 25)), n = t.filter((e) => e.type === "month" || e.type === "day" || e.type === "year").map((e) => e.type), r = t.find((e) => e.type === "literal")?.value ?? "/", i;
|
|
62
|
+
i = n[0] === "year" ? r === "-" ? "yyyy-mm-dd" : "yyyy/mm/dd" : n[0] === "month" ? "mm/dd/yyyy" : r === "." ? "dd.mm.yyyy" : "dd/mm/yyyy";
|
|
63
|
+
let a = new Intl.DateTimeFormat(e, {
|
|
64
|
+
year: "numeric",
|
|
65
|
+
month: "numeric",
|
|
66
|
+
day: "numeric"
|
|
67
|
+
}).formatToParts(new Date(2024, 2, 5)).find((e) => e.type === "day")?.value === "05";
|
|
68
|
+
return {
|
|
69
|
+
pattern: i,
|
|
70
|
+
zeroPad: a
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
function s(e) {
|
|
74
|
+
try {
|
|
75
|
+
let t = new Intl.Locale(e), n = t.getWeekInfo?.() ?? t.weekInfo;
|
|
76
|
+
if (n?.firstDay != null) return n.firstDay === 7 ? 0 : n.firstDay;
|
|
77
|
+
} catch {}
|
|
78
|
+
let t = c(e);
|
|
79
|
+
return +![
|
|
80
|
+
"US",
|
|
81
|
+
"CA",
|
|
82
|
+
"JP",
|
|
83
|
+
"KR",
|
|
84
|
+
"TW",
|
|
85
|
+
"PH",
|
|
86
|
+
"IL"
|
|
87
|
+
].includes(t);
|
|
88
|
+
}
|
|
89
|
+
function c(e) {
|
|
90
|
+
let t = e.split("-");
|
|
91
|
+
if (t.length > 1) return t[t.length - 1].toUpperCase();
|
|
92
|
+
try {
|
|
93
|
+
return new Intl.Locale(e).maximize().region?.toUpperCase() ?? "";
|
|
94
|
+
} catch {
|
|
95
|
+
return "";
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
function l(e) {
|
|
99
|
+
try {
|
|
100
|
+
let t = new Intl.DateTimeFormat(e, {
|
|
101
|
+
hour: "numeric",
|
|
102
|
+
hour12: !0
|
|
103
|
+
}), n = t.formatToParts(new Date(2024, 0, 1, 9)), r = t.formatToParts(new Date(2024, 0, 1, 15));
|
|
104
|
+
return [n.find((e) => e.type === "dayPeriod")?.value ?? "AM", r.find((e) => e.type === "dayPeriod")?.value ?? "PM"];
|
|
105
|
+
} catch {
|
|
106
|
+
return ["AM", "PM"];
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
function u(e) {
|
|
110
|
+
let t = new Intl.NumberFormat(e, { useGrouping: !0 }).formatToParts(1234567.89);
|
|
111
|
+
return {
|
|
112
|
+
decimal: t.find((e) => e.type === "decimal")?.value ?? ".",
|
|
113
|
+
group: t.find((e) => e.type === "group")?.value ?? ",",
|
|
114
|
+
grouping: [3]
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
function d(e) {
|
|
118
|
+
let t = p(c(e));
|
|
119
|
+
try {
|
|
120
|
+
let n = new Intl.NumberFormat(e, {
|
|
121
|
+
style: "currency",
|
|
122
|
+
currency: t
|
|
123
|
+
}).formatToParts(1234.56), r = n.find((e) => e.type === "currency")?.value ?? t, i = n.findIndex((e) => e.type === "currency"), a = n.findIndex((e) => e.type === "integer"), o = i < a ? "before" : "after", s = (o === "before" ? n.slice(i + 1, a) : n.slice(a, i)).some((e) => e.type === "literal" && /\s/.test(e.value));
|
|
124
|
+
return {
|
|
125
|
+
default: t,
|
|
126
|
+
symbols: { [t]: r },
|
|
127
|
+
position: o,
|
|
128
|
+
spacing: s,
|
|
129
|
+
decimals: 2
|
|
130
|
+
};
|
|
131
|
+
} catch {
|
|
132
|
+
return {
|
|
133
|
+
default: t,
|
|
134
|
+
symbols: {},
|
|
135
|
+
position: "before",
|
|
136
|
+
spacing: !1,
|
|
137
|
+
decimals: 2
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
function f(e) {
|
|
142
|
+
try {
|
|
143
|
+
let t = new Intl.NumberFormat(e, { style: "percent" }).formatToParts(.25), n = t.find((e) => e.type === "percentSign")?.value ?? "%", r = t.findIndex((e) => e.type === "percentSign"), i = t.findIndex((e) => e.type === "integer");
|
|
144
|
+
return {
|
|
145
|
+
symbol: n,
|
|
146
|
+
spacing: (r > i ? t.slice(i + 1, r) : t.slice(r + 1, i)).some((e) => e.type === "literal" && /\s/.test(e.value)),
|
|
147
|
+
decimals: 0
|
|
148
|
+
};
|
|
149
|
+
} catch {
|
|
150
|
+
return {
|
|
151
|
+
symbol: "%",
|
|
152
|
+
spacing: !1,
|
|
153
|
+
decimals: 0
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
function p(e) {
|
|
158
|
+
return {
|
|
159
|
+
US: "USD",
|
|
160
|
+
GB: "GBP",
|
|
161
|
+
EU: "EUR",
|
|
162
|
+
DE: "EUR",
|
|
163
|
+
FR: "EUR",
|
|
164
|
+
IT: "EUR",
|
|
165
|
+
ES: "EUR",
|
|
166
|
+
NL: "EUR",
|
|
167
|
+
AT: "EUR",
|
|
168
|
+
BE: "EUR",
|
|
169
|
+
FI: "EUR",
|
|
170
|
+
IE: "EUR",
|
|
171
|
+
PT: "EUR",
|
|
172
|
+
GR: "EUR",
|
|
173
|
+
LU: "EUR",
|
|
174
|
+
JP: "JPY",
|
|
175
|
+
CN: "CNY",
|
|
176
|
+
KR: "KRW",
|
|
177
|
+
CA: "CAD",
|
|
178
|
+
AU: "AUD",
|
|
179
|
+
CH: "CHF",
|
|
180
|
+
SE: "SEK",
|
|
181
|
+
NO: "NOK",
|
|
182
|
+
DK: "DKK",
|
|
183
|
+
PL: "PLN",
|
|
184
|
+
CZ: "CZK",
|
|
185
|
+
HU: "HUF",
|
|
186
|
+
RO: "RON",
|
|
187
|
+
BG: "BGN",
|
|
188
|
+
HR: "EUR",
|
|
189
|
+
IN: "INR",
|
|
190
|
+
BR: "BRL",
|
|
191
|
+
MX: "MXN",
|
|
192
|
+
RU: "RUB",
|
|
193
|
+
TR: "TRY",
|
|
194
|
+
ZA: "ZAR",
|
|
195
|
+
IL: "ILS",
|
|
196
|
+
TW: "TWD",
|
|
197
|
+
SG: "SGD",
|
|
198
|
+
HK: "HKD",
|
|
199
|
+
NZ: "NZD",
|
|
200
|
+
PH: "PHP",
|
|
201
|
+
TH: "THB",
|
|
202
|
+
MY: "MYR",
|
|
203
|
+
ID: "IDR",
|
|
204
|
+
VN: "VND",
|
|
205
|
+
AE: "AED",
|
|
206
|
+
SA: "SAR"
|
|
207
|
+
}[e] ?? "USD";
|
|
208
|
+
}
|
|
209
|
+
//#endregion
|
|
210
|
+
//#region src/l10n/merge-localization-data.ts
|
|
211
|
+
function m(e, t) {
|
|
212
|
+
return {
|
|
213
|
+
code: t.code ?? e.code,
|
|
214
|
+
date: t.date ? {
|
|
215
|
+
...e.date,
|
|
216
|
+
...t.date
|
|
217
|
+
} : e.date,
|
|
218
|
+
number: t.number ? {
|
|
219
|
+
...e.number,
|
|
220
|
+
...t.number
|
|
221
|
+
} : e.number,
|
|
222
|
+
currency: t.currency ? {
|
|
223
|
+
...e.currency,
|
|
224
|
+
...t.currency,
|
|
225
|
+
symbols: {
|
|
226
|
+
...e.currency.symbols,
|
|
227
|
+
...t.currency.symbols
|
|
228
|
+
}
|
|
229
|
+
} : e.currency,
|
|
230
|
+
percent: t.percent ? {
|
|
231
|
+
...e.percent,
|
|
232
|
+
...t.percent
|
|
233
|
+
} : e.percent
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
//#endregion
|
|
237
|
+
//#region src/i18n/translation-store.ts
|
|
238
|
+
var h = class {
|
|
239
|
+
data = /* @__PURE__ */ new Map();
|
|
240
|
+
_version = n(0);
|
|
241
|
+
version = this._version;
|
|
242
|
+
loadedLanguages = e(() => (this._version.value, new Set(this.data.keys())));
|
|
243
|
+
setTranslations(e, t) {
|
|
244
|
+
let n = /* @__PURE__ */ new Map();
|
|
245
|
+
g(t, "", n), this.data.set(e, n), this._version.value++;
|
|
246
|
+
}
|
|
247
|
+
updateTranslations(e, t) {
|
|
248
|
+
let n = this.data.get(e) ?? /* @__PURE__ */ new Map();
|
|
249
|
+
g(t, "", n), this.data.set(e, n), this._version.value++;
|
|
250
|
+
}
|
|
251
|
+
getTranslation(e, t) {
|
|
252
|
+
return this._version.value, this.data.get(e)?.get(t);
|
|
253
|
+
}
|
|
254
|
+
getTranslations(e) {
|
|
255
|
+
return this._version.value, this.data.get(e);
|
|
256
|
+
}
|
|
257
|
+
setTranslation(e, t, n) {
|
|
258
|
+
let r = this.data.get(e);
|
|
259
|
+
r || (r = /* @__PURE__ */ new Map(), this.data.set(e, r)), r.set(t, n), this._version.value++;
|
|
260
|
+
}
|
|
261
|
+
hasLanguage(e) {
|
|
262
|
+
return this._version.value, this.data.has(e);
|
|
263
|
+
}
|
|
264
|
+
clearLanguage(e) {
|
|
265
|
+
this.data.delete(e), this._version.value++;
|
|
266
|
+
}
|
|
267
|
+
touch() {
|
|
268
|
+
this._version.value++;
|
|
269
|
+
}
|
|
270
|
+
clear() {
|
|
271
|
+
this.data.clear(), this._version.value++;
|
|
272
|
+
}
|
|
273
|
+
};
|
|
274
|
+
function g(e, t, n) {
|
|
275
|
+
for (let [r, i] of Object.entries(e)) {
|
|
276
|
+
let e = t ? `${t}.${r}` : r;
|
|
277
|
+
typeof i == "string" ? n.set(e, i) : g(i, e, n);
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
//#endregion
|
|
281
|
+
//#region src/i18n/interpolate.ts
|
|
282
|
+
function _(e, t) {
|
|
283
|
+
return t ? e.replace(/\{(\w+)\}/g, (e, n) => {
|
|
284
|
+
let r = t[n];
|
|
285
|
+
return r == null ? "" : String(r);
|
|
286
|
+
}) : e;
|
|
287
|
+
}
|
|
288
|
+
function v(e, t) {
|
|
289
|
+
return t == null || t.trim() === "" ? !0 : e === t;
|
|
290
|
+
}
|
|
291
|
+
//#endregion
|
|
292
|
+
//#region src/i18n/intl-translation-source.ts
|
|
293
|
+
var y = class {
|
|
294
|
+
async load(e) {
|
|
295
|
+
let t = {};
|
|
296
|
+
try {
|
|
297
|
+
let n = new Intl.RelativeTimeFormat(e, { numeric: "auto" });
|
|
298
|
+
t["common.today"] = n.format(0, "day"), t["common.yesterday"] = n.format(-1, "day"), t["common.tomorrow"] = n.format(1, "day");
|
|
299
|
+
} catch {}
|
|
300
|
+
try {
|
|
301
|
+
let n = new Intl.DateTimeFormat(e, { month: "long" }), r = new Intl.DateTimeFormat(e, { month: "short" });
|
|
302
|
+
for (let e = 0; e < 12; e++) {
|
|
303
|
+
let i = new Date(2024, e, 1);
|
|
304
|
+
t[`common.month.${e + 1}`] = n.format(i), t[`common.month.short.${e + 1}`] = r.format(i);
|
|
305
|
+
}
|
|
306
|
+
} catch {}
|
|
307
|
+
try {
|
|
308
|
+
let n = new Intl.DateTimeFormat(e, { weekday: "long" }), r = new Intl.DateTimeFormat(e, { weekday: "short" });
|
|
309
|
+
for (let e = 0; e < 7; e++) {
|
|
310
|
+
let i = new Date(2024, 0, 8 + e);
|
|
311
|
+
t[`common.weekday.${e + 1}`] = n.format(i), t[`common.weekday.short.${e + 1}`] = r.format(i);
|
|
312
|
+
}
|
|
313
|
+
} catch {}
|
|
314
|
+
return t;
|
|
315
|
+
}
|
|
316
|
+
}, b = class {
|
|
317
|
+
getTimezone() {
|
|
318
|
+
try {
|
|
319
|
+
return Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
320
|
+
} catch {
|
|
321
|
+
return null;
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
}, x = class {
|
|
325
|
+
providers;
|
|
326
|
+
_timezone;
|
|
327
|
+
get timezone() {
|
|
328
|
+
return this._timezone;
|
|
329
|
+
}
|
|
330
|
+
constructor(e = []) {
|
|
331
|
+
this.providers = [...e, new b()], this._timezone = n(this.resolve());
|
|
332
|
+
}
|
|
333
|
+
refresh() {
|
|
334
|
+
this._timezone.value = this.resolve();
|
|
335
|
+
}
|
|
336
|
+
resolve() {
|
|
337
|
+
for (let e of this.providers) {
|
|
338
|
+
let t = e.getTimezone();
|
|
339
|
+
if (t) return t;
|
|
340
|
+
}
|
|
341
|
+
return "UTC";
|
|
342
|
+
}
|
|
343
|
+
}, S = class {
|
|
344
|
+
defaultLanguage;
|
|
345
|
+
_language;
|
|
346
|
+
_loading;
|
|
347
|
+
l10nStore;
|
|
348
|
+
i18nStore;
|
|
349
|
+
timezoneService;
|
|
350
|
+
l10nSources;
|
|
351
|
+
i18nSources;
|
|
352
|
+
get language() {
|
|
353
|
+
return this._language;
|
|
354
|
+
}
|
|
355
|
+
get loading() {
|
|
356
|
+
return this._loading;
|
|
357
|
+
}
|
|
358
|
+
localeData;
|
|
359
|
+
constructor(t = {}) {
|
|
360
|
+
this.defaultLanguage = t.defaultLanguage ?? "en", this._language = n(this.defaultLanguage), this._loading = n(!1), this.l10nStore = new r(), this.i18nStore = new h(), this.timezoneService = new x(t.timezoneProviders), this.l10nSources = [new i()], this.i18nSources = [new y()], t.l10nUrl && this.l10nSources.push(new C(t.l10nUrl)), t.i18nUrl && this.i18nSources.push(new w(t.i18nUrl)), this.localeData = e(() => this.l10nStore.getLocaleData(this._language.value));
|
|
361
|
+
}
|
|
362
|
+
getDefaultLanguage() {
|
|
363
|
+
return this.defaultLanguage;
|
|
364
|
+
}
|
|
365
|
+
async setLanguage(e) {
|
|
366
|
+
this._loading.value = !0;
|
|
367
|
+
try {
|
|
368
|
+
await this.loadDataForLanguage(e), this._language.value = e;
|
|
369
|
+
} finally {
|
|
370
|
+
this._loading.value = !1;
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
async preloadLanguage(e) {
|
|
374
|
+
await this.loadDataForLanguage(e);
|
|
375
|
+
}
|
|
376
|
+
async reloadLanguage(e) {
|
|
377
|
+
let t = e ?? this._language.value;
|
|
378
|
+
this._loading.value = !0;
|
|
379
|
+
try {
|
|
380
|
+
this.l10nStore.removeLocaleData(t), this.i18nStore.clearLanguage(t), await this.loadDataForLanguage(t), this.i18nStore.touch();
|
|
381
|
+
} finally {
|
|
382
|
+
this._loading.value = !1;
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
t(e, t, n) {
|
|
386
|
+
let r = this._language.value, i = this.i18nStore.getTranslation(r, e);
|
|
387
|
+
if (i === void 0 && r.includes("-")) {
|
|
388
|
+
let t = r.split("-")[0];
|
|
389
|
+
i = this.i18nStore.getTranslation(t, e);
|
|
390
|
+
}
|
|
391
|
+
return _(i ?? n ?? e, t);
|
|
392
|
+
}
|
|
393
|
+
addLocaleDataSource(e) {
|
|
394
|
+
let t = this.l10nSources.findIndex((e) => e instanceof C);
|
|
395
|
+
t >= 0 ? this.l10nSources.splice(t, 0, e) : this.l10nSources.push(e);
|
|
396
|
+
}
|
|
397
|
+
addTranslationSource(e) {
|
|
398
|
+
this.i18nSources.push(e);
|
|
399
|
+
}
|
|
400
|
+
async loadDataForLanguage(e) {
|
|
401
|
+
let t = [];
|
|
402
|
+
this.l10nStore.hasLocaleData(e) || t.push(this.loadLocaleData(e)), this.i18nStore.hasLanguage(e) || t.push(this.loadTranslations(e)), await Promise.all(t);
|
|
403
|
+
}
|
|
404
|
+
async loadLocaleData(e) {
|
|
405
|
+
let t = null;
|
|
406
|
+
for (let n of this.l10nSources) try {
|
|
407
|
+
let r = await n.load(e);
|
|
408
|
+
r && (t = t ? m(t, r) : r);
|
|
409
|
+
} catch {}
|
|
410
|
+
t && this.l10nStore.setLocaleData(e, t);
|
|
411
|
+
}
|
|
412
|
+
async loadTranslations(e) {
|
|
413
|
+
for (let t of this.i18nSources) try {
|
|
414
|
+
let n = await t.load(e);
|
|
415
|
+
n && (this.i18nStore.hasLanguage(e) ? this.i18nStore.updateTranslations(e, n) : this.i18nStore.setTranslations(e, n));
|
|
416
|
+
} catch {}
|
|
417
|
+
this.i18nStore.hasLanguage(e) || this.i18nStore.setTranslations(e, {});
|
|
418
|
+
}
|
|
419
|
+
}, C = class {
|
|
420
|
+
constructor(e) {
|
|
421
|
+
this.urlBuilder = e;
|
|
422
|
+
}
|
|
423
|
+
async load(e) {
|
|
424
|
+
let t = e.includes("-") ? e.split("-")[0] : null, n = null;
|
|
425
|
+
if (t) try {
|
|
426
|
+
let e = await fetch(this.urlBuilder(t));
|
|
427
|
+
e.ok && (n = await e.json());
|
|
428
|
+
} catch {}
|
|
429
|
+
try {
|
|
430
|
+
let t = await fetch(this.urlBuilder(e));
|
|
431
|
+
if (t.ok) {
|
|
432
|
+
let e = await t.json();
|
|
433
|
+
n = n ? m(n, e) : e;
|
|
434
|
+
}
|
|
435
|
+
} catch {}
|
|
436
|
+
return n;
|
|
437
|
+
}
|
|
438
|
+
}, w = class {
|
|
439
|
+
constructor(e) {
|
|
440
|
+
this.urlBuilder = e;
|
|
441
|
+
}
|
|
442
|
+
async load(e) {
|
|
443
|
+
let t = e.includes("-") ? e.split("-")[0] : null, n = null;
|
|
444
|
+
if (t) try {
|
|
445
|
+
let e = await fetch(this.urlBuilder(t));
|
|
446
|
+
e.ok && (n = await e.json());
|
|
447
|
+
} catch {}
|
|
448
|
+
try {
|
|
449
|
+
let t = await fetch(this.urlBuilder(e));
|
|
450
|
+
if (t.ok) {
|
|
451
|
+
let e = await t.json();
|
|
452
|
+
n = n ? {
|
|
453
|
+
...n,
|
|
454
|
+
...e
|
|
455
|
+
} : e;
|
|
456
|
+
}
|
|
457
|
+
} catch {}
|
|
458
|
+
return n;
|
|
459
|
+
}
|
|
651
460
|
};
|
|
461
|
+
//#endregion
|
|
462
|
+
//#region src/l10n/formatters.ts
|
|
463
|
+
function T(e, t, n) {
|
|
464
|
+
let r = n ?? 2, [i, a] = Math.abs(e).toFixed(r).split("."), o = "", s = i, c = t.grouping[0] ?? 3, l = s.length;
|
|
465
|
+
for (; l > 0;) {
|
|
466
|
+
let e = Math.max(0, l - c);
|
|
467
|
+
o = s.slice(e, l) + (o ? t.group + o : ""), l = e;
|
|
468
|
+
}
|
|
469
|
+
let u = e < 0 ? "-" : "";
|
|
470
|
+
return r > 0 && a ? `${u}${o}${t.decimal}${a}` : `${u}${o}`;
|
|
471
|
+
}
|
|
472
|
+
function E(e, t, n) {
|
|
473
|
+
let r = t.currency, i = n ?? r.default, a = r.symbols[i] ?? O(t.code, i), o = T(e, t.number, r.decimals), s = r.spacing ? "\xA0" : "";
|
|
474
|
+
return r.position === "before" ? `${a}${s}${o}` : `${o}${s}${a}`;
|
|
475
|
+
}
|
|
476
|
+
var D = /* @__PURE__ */ new Map();
|
|
477
|
+
function O(e, t) {
|
|
478
|
+
let n = `${e}:${t}`, r = D.get(n);
|
|
479
|
+
if (r != null) return r;
|
|
480
|
+
try {
|
|
481
|
+
r = new Intl.NumberFormat(e, {
|
|
482
|
+
style: "currency",
|
|
483
|
+
currency: t
|
|
484
|
+
}).formatToParts(0).find((e) => e.type === "currency")?.value ?? t;
|
|
485
|
+
} catch {
|
|
486
|
+
r = t;
|
|
487
|
+
}
|
|
488
|
+
return D.set(n, r), r;
|
|
489
|
+
}
|
|
490
|
+
function k(e, t, n) {
|
|
491
|
+
let r = t.percent, i = n ?? r.decimals;
|
|
492
|
+
return `${T(e * 100, t.number, i)}${r.spacing ? "\xA0" : ""}${r.symbol}`;
|
|
493
|
+
}
|
|
494
|
+
function A(e, t, n = !1) {
|
|
495
|
+
let r = typeof e == "string" ? new Date(e) : e;
|
|
496
|
+
if (isNaN(r.getTime())) return String(e);
|
|
497
|
+
let i = t.zeroPad !== !1, a = i ? String(r.getDate()).padStart(2, "0") : String(r.getDate()), o = i ? String(r.getMonth() + 1).padStart(2, "0") : String(r.getMonth() + 1), s = String(r.getFullYear()), c;
|
|
498
|
+
switch (t.pattern) {
|
|
499
|
+
case "mm/dd/yyyy":
|
|
500
|
+
c = `${o}/${a}/${s}`;
|
|
501
|
+
break;
|
|
502
|
+
case "yyyy-mm-dd":
|
|
503
|
+
c = `${s}-${o}-${a}`;
|
|
504
|
+
break;
|
|
505
|
+
case "yyyy/mm/dd":
|
|
506
|
+
c = `${s}/${o}/${a}`;
|
|
507
|
+
break;
|
|
508
|
+
case "dd/mm/yyyy":
|
|
509
|
+
c = `${a}/${o}/${s}`;
|
|
510
|
+
break;
|
|
511
|
+
default:
|
|
512
|
+
c = `${a}.${o}.${s}`;
|
|
513
|
+
break;
|
|
514
|
+
}
|
|
515
|
+
if (n) {
|
|
516
|
+
let e = String(r.getHours()).padStart(2, "0"), t = String(r.getMinutes()).padStart(2, "0");
|
|
517
|
+
c += ` ${e}:${t}`;
|
|
518
|
+
}
|
|
519
|
+
return c;
|
|
520
|
+
}
|
|
521
|
+
//#endregion
|
|
522
|
+
//#region src/injection-keys.ts
|
|
523
|
+
var j = Symbol("coar-localization");
|
|
524
|
+
//#endregion
|
|
525
|
+
//#region src/plugin.ts
|
|
526
|
+
function M(e = {}) {
|
|
527
|
+
let t = new S(e);
|
|
528
|
+
return {
|
|
529
|
+
service: t,
|
|
530
|
+
install(e) {
|
|
531
|
+
e.provide(j, t), t.setLanguage(t.getDefaultLanguage());
|
|
532
|
+
}
|
|
533
|
+
};
|
|
534
|
+
}
|
|
535
|
+
//#endregion
|
|
536
|
+
//#region src/composables.ts
|
|
537
|
+
function N() {
|
|
538
|
+
return t(j, null);
|
|
539
|
+
}
|
|
540
|
+
function P() {
|
|
541
|
+
let n = t(j, null), r = n ? n.language : e(() => navigator.language || "en"), i = n ? n.localeData : e(() => void 0);
|
|
542
|
+
return {
|
|
543
|
+
language: r,
|
|
544
|
+
localeData: i,
|
|
545
|
+
fmtNumber: (e, t) => {
|
|
546
|
+
let n = i.value;
|
|
547
|
+
return n ? T(e, n.number, t) : e.toFixed(t ?? 2);
|
|
548
|
+
},
|
|
549
|
+
fmtCurrency: (e, t) => {
|
|
550
|
+
let n = i.value;
|
|
551
|
+
return n ? E(e, n, t) : e.toFixed(2);
|
|
552
|
+
},
|
|
553
|
+
fmtPercent: (e, t) => {
|
|
554
|
+
let n = i.value;
|
|
555
|
+
return n ? k(e, n, t) : `${(e * 100).toFixed(t ?? 0)}%`;
|
|
556
|
+
},
|
|
557
|
+
fmtDate: (e, t = !1) => {
|
|
558
|
+
let n = i.value;
|
|
559
|
+
return n ? A(e, n.date, t) : String(e);
|
|
560
|
+
}
|
|
561
|
+
};
|
|
562
|
+
}
|
|
563
|
+
function F() {
|
|
564
|
+
let n = t(j, null);
|
|
565
|
+
return {
|
|
566
|
+
language: n ? n.language : e(() => navigator.language || "en"),
|
|
567
|
+
t: (e, t, r) => n ? n.t(e, t, r) : r ?? e,
|
|
568
|
+
tRef: (t, r, i) => e(n ? () => n.t(t, r, i) : () => i ?? t)
|
|
569
|
+
};
|
|
570
|
+
}
|
|
571
|
+
function I() {
|
|
572
|
+
let n = t(j, null);
|
|
573
|
+
return {
|
|
574
|
+
timezone: n ? n.timezoneService.timezone : e(() => {
|
|
575
|
+
try {
|
|
576
|
+
return Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
577
|
+
} catch {
|
|
578
|
+
return "UTC";
|
|
579
|
+
}
|
|
580
|
+
}),
|
|
581
|
+
refresh: () => n?.timezoneService.refresh()
|
|
582
|
+
};
|
|
583
|
+
}
|
|
584
|
+
//#endregion
|
|
585
|
+
export { b as BrowserTimezoneProvider, j as COAR_LOCALIZATION_KEY, r as CoarLocalizationDataStore, S as CoarLocalizationService, x as CoarTimezoneService, h as CoarTranslationStore, i as IntlLocaleDataSource, y as IntlTranslationSource, M as createCoarLocalization, E as formatCurrency, A as formatDate, T as formatNumber, k as formatPercent, _ as interpolate, v as isMissingTranslation, m as mergeLocalizationData, F as useI18n, P as useL10n, N as useLocalization, I as useTimezone };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cocoar/vue-localization",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.5",
|
|
4
4
|
"description": "Locale-aware formatting (l10n), translations (i18n), and timezone detection for Vue 3",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -42,6 +42,6 @@
|
|
|
42
42
|
"vue": "^3.5.0"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"vue": "^3.5.
|
|
45
|
+
"vue": "^3.5.32"
|
|
46
46
|
}
|
|
47
47
|
}
|