@i18n-micro/vue 1.3.12 → 1.4.4
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.cjs +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +346 -330
- package/dist/index.d.ts +346 -330
- package/dist/index.mjs +674 -777
- package/dist/index.mjs.map +1 -1
- package/dist/router.cjs +2 -0
- package/dist/router.cjs.map +1 -0
- package/dist/router.d.cts +79 -0
- package/dist/router.d.ts +79 -0
- package/dist/router.mjs +29 -0
- package/dist/router.mjs.map +1 -0
- package/package.json +21 -10
package/dist/index.mjs
CHANGED
|
@@ -1,786 +1,683 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { BaseI18n as
|
|
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
|
-
|
|
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
|
-
customPluralRule: {
|
|
375
|
-
type: Function,
|
|
376
|
-
default: null
|
|
377
|
-
},
|
|
378
|
-
number: {
|
|
379
|
-
type: [Number, String]
|
|
380
|
-
},
|
|
381
|
-
date: {
|
|
382
|
-
type: [Date, String, Number]
|
|
383
|
-
},
|
|
384
|
-
relativeDate: {
|
|
385
|
-
type: [Date, String, Number]
|
|
386
|
-
}
|
|
387
|
-
},
|
|
388
|
-
setup(t, { slots: e, attrs: a }) {
|
|
389
|
-
const o = S(W);
|
|
390
|
-
if (!o)
|
|
391
|
-
throw new Error("[i18n-micro] I18nT: i18n instance not found. Make sure i18n plugin is installed.");
|
|
392
|
-
return () => {
|
|
393
|
-
const c = {}, r = o.getRoute();
|
|
394
|
-
if (t.number !== void 0) {
|
|
395
|
-
const n = Number(t.number), l = o.tn(n), m = o.t(t.keypath, { number: l, ...t.params }, void 0, r);
|
|
396
|
-
return g(t.tag, { ...a, innerHTML: m });
|
|
397
|
-
}
|
|
398
|
-
if (t.date !== void 0) {
|
|
399
|
-
const n = o.td(t.date), l = o.t(t.keypath, { date: n, ...t.params }, void 0, r);
|
|
400
|
-
return g(t.tag, { ...a, innerHTML: l });
|
|
401
|
-
}
|
|
402
|
-
if (t.relativeDate !== void 0) {
|
|
403
|
-
const n = o.tdr(t.relativeDate), l = o.t(t.keypath, { relativeDate: n, ...t.params }, void 0, r);
|
|
404
|
-
return g(t.tag, { ...a, innerHTML: l });
|
|
405
|
-
}
|
|
406
|
-
if (t.plural !== void 0) {
|
|
407
|
-
const n = Number.parseInt(t.plural.toString(), 10);
|
|
408
|
-
if (t.customPluralRule) {
|
|
409
|
-
const l = t.customPluralRule(
|
|
410
|
-
t.keypath,
|
|
411
|
-
n,
|
|
412
|
-
t.params,
|
|
413
|
-
o.locale.value,
|
|
414
|
-
(m, v, L) => o.t(m, v, L, r)
|
|
415
|
-
);
|
|
416
|
-
return g(t.tag, { ...a, innerHTML: l || "" });
|
|
417
|
-
} else {
|
|
418
|
-
const l = o.tc(t.keypath, { count: n, ...t.params });
|
|
419
|
-
return g(t.tag, { ...a, innerHTML: l });
|
|
420
|
-
}
|
|
421
|
-
}
|
|
422
|
-
const s = (o.t(t.keypath, { ...t.params, ...c }, void 0, r) ?? "").toString();
|
|
423
|
-
if (t.hideIfEmpty && !s.trim())
|
|
424
|
-
return t.defaultValue ?? null;
|
|
425
|
-
if (t.html)
|
|
426
|
-
return g(t.tag, { ...a, innerHTML: s });
|
|
427
|
-
if (e.default)
|
|
428
|
-
return g(t.tag, a, e.default({ translation: s }));
|
|
429
|
-
const f = [];
|
|
430
|
-
let i = 0;
|
|
431
|
-
for (const [n, l] of Object.entries(e)) {
|
|
432
|
-
if (n === "default") continue;
|
|
433
|
-
const m = `{${n}}`, v = s.indexOf(m, i);
|
|
434
|
-
v !== -1 && (v > i && f.push(s.slice(i, v)), l && f.push(g(l)), i = v + m.length);
|
|
435
|
-
}
|
|
436
|
-
return i < s.length && f.push(s.slice(i)), e.default ? g(t.tag, a, e.default({ children: f })) : f.length > 0 ? g(t.tag, a, f) : g(t.tag, a, s);
|
|
437
|
-
};
|
|
438
|
-
}
|
|
1
|
+
import { computed as e, defineComponent as t, h as n, inject as r, nextTick as i, onMounted as a, onUnmounted as o, ref as s, shallowRef as c } from "vue";
|
|
2
|
+
import { BaseI18n as l, FormatService as u, defaultPlural as d, interpolate as f } from "@i18n-micro/core";
|
|
3
|
+
//#region src/injection.ts
|
|
4
|
+
var p = Symbol("i18n"), m = Symbol("i18n-locales"), h = Symbol("i18n-default-locale"), g = Symbol("i18n-router-strategy"), _ = t({
|
|
5
|
+
name: "I18nGroup",
|
|
6
|
+
props: {
|
|
7
|
+
prefix: {
|
|
8
|
+
type: String,
|
|
9
|
+
required: !0
|
|
10
|
+
},
|
|
11
|
+
groupClass: {
|
|
12
|
+
type: String,
|
|
13
|
+
default: ""
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
setup(e, { slots: t }) {
|
|
17
|
+
let i = r(p);
|
|
18
|
+
if (!i) throw Error("[i18n-micro] I18nGroup: i18n instance not found. Make sure i18n plugin is installed.");
|
|
19
|
+
let a = (t, n) => i.t(`${e.prefix}.${t}`, n, void 0, i.getRoute());
|
|
20
|
+
return () => n("div", { class: ["i18n-group", e.groupClass] }, t.default?.({
|
|
21
|
+
prefix: e.prefix,
|
|
22
|
+
t: a
|
|
23
|
+
}));
|
|
24
|
+
}
|
|
25
|
+
}), v = t({
|
|
26
|
+
name: "I18nLink",
|
|
27
|
+
props: {
|
|
28
|
+
to: {
|
|
29
|
+
type: [String, Object],
|
|
30
|
+
required: !0
|
|
31
|
+
},
|
|
32
|
+
activeStyle: {
|
|
33
|
+
type: Object,
|
|
34
|
+
default: () => ({})
|
|
35
|
+
},
|
|
36
|
+
localeRoute: {
|
|
37
|
+
type: Function,
|
|
38
|
+
default: void 0
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
setup(t, { slots: i }) {
|
|
42
|
+
let a = r(p), o = r(g, void 0);
|
|
43
|
+
if (!a) throw Error("[i18n-micro] I18nLink: i18n instance not found. Make sure i18n plugin is installed.");
|
|
44
|
+
let s = e(() => typeof t.to == "string" && /^(?:https?:\/\/|\/\/|[a-zA-Z0-9-]+\.[a-zA-Z]{2,})|tel:|mailto:/.test(t.to)), c = e(() => {
|
|
45
|
+
if (s.value) return t.to;
|
|
46
|
+
if (t.localeRoute) {
|
|
47
|
+
let e = t.localeRoute(t.to);
|
|
48
|
+
return typeof e == "string" ? e : e.path || "/";
|
|
49
|
+
}
|
|
50
|
+
if (!o?.resolvePath) return typeof t.to == "string" ? t.to : t.to.path || "/";
|
|
51
|
+
let e = o.resolvePath(t.to, a.locale.value);
|
|
52
|
+
return typeof e == "string" ? e : e.path || "/";
|
|
53
|
+
}), l = e(() => s.value || !o ? !1 : o.getCurrentPath().replace(/#.*$/, "").replace(/\/$/, "") === c.value.replace(/#.*$/, "").replace(/\/$/, "")), u = e(() => l.value ? t.activeStyle : {});
|
|
54
|
+
return () => s.value ? n("a", {
|
|
55
|
+
href: c.value,
|
|
56
|
+
target: "_blank",
|
|
57
|
+
rel: "noopener noreferrer",
|
|
58
|
+
style: u.value
|
|
59
|
+
}, i.default?.()) : o?.linkComponent ? n(o.linkComponent, {
|
|
60
|
+
to: c.value,
|
|
61
|
+
style: u.value
|
|
62
|
+
}, { default: i.default }) : n("a", {
|
|
63
|
+
href: c.value,
|
|
64
|
+
style: u.value,
|
|
65
|
+
onClick: (e) => {
|
|
66
|
+
e.preventDefault(), o ? o.push({ path: c.value }) : window.location.href = c.value;
|
|
67
|
+
}
|
|
68
|
+
}, i.default?.());
|
|
69
|
+
}
|
|
70
|
+
}), y = t({
|
|
71
|
+
name: "I18nSwitcher",
|
|
72
|
+
props: {
|
|
73
|
+
customLabels: {
|
|
74
|
+
type: Object,
|
|
75
|
+
default: () => ({})
|
|
76
|
+
},
|
|
77
|
+
customWrapperStyle: {
|
|
78
|
+
type: Object,
|
|
79
|
+
default: () => ({})
|
|
80
|
+
},
|
|
81
|
+
customButtonStyle: {
|
|
82
|
+
type: Object,
|
|
83
|
+
default: () => ({})
|
|
84
|
+
},
|
|
85
|
+
customDropdownStyle: {
|
|
86
|
+
type: Object,
|
|
87
|
+
default: () => ({})
|
|
88
|
+
},
|
|
89
|
+
customItemStyle: {
|
|
90
|
+
type: Object,
|
|
91
|
+
default: () => ({})
|
|
92
|
+
},
|
|
93
|
+
customLinkStyle: {
|
|
94
|
+
type: Object,
|
|
95
|
+
default: () => ({})
|
|
96
|
+
},
|
|
97
|
+
customActiveLinkStyle: {
|
|
98
|
+
type: Object,
|
|
99
|
+
default: () => ({})
|
|
100
|
+
},
|
|
101
|
+
customDisabledLinkStyle: {
|
|
102
|
+
type: Object,
|
|
103
|
+
default: () => ({})
|
|
104
|
+
},
|
|
105
|
+
customIconStyle: {
|
|
106
|
+
type: Object,
|
|
107
|
+
default: () => ({})
|
|
108
|
+
},
|
|
109
|
+
locales: {
|
|
110
|
+
type: Array,
|
|
111
|
+
default: void 0
|
|
112
|
+
},
|
|
113
|
+
currentLocale: {
|
|
114
|
+
type: [String, Function],
|
|
115
|
+
default: void 0
|
|
116
|
+
},
|
|
117
|
+
getLocaleName: {
|
|
118
|
+
type: Function,
|
|
119
|
+
default: void 0
|
|
120
|
+
},
|
|
121
|
+
switchLocale: {
|
|
122
|
+
type: Function,
|
|
123
|
+
default: void 0
|
|
124
|
+
},
|
|
125
|
+
localeRoute: {
|
|
126
|
+
type: Function,
|
|
127
|
+
default: void 0
|
|
128
|
+
}
|
|
129
|
+
},
|
|
130
|
+
setup(t, { slots: c }) {
|
|
131
|
+
let l = r(p), u = r(g, void 0), d = r(m, void 0);
|
|
132
|
+
if (!l) throw Error("[i18n-micro] I18nSwitcher: i18n instance not found. Make sure i18n plugin is installed.");
|
|
133
|
+
if (!d && !t.locales) throw Error("[i18n-micro] I18nSwitcher: locales not provided. Make sure app.provide(I18nLocalesKey, locales) is called or pass locales prop.");
|
|
134
|
+
let f = e(() => t.locales || d || []), h = e(() => f.value.filter((e) => !e.disabled)), _ = e(() => t.currentLocale === void 0 ? l.locale.value : typeof t.currentLocale == "function" ? t.currentLocale() : t.currentLocale), v = e(() => f.value.some((e) => e.code === _.value && e.disabled)), y = e(() => t.getLocaleName ? t.getLocaleName() || null : f.value.find((e) => e.code === l.locale.value)?.displayName || null), b = s(!1), x = s(null), S = (e) => {
|
|
135
|
+
e && (e.stopPropagation(), e.preventDefault()), b.value = !b.value;
|
|
136
|
+
}, C = (e) => t.customLabels[e.code] || e.displayName || e.code, w = e(() => {
|
|
137
|
+
let e = f.value.find((e) => e.code === _.value);
|
|
138
|
+
return e ? C(e) : y.value || _.value;
|
|
139
|
+
}), T = async (e) => {
|
|
140
|
+
if (b.value = !1, await i(), t.switchLocale) {
|
|
141
|
+
t.switchLocale(e);
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
if (l.locale.value = e, !u) return;
|
|
145
|
+
let n = u.getCurrentPath(), r = t.localeRoute ? (() => {
|
|
146
|
+
let r = t.localeRoute(n, e);
|
|
147
|
+
return typeof r == "string" ? r : r.path || "/";
|
|
148
|
+
})() : u?.resolvePath ? (() => {
|
|
149
|
+
let t = u.resolvePath(n, e);
|
|
150
|
+
return typeof t == "string" ? t : t.path || "/";
|
|
151
|
+
})() : n;
|
|
152
|
+
u.push({ path: r });
|
|
153
|
+
}, E = {
|
|
154
|
+
position: "relative",
|
|
155
|
+
display: "inline-block",
|
|
156
|
+
verticalAlign: "middle"
|
|
157
|
+
}, D = {
|
|
158
|
+
padding: "4px 12px",
|
|
159
|
+
fontSize: "16px",
|
|
160
|
+
cursor: "pointer",
|
|
161
|
+
backgroundColor: "#fff",
|
|
162
|
+
border: "1px solid #333",
|
|
163
|
+
transition: "background-color 0.3s ease",
|
|
164
|
+
display: "flex",
|
|
165
|
+
alignItems: "center",
|
|
166
|
+
justifyContent: "space-between"
|
|
167
|
+
}, O = {
|
|
168
|
+
position: "absolute",
|
|
169
|
+
top: "100%",
|
|
170
|
+
left: "0",
|
|
171
|
+
zIndex: 1e3,
|
|
172
|
+
backgroundColor: "#fff",
|
|
173
|
+
border: "1px solid #333",
|
|
174
|
+
listStyle: "none",
|
|
175
|
+
padding: "0",
|
|
176
|
+
margin: "4px 0 0 0",
|
|
177
|
+
minWidth: "150px",
|
|
178
|
+
boxShadow: "0 2px 8px rgba(0,0,0,0.15)"
|
|
179
|
+
}, k = {
|
|
180
|
+
margin: "0",
|
|
181
|
+
padding: "0"
|
|
182
|
+
}, A = {
|
|
183
|
+
display: "block",
|
|
184
|
+
padding: "8px 12px",
|
|
185
|
+
color: "#333",
|
|
186
|
+
textDecoration: "none",
|
|
187
|
+
transition: "background-color 0.3s ease",
|
|
188
|
+
cursor: "pointer"
|
|
189
|
+
}, j = {
|
|
190
|
+
fontWeight: "bold",
|
|
191
|
+
color: "#007bff",
|
|
192
|
+
cursor: "not-allowed"
|
|
193
|
+
}, M = {
|
|
194
|
+
marginLeft: "8px",
|
|
195
|
+
display: "inline-block",
|
|
196
|
+
transition: "transform 0.3s ease"
|
|
197
|
+
}, N = { transform: "rotate(180deg)" }, P = (e) => e ? Array.isArray(e) ? e : [e] : [], F = (e) => {
|
|
198
|
+
if (!b.value) return;
|
|
199
|
+
let t = e.target;
|
|
200
|
+
if (!t || !x.value) return;
|
|
201
|
+
let n = x.value.contains(t), r = t.closest(".i18n-switcher-button") !== null;
|
|
202
|
+
!n && !r && (b.value = !1);
|
|
203
|
+
};
|
|
204
|
+
return a(() => {
|
|
205
|
+
document.addEventListener("click", F);
|
|
206
|
+
}), o(() => {
|
|
207
|
+
document.removeEventListener("click", F);
|
|
208
|
+
}), () => {
|
|
209
|
+
let e = [];
|
|
210
|
+
c["before-button"] && e.push(...P(c["before-button"]()));
|
|
211
|
+
let r = [];
|
|
212
|
+
if (c["before-selected-locale"] && r.push(...P(c["before-selected-locale"]())), r.push(n("span", w.value)), c["after-selected-locale"] && r.push(...P(c["after-selected-locale"]())), r.push(n("span", { style: {
|
|
213
|
+
...M,
|
|
214
|
+
...b.value ? N : {},
|
|
215
|
+
...t.customIconStyle
|
|
216
|
+
} }, "▼")), e.push(n("button", {
|
|
217
|
+
class: "i18n-switcher-button",
|
|
218
|
+
style: {
|
|
219
|
+
...D,
|
|
220
|
+
...t.customButtonStyle,
|
|
221
|
+
...v.value ? t.customDisabledLinkStyle : {}
|
|
222
|
+
},
|
|
223
|
+
onClick: (e) => {
|
|
224
|
+
e.preventDefault(), e.stopPropagation(), S(e);
|
|
225
|
+
},
|
|
226
|
+
type: "button",
|
|
227
|
+
ariaHaspopup: !0,
|
|
228
|
+
ariaExpanded: b.value
|
|
229
|
+
}, r)), c["before-dropdown"] && e.push(...P(c["before-dropdown"]())), b.value) {
|
|
230
|
+
let r = [];
|
|
231
|
+
c["before-dropdown-items"] && r.push(...P(c["before-dropdown-items"]())), h.value.forEach((e) => {
|
|
232
|
+
let i = [];
|
|
233
|
+
c["before-item"] && i.push(...P(c["before-item"]({ locale: e })));
|
|
234
|
+
let a = [];
|
|
235
|
+
c["before-link-content"] && a.push(...P(c["before-link-content"]({ locale: e }))), a.push(C(e)), c["after-link-content"] && a.push(...P(c["after-link-content"]({ locale: e })));
|
|
236
|
+
let o = typeof window < "u" ? window.location.pathname : "/", s = t.localeRoute ? t.localeRoute(o, e.code) : u?.resolvePath ? u.resolvePath(o, e.code) : o, l = typeof s == "string" ? s : s.path || "#", d = e.code === _.value;
|
|
237
|
+
i.push(n("a", {
|
|
238
|
+
class: `switcher-locale-${e.code}`,
|
|
239
|
+
href: typeof l == "string" ? l : "#",
|
|
240
|
+
style: {
|
|
241
|
+
...A,
|
|
242
|
+
...d ? j : {},
|
|
243
|
+
...t.customLinkStyle,
|
|
244
|
+
...d ? t.customActiveLinkStyle : {}
|
|
245
|
+
},
|
|
246
|
+
onClick: (t) => {
|
|
247
|
+
t.preventDefault(), t.stopPropagation(), T(e.code);
|
|
248
|
+
}
|
|
249
|
+
}, a)), c["after-item"] && i.push(...P(c["after-item"]({ locale: e }))), r.push(n("li", {
|
|
250
|
+
key: e.code,
|
|
251
|
+
style: {
|
|
252
|
+
...k,
|
|
253
|
+
...t.customItemStyle
|
|
254
|
+
}
|
|
255
|
+
}, i));
|
|
256
|
+
}), c["after-dropdown-items"] && r.push(...P(c["after-dropdown-items"]())), e.push(n("ul", {
|
|
257
|
+
class: "i18n-switcher-dropdown",
|
|
258
|
+
style: {
|
|
259
|
+
...O,
|
|
260
|
+
...t.customDropdownStyle
|
|
261
|
+
}
|
|
262
|
+
}, r));
|
|
263
|
+
}
|
|
264
|
+
return c["after-dropdown"] && e.push(...P(c["after-dropdown"]())), n("div", {
|
|
265
|
+
ref: x,
|
|
266
|
+
class: "i18n-switcher-wrapper",
|
|
267
|
+
style: {
|
|
268
|
+
...E,
|
|
269
|
+
...t.customWrapperStyle
|
|
270
|
+
}
|
|
271
|
+
}, e);
|
|
272
|
+
};
|
|
273
|
+
}
|
|
274
|
+
}), b = t({
|
|
275
|
+
name: "I18nT",
|
|
276
|
+
inheritAttrs: !1,
|
|
277
|
+
props: {
|
|
278
|
+
keypath: {
|
|
279
|
+
type: String,
|
|
280
|
+
required: !0
|
|
281
|
+
},
|
|
282
|
+
plural: { type: [Number, String] },
|
|
283
|
+
tag: {
|
|
284
|
+
type: String,
|
|
285
|
+
default: "span"
|
|
286
|
+
},
|
|
287
|
+
params: {
|
|
288
|
+
type: Object,
|
|
289
|
+
default: () => ({})
|
|
290
|
+
},
|
|
291
|
+
defaultValue: {
|
|
292
|
+
type: String,
|
|
293
|
+
default: ""
|
|
294
|
+
},
|
|
295
|
+
html: {
|
|
296
|
+
type: Boolean,
|
|
297
|
+
default: !1
|
|
298
|
+
},
|
|
299
|
+
hideIfEmpty: {
|
|
300
|
+
type: Boolean,
|
|
301
|
+
default: !1
|
|
302
|
+
},
|
|
303
|
+
customPluralRule: {
|
|
304
|
+
type: Function,
|
|
305
|
+
default: null
|
|
306
|
+
},
|
|
307
|
+
number: { type: [Number, String] },
|
|
308
|
+
date: { type: [
|
|
309
|
+
Date,
|
|
310
|
+
String,
|
|
311
|
+
Number
|
|
312
|
+
] },
|
|
313
|
+
relativeDate: { type: [
|
|
314
|
+
Date,
|
|
315
|
+
String,
|
|
316
|
+
Number
|
|
317
|
+
] }
|
|
318
|
+
},
|
|
319
|
+
setup(e, { slots: t, attrs: i }) {
|
|
320
|
+
let a = r(p);
|
|
321
|
+
if (!a) throw Error("[i18n-micro] I18nT: i18n instance not found. Make sure i18n plugin is installed.");
|
|
322
|
+
return () => {
|
|
323
|
+
let r = {}, o = a.getRoute(), s = { ...i };
|
|
324
|
+
delete s.innerHTML;
|
|
325
|
+
let c = (t) => e.html ? n(e.tag, {
|
|
326
|
+
...s,
|
|
327
|
+
innerHTML: t
|
|
328
|
+
}) : n(e.tag, s, t);
|
|
329
|
+
if (e.number !== void 0) {
|
|
330
|
+
let t = Number(e.number), n = a.tn(t), r = a.t(e.keypath, {
|
|
331
|
+
number: n,
|
|
332
|
+
...e.params
|
|
333
|
+
}, void 0, o);
|
|
334
|
+
return c(String(r ?? ""));
|
|
335
|
+
}
|
|
336
|
+
if (e.date !== void 0) {
|
|
337
|
+
let t = a.td(e.date), n = a.t(e.keypath, {
|
|
338
|
+
date: t,
|
|
339
|
+
...e.params
|
|
340
|
+
}, void 0, o);
|
|
341
|
+
return c(String(n ?? ""));
|
|
342
|
+
}
|
|
343
|
+
if (e.relativeDate !== void 0) {
|
|
344
|
+
let t = a.tdr(e.relativeDate), n = a.t(e.keypath, {
|
|
345
|
+
relativeDate: t,
|
|
346
|
+
...e.params
|
|
347
|
+
}, void 0, o);
|
|
348
|
+
return c(String(n ?? ""));
|
|
349
|
+
}
|
|
350
|
+
if (e.plural !== void 0) {
|
|
351
|
+
let t = Number.parseInt(e.plural.toString(), 10);
|
|
352
|
+
return e.customPluralRule ? c(e.customPluralRule(e.keypath, t, e.params, a.locale.value, (e, t, n) => a.t(e, t, n, o)) || "") : c(a.tc(e.keypath, {
|
|
353
|
+
count: t,
|
|
354
|
+
...e.params
|
|
355
|
+
}));
|
|
356
|
+
}
|
|
357
|
+
let l = (a.t(e.keypath, {
|
|
358
|
+
...e.params,
|
|
359
|
+
...r
|
|
360
|
+
}, void 0, o) ?? "").toString();
|
|
361
|
+
if (e.hideIfEmpty && !l.trim()) return e.defaultValue ?? null;
|
|
362
|
+
if (e.html) return c(l);
|
|
363
|
+
if (t.default) return n(e.tag, s, t.default({ translation: l }));
|
|
364
|
+
let u = [], d = 0;
|
|
365
|
+
for (let [e, r] of Object.entries(t)) {
|
|
366
|
+
if (e === "default") continue;
|
|
367
|
+
let t = `{${e}}`, i = l.indexOf(t, d);
|
|
368
|
+
i !== -1 && (i > d && u.push(l.slice(d, i)), r && u.push(n(r)), d = i + t.length);
|
|
369
|
+
}
|
|
370
|
+
return d < l.length && u.push(l.slice(d)), t.default ? n(e.tag, s, t.default({ children: u })) : u.length > 0 ? n(e.tag, s, u) : n(e.tag, s, l);
|
|
371
|
+
};
|
|
372
|
+
}
|
|
439
373
|
});
|
|
440
|
-
|
|
441
|
-
|
|
374
|
+
//#endregion
|
|
375
|
+
//#region ../utils/dist/resolve-hreflang.mjs
|
|
376
|
+
function x(e) {
|
|
377
|
+
return e.iso?.trim() || String(e.code);
|
|
442
378
|
}
|
|
443
|
-
function
|
|
444
|
-
|
|
445
|
-
|
|
379
|
+
function S(e) {
|
|
380
|
+
let t = e.match(/^([A-Za-z]{2,3})(?:[-_](.+))?$/);
|
|
381
|
+
return t ? {
|
|
382
|
+
language: t[1],
|
|
383
|
+
region: t[2]
|
|
384
|
+
} : { language: e };
|
|
446
385
|
}
|
|
447
|
-
function
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
386
|
+
function C(e, t = {}) {
|
|
387
|
+
let { hreflangBaseLanguage: n = !1 } = t;
|
|
388
|
+
if (!n) return e.map((e) => {
|
|
389
|
+
let t = String(e.code);
|
|
390
|
+
return {
|
|
391
|
+
hreflang: x(e),
|
|
392
|
+
localeCode: t
|
|
393
|
+
};
|
|
394
|
+
});
|
|
395
|
+
let r = /* @__PURE__ */ new Map();
|
|
396
|
+
for (let t of e) {
|
|
397
|
+
let e = String(t.code), n = x(t), { language: i, region: a } = S(n);
|
|
398
|
+
i && a && !r.has(i) && r.set(i, e), r.set(n, e);
|
|
399
|
+
}
|
|
400
|
+
let i = /* @__PURE__ */ new Set(), a = [];
|
|
401
|
+
for (let t of e) {
|
|
402
|
+
let e = String(t.code), n = x(t), { language: o, region: s } = S(n);
|
|
403
|
+
o && s && r.get(o) === e && !i.has(o) && (i.add(o), a.push({
|
|
404
|
+
hreflang: o,
|
|
405
|
+
localeCode: e
|
|
406
|
+
})), i.has(n) || (i.add(n), a.push({
|
|
407
|
+
hreflang: n,
|
|
408
|
+
localeCode: e
|
|
409
|
+
}));
|
|
410
|
+
}
|
|
411
|
+
return a;
|
|
465
412
|
}
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
413
|
+
//#endregion
|
|
414
|
+
//#region ../utils/dist/resolve-og-locale.mjs
|
|
415
|
+
function w(e) {
|
|
416
|
+
let t = e.og?.trim();
|
|
417
|
+
if (t) return t;
|
|
418
|
+
let n = e.iso?.trim();
|
|
419
|
+
if (!n) return null;
|
|
420
|
+
let r = n.indexOf("_");
|
|
421
|
+
if (r > 0) {
|
|
422
|
+
let e = n.slice(0, r), t = n.slice(r + 1);
|
|
423
|
+
if (e.length >= 2 && t.length === 2) return `${e.toLowerCase()}_${t.toUpperCase()}`;
|
|
424
|
+
}
|
|
425
|
+
let i = n.indexOf("-");
|
|
426
|
+
if (i > 0) {
|
|
427
|
+
let e = n.slice(0, i), t = n.slice(i + 1);
|
|
428
|
+
if (e.length >= 2 && t.length === 2 && /^[A-Za-z]{2}$/.test(t)) return `${e.toLowerCase()}_${t.toUpperCase()}`;
|
|
429
|
+
}
|
|
430
|
+
return null;
|
|
484
431
|
}
|
|
485
|
-
function
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
`[i18n] Cannot derive ${a} for locale '${o}'${c}. Set locale.og (e.g. 'en_US') or use iso with a 2-letter region (e.g. 'en-US').`
|
|
490
|
-
);
|
|
432
|
+
function T(e, t = {}) {
|
|
433
|
+
if (w(e) !== null || t.missingWarn === !1 || process.env.NODE_ENV === "production") return;
|
|
434
|
+
let n = t.tag ?? "og:locale", r = String(e.code ?? "unknown"), i = e.iso ? `, iso: '${e.iso}'` : "";
|
|
435
|
+
console.warn(`[i18n] Cannot derive ${n} for locale '${r}'${i}. Set locale.og (e.g. 'en_US') or use iso with a 2-letter region (e.g. 'en-US').`);
|
|
491
436
|
}
|
|
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
|
-
getRoute: e.getRoute.bind(e),
|
|
540
|
-
getLocale: () => e.locale.value,
|
|
541
|
-
// Translation management
|
|
542
|
-
addTranslations: e.addTranslations.bind(e),
|
|
543
|
-
addRouteTranslations: e.addRouteTranslations.bind(e),
|
|
544
|
-
mergeTranslations: e.mergeTranslations.bind(e),
|
|
545
|
-
clearCache: e.clearCache.bind(e)
|
|
546
|
-
};
|
|
437
|
+
//#endregion
|
|
438
|
+
//#region src/use-i18n.ts
|
|
439
|
+
function E(t) {
|
|
440
|
+
let n = r(p), i = r(g, void 0), a = r(m, void 0), o = r(h, void 0);
|
|
441
|
+
if (!n) throw Error("[i18n-micro] useI18n() must be called after app.use(i18n). Make sure i18n plugin is installed.");
|
|
442
|
+
if (!a) throw Error("[i18n-micro] I18nLocalesKey not provided. Make sure app.provide(I18nLocalesKey, locales) is called.");
|
|
443
|
+
if (!o) throw Error("[i18n-micro] I18nDefaultLocaleKey not provided. Make sure app.provide(I18nDefaultLocaleKey, defaultLocale) is called.");
|
|
444
|
+
let s = t?.locales || a, c = t?.defaultLocale || o, l = (e, t) => i?.resolvePath ? i.resolvePath(e, t || n.locale.value) : e;
|
|
445
|
+
return {
|
|
446
|
+
instance: n,
|
|
447
|
+
locale: e({
|
|
448
|
+
get: () => n.locale.value,
|
|
449
|
+
set: (e) => {
|
|
450
|
+
n.locale.value = e;
|
|
451
|
+
}
|
|
452
|
+
}),
|
|
453
|
+
getLocales: () => s,
|
|
454
|
+
defaultLocale: () => c,
|
|
455
|
+
getLocaleName: () => s.find((e) => e.code === n.locale.value)?.displayName || null,
|
|
456
|
+
localeRoute: l,
|
|
457
|
+
localePath: (e, t) => {
|
|
458
|
+
let n = l(e, t);
|
|
459
|
+
return typeof n == "string" ? n : n.path || "/";
|
|
460
|
+
},
|
|
461
|
+
switchLocale: (e) => {
|
|
462
|
+
if (n.locale.value = e, i) {
|
|
463
|
+
let t = i.getCurrentPath(), n = l(t, e);
|
|
464
|
+
i.push(typeof n == "string" ? { path: n } : { path: n.path || "/" });
|
|
465
|
+
}
|
|
466
|
+
},
|
|
467
|
+
t: n.t.bind(n),
|
|
468
|
+
ts: n.ts.bind(n),
|
|
469
|
+
tc: n.tc.bind(n),
|
|
470
|
+
tn: n.tn.bind(n),
|
|
471
|
+
td: n.td.bind(n),
|
|
472
|
+
tdr: n.tdr.bind(n),
|
|
473
|
+
has: n.has.bind(n),
|
|
474
|
+
resolveTranslations: n.resolveTranslations.bind(n),
|
|
475
|
+
setTranslation: n.setTranslation.bind(n),
|
|
476
|
+
setRoute: n.setRoute.bind(n),
|
|
477
|
+
getRoute: n.getRoute.bind(n),
|
|
478
|
+
getLocale: () => n.locale.value,
|
|
479
|
+
addTranslations: n.addTranslations.bind(n),
|
|
480
|
+
addRouteTranslations: n.addRouteTranslations.bind(n),
|
|
481
|
+
mergeTranslations: n.mergeTranslations.bind(n),
|
|
482
|
+
clearCache: n.clearCache.bind(n)
|
|
483
|
+
};
|
|
547
484
|
}
|
|
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
|
-
|
|
485
|
+
//#endregion
|
|
486
|
+
//#region src/composables/use-locale-head.ts
|
|
487
|
+
function D(e = {}) {
|
|
488
|
+
let { addDirAttribute: t = !0, identifierAttribute: n = "id", addSeoAttributes: i = !0, baseUrl: a = "/", hreflangBaseLanguage: o = !1 } = e, { getLocale: c, getLocales: l, localeRoute: u } = E(), d = r(g, void 0), f = s({
|
|
489
|
+
htmlAttrs: {},
|
|
490
|
+
link: [],
|
|
491
|
+
meta: []
|
|
492
|
+
});
|
|
493
|
+
function p(e, t) {
|
|
494
|
+
let n = new URL(e, "http://localhost"), r = new URLSearchParams(n.search), i = {};
|
|
495
|
+
for (let e of t) r.has(e) && (i[e] = r.get(e));
|
|
496
|
+
let a = new URLSearchParams(i);
|
|
497
|
+
return a.toString() ? `${n.pathname}?${a.toString()}` : n.pathname;
|
|
498
|
+
}
|
|
499
|
+
function m(e = []) {
|
|
500
|
+
if (!d) {
|
|
501
|
+
f.value = {
|
|
502
|
+
htmlAttrs: {},
|
|
503
|
+
link: [],
|
|
504
|
+
meta: []
|
|
505
|
+
};
|
|
506
|
+
return;
|
|
507
|
+
}
|
|
508
|
+
let s = c(), m = l(), g = m.find((e) => e.code === s);
|
|
509
|
+
if (!g) return;
|
|
510
|
+
let _ = g.iso || s, v = w(g), y = g.dir || "auto", b = d.getCurrentPath();
|
|
511
|
+
b.startsWith("/") || (b = `/${b}`);
|
|
512
|
+
let x = b.split("/").filter(Boolean), S = m.find((e) => x[0] === e.code), E = b, D, O, k = typeof a == "function" ? a() : a;
|
|
513
|
+
S ? (E = b.slice(S.code.length + 1) || "/", D = p(E, e), O = `${k}${`/${s}`}${D.startsWith("/") ? "" : "/"}${D}`) : (D = p(b, e), O = `${k}${D.startsWith("/") ? "" : "/"}${D}`);
|
|
514
|
+
let A = {
|
|
515
|
+
lang: _,
|
|
516
|
+
...t ? { dir: y } : {}
|
|
517
|
+
};
|
|
518
|
+
if (!i) {
|
|
519
|
+
f.value = {
|
|
520
|
+
htmlAttrs: A,
|
|
521
|
+
link: [],
|
|
522
|
+
meta: []
|
|
523
|
+
};
|
|
524
|
+
return;
|
|
525
|
+
}
|
|
526
|
+
let j = m.filter((e) => !e.disabled && e.seo !== !1);
|
|
527
|
+
v || T(g, { tag: "og:locale" });
|
|
528
|
+
let M = v ? {
|
|
529
|
+
[n]: "i18n-og",
|
|
530
|
+
property: "og:locale",
|
|
531
|
+
content: v
|
|
532
|
+
} : null, N = {
|
|
533
|
+
[n]: "i18n-og-url",
|
|
534
|
+
property: "og:url",
|
|
535
|
+
content: O
|
|
536
|
+
}, P = j.filter((e) => e.code !== s).map((e) => {
|
|
537
|
+
let t = w(e);
|
|
538
|
+
return t ? {
|
|
539
|
+
[n]: `i18n-og-alt-${t}`,
|
|
540
|
+
property: "og:locale:alternate",
|
|
541
|
+
content: t
|
|
542
|
+
} : (T(e, { tag: "og:locale:alternate" }), null);
|
|
543
|
+
}).filter((e) => e !== null), F = {
|
|
544
|
+
[n]: "i18n-can",
|
|
545
|
+
rel: "canonical",
|
|
546
|
+
href: O
|
|
547
|
+
}, I = (() => {
|
|
548
|
+
if (!u || !d) return [];
|
|
549
|
+
let e = /* @__PURE__ */ new Map(), t = d.getCurrentPath();
|
|
550
|
+
for (let n of j) {
|
|
551
|
+
let r = u(t, n.code), i = typeof r == "string" ? r : r?.path || "/";
|
|
552
|
+
if (!i) continue;
|
|
553
|
+
let o;
|
|
554
|
+
o = i.startsWith("http://") || i.startsWith("https://") ? i : `${typeof a == "function" ? a() : a}${i.startsWith("/") ? "" : "/"}${i}`, e.set(String(n.code), o);
|
|
555
|
+
}
|
|
556
|
+
return C(j, { hreflangBaseLanguage: o }).flatMap(({ hreflang: t, localeCode: r }) => {
|
|
557
|
+
let i = e.get(r);
|
|
558
|
+
return i ? [{
|
|
559
|
+
[n]: `i18n-alternate-${t}`,
|
|
560
|
+
rel: "alternate",
|
|
561
|
+
href: i,
|
|
562
|
+
hreflang: t
|
|
563
|
+
}] : [];
|
|
564
|
+
});
|
|
565
|
+
})(), L = r(h, void 0), R = null, z = L ? m.find((e) => e.code === L) : void 0;
|
|
566
|
+
if (u && d && L && z?.seo !== !1) {
|
|
567
|
+
let e = d.getCurrentPath(), t = u(e, L), r = typeof t == "string" ? t : t?.path || "/";
|
|
568
|
+
if (r) {
|
|
569
|
+
let e;
|
|
570
|
+
e = r.startsWith("http://") || r.startsWith("https://") ? r : `${typeof a == "function" ? a() : a}${r.startsWith("/") ? "" : "/"}${r}`, R = {
|
|
571
|
+
[n]: "i18n-xd",
|
|
572
|
+
rel: "alternate",
|
|
573
|
+
href: e,
|
|
574
|
+
hreflang: "x-default"
|
|
575
|
+
};
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
f.value = {
|
|
579
|
+
htmlAttrs: A,
|
|
580
|
+
meta: [
|
|
581
|
+
...M ? [M] : [],
|
|
582
|
+
N,
|
|
583
|
+
...P
|
|
584
|
+
],
|
|
585
|
+
link: [
|
|
586
|
+
F,
|
|
587
|
+
...I,
|
|
588
|
+
...R ? [R] : []
|
|
589
|
+
]
|
|
590
|
+
};
|
|
591
|
+
}
|
|
592
|
+
return {
|
|
593
|
+
metaObject: f,
|
|
594
|
+
updateMeta: m
|
|
595
|
+
};
|
|
656
596
|
}
|
|
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
|
-
e[a] = o;
|
|
726
|
-
return e;
|
|
727
|
-
}
|
|
728
|
-
}
|
|
729
|
-
function Le(t) {
|
|
730
|
-
const { routingStrategy: e, locales: a, defaultLocale: o, ...c } = t, r = new ge(c);
|
|
731
|
-
let s = null, f = e || null;
|
|
732
|
-
return {
|
|
733
|
-
global: r,
|
|
734
|
-
// Access to instance outside components
|
|
735
|
-
setRoutingStrategy: (n) => {
|
|
736
|
-
f = n, s && s.provide(U, n);
|
|
737
|
-
},
|
|
738
|
-
// Method for setting adapter after creation
|
|
739
|
-
install(n) {
|
|
740
|
-
s = n, n.provide(W, r), f && n.provide(U, f), a && n.provide(Y, a), o && n.provide(ee, o), n.config.globalProperties.$t = (l, m, v, L) => r.t(l, m, v, L), n.config.globalProperties.$ts = (l, m, v, L) => r.ts(l, m, v, L), n.config.globalProperties.$tc = (l, m, v) => r.tc(l, m, v), n.config.globalProperties.$tn = r.tn.bind(r), n.config.globalProperties.$td = r.td.bind(r), n.config.globalProperties.$tdr = r.tdr.bind(r), n.config.globalProperties.$has = (l, m) => r.has(l, m), n.config.globalProperties.$i18n = r, n.component("I18nT", fe), n.component("I18nLink", se), n.component("I18nGroup", ce), n.component("I18nSwitcher", ue);
|
|
741
|
-
}
|
|
742
|
-
};
|
|
743
|
-
}
|
|
744
|
-
function Se(t, e, a) {
|
|
745
|
-
const o = e.map((r) => r.code), c = (r, s) => {
|
|
746
|
-
const i = (typeof r == "string" ? r : r.path || "/").split("/").filter(Boolean), n = i[0];
|
|
747
|
-
n !== void 0 && o.includes(n) && i.shift();
|
|
748
|
-
const l = `/${i.join("/")}`;
|
|
749
|
-
return s === a ? l : `/${s}${l === "/" ? "" : l}`;
|
|
750
|
-
};
|
|
751
|
-
return {
|
|
752
|
-
linkComponent: ie,
|
|
753
|
-
getCurrentPath: () => t.currentRoute.value.path,
|
|
754
|
-
push: (r) => {
|
|
755
|
-
t.push(r.path).catch(() => {
|
|
756
|
-
});
|
|
757
|
-
},
|
|
758
|
-
replace: (r) => {
|
|
759
|
-
t.replace(r.path).catch(() => {
|
|
760
|
-
});
|
|
761
|
-
},
|
|
762
|
-
resolvePath: (r, s) => c(r, s),
|
|
763
|
-
getRoute: () => ({
|
|
764
|
-
fullPath: t.currentRoute.value.fullPath,
|
|
765
|
-
query: t.currentRoute.value.query
|
|
766
|
-
})
|
|
767
|
-
};
|
|
768
|
-
}
|
|
769
|
-
export {
|
|
770
|
-
Pe as FormatService,
|
|
771
|
-
ee as I18nDefaultLocaleKey,
|
|
772
|
-
ce as I18nGroup,
|
|
773
|
-
W as I18nInjectionKey,
|
|
774
|
-
se as I18nLink,
|
|
775
|
-
Y as I18nLocalesKey,
|
|
776
|
-
ue as I18nSwitcher,
|
|
777
|
-
fe as I18nT,
|
|
778
|
-
ge as VueI18n,
|
|
779
|
-
Le as createI18n,
|
|
780
|
-
Se as createVueRouterAdapter,
|
|
781
|
-
$e as defaultPlural,
|
|
782
|
-
Re as interpolate,
|
|
783
|
-
he as useI18n,
|
|
784
|
-
be as useLocaleHead
|
|
597
|
+
//#endregion
|
|
598
|
+
//#region src/composer.ts
|
|
599
|
+
var O = class extends l {
|
|
600
|
+
constructor(e) {
|
|
601
|
+
let t = { translations: /* @__PURE__ */ new Map() };
|
|
602
|
+
if (super({
|
|
603
|
+
storage: t,
|
|
604
|
+
plural: e.plural,
|
|
605
|
+
missingWarn: e.missingWarn,
|
|
606
|
+
missingHandler: e.missingHandler
|
|
607
|
+
}), this.listeners = /* @__PURE__ */ new Set(), this.storage = t, this._locale = c(e.locale), this._fallbackLocale = c(e.fallbackLocale || e.locale), this._currentRoute = c("index"), this._revision = c(0), e.messages) for (let [t, n] of Object.entries(e.messages)) this.helper.loadTranslations(t, n);
|
|
608
|
+
}
|
|
609
|
+
get locale() {
|
|
610
|
+
return this._locale;
|
|
611
|
+
}
|
|
612
|
+
set locale(e) {
|
|
613
|
+
typeof e == "string" ? this._locale.value = e : this._locale = e;
|
|
614
|
+
}
|
|
615
|
+
get fallbackLocale() {
|
|
616
|
+
return this._fallbackLocale;
|
|
617
|
+
}
|
|
618
|
+
set fallbackLocale(e) {
|
|
619
|
+
typeof e == "string" ? this._fallbackLocale.value = e : this._fallbackLocale = e;
|
|
620
|
+
}
|
|
621
|
+
get currentRoute() {
|
|
622
|
+
return this._currentRoute;
|
|
623
|
+
}
|
|
624
|
+
setRoute(e) {
|
|
625
|
+
this._currentRoute.value = e;
|
|
626
|
+
}
|
|
627
|
+
getLocale() {
|
|
628
|
+
return this._locale.value;
|
|
629
|
+
}
|
|
630
|
+
getFallbackLocale() {
|
|
631
|
+
return this._fallbackLocale.value;
|
|
632
|
+
}
|
|
633
|
+
getRoute() {
|
|
634
|
+
return this._currentRoute.value;
|
|
635
|
+
}
|
|
636
|
+
addTranslations(e, t, n = !0) {
|
|
637
|
+
super.loadTranslationsCore(e, t, n), this._revision.value++, this.notifyListeners();
|
|
638
|
+
}
|
|
639
|
+
addRouteTranslations(e, t, n, r = !0) {
|
|
640
|
+
super.loadRouteTranslationsCore(e, t, n, r), this._revision.value++, this.notifyListeners();
|
|
641
|
+
}
|
|
642
|
+
mergeTranslations(e, t, n) {
|
|
643
|
+
this.helper.mergeTranslation(e, t, n, !0), this._revision.value++, this.notifyListeners();
|
|
644
|
+
}
|
|
645
|
+
clearCache() {
|
|
646
|
+
super.clearCache(), this._revision.value++, this.notifyListeners();
|
|
647
|
+
}
|
|
648
|
+
onTranslationsChanged() {
|
|
649
|
+
this._revision.value++, this.notifyListeners();
|
|
650
|
+
}
|
|
651
|
+
subscribeToChanges(e) {
|
|
652
|
+
return this.listeners.add(e), () => this.listeners.delete(e);
|
|
653
|
+
}
|
|
654
|
+
notifyListeners() {
|
|
655
|
+
this.listeners.forEach((e) => e());
|
|
656
|
+
}
|
|
657
|
+
getStorage() {
|
|
658
|
+
return this.storage;
|
|
659
|
+
}
|
|
660
|
+
getRouteCache() {
|
|
661
|
+
let e = {};
|
|
662
|
+
for (let [t, n] of this.storage.translations) e[t] = n;
|
|
663
|
+
return e;
|
|
664
|
+
}
|
|
785
665
|
};
|
|
786
|
-
//#
|
|
666
|
+
//#endregion
|
|
667
|
+
//#region src/plugin.ts
|
|
668
|
+
function k(e) {
|
|
669
|
+
let { routingStrategy: t, locales: n, defaultLocale: r, ...i } = e, a = new O(i), o = null, s = t || null;
|
|
670
|
+
return {
|
|
671
|
+
global: a,
|
|
672
|
+
setRoutingStrategy: (e) => {
|
|
673
|
+
s = e, o && o.provide(g, e);
|
|
674
|
+
},
|
|
675
|
+
install(e) {
|
|
676
|
+
o = e, e.provide(p, a), s && e.provide(g, s), n && e.provide(m, n), r && e.provide(h, r), e.config.globalProperties.$t = (e, t, n, r) => a.t(e, t, n, r), e.config.globalProperties.$ts = (e, t, n, r) => a.ts(e, t, n, r), e.config.globalProperties.$tc = (e, t, n) => a.tc(e, t, n), e.config.globalProperties.$tn = a.tn.bind(a), e.config.globalProperties.$td = a.td.bind(a), e.config.globalProperties.$tdr = a.tdr.bind(a), e.config.globalProperties.$has = (e, t) => a.has(e, t), e.config.globalProperties.$i18n = a, e.component("I18nT", b), e.component("I18nLink", v), e.component("I18nGroup", _), e.component("I18nSwitcher", y);
|
|
677
|
+
}
|
|
678
|
+
};
|
|
679
|
+
}
|
|
680
|
+
//#endregion
|
|
681
|
+
export { u as FormatService, h as I18nDefaultLocaleKey, _ as I18nGroup, p as I18nInjectionKey, v as I18nLink, m as I18nLocalesKey, y as I18nSwitcher, b as I18nT, O as VueI18n, k as createI18n, d as defaultPlural, f as interpolate, E as useI18n, D as useLocaleHead };
|
|
682
|
+
|
|
683
|
+
//# sourceMappingURL=index.mjs.map
|