@i18n-micro/vue 1.4.11 → 2.0.1
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/LICENSE +1 -1
- package/README.md +12 -47
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +129 -157
- package/dist/index.d.ts +129 -157
- package/dist/index.mjs +328 -467
- package/dist/index.mjs.map +1 -1
- package/dist/router.cjs +1 -1
- package/dist/router.cjs.map +1 -1
- package/dist/router.d.cts +29 -7
- package/dist/router.d.ts +29 -7
- package/dist/router.mjs +13 -18
- package/dist/router.mjs.map +1 -1
- package/package.json +21 -15
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { BaseI18n as l, FormatService as u, defaultPlural as d,
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { Fragment as e, computed as t, defineComponent as n, h as r, inject 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, externalLinkHref as f, interpolate as p, isPlainClick as m, isSamePage as h, localeIsoMap as g, urlPath as _ } from "@i18n-micro/core";
|
|
3
|
+
import { createLocaleSwitcher as v, renderI18nT as y } from "@i18n-micro/core/render";
|
|
4
|
+
// src/injection.ts
|
|
5
|
+
var b = Symbol("i18n"), x = Symbol("i18n-locales"), S = Symbol("i18n-default-locale"), C = Symbol("i18n-router-strategy"), w = /*#__PURE__*/ n({
|
|
5
6
|
name: "I18nGroup",
|
|
6
7
|
props: {
|
|
7
8
|
prefix: {
|
|
@@ -14,15 +15,198 @@ var p = Symbol("i18n"), m = Symbol("i18n-locales"), h = Symbol("i18n-default-loc
|
|
|
14
15
|
}
|
|
15
16
|
},
|
|
16
17
|
setup(e, { slots: t }) {
|
|
17
|
-
let
|
|
18
|
-
if (!
|
|
19
|
-
let a = (t,
|
|
20
|
-
return () =>
|
|
18
|
+
let n = i(b);
|
|
19
|
+
if (!n) throw Error("[i18n-micro] I18nGroup: i18n instance not found. Make sure i18n plugin is installed.");
|
|
20
|
+
let a = (t, r) => n.t(`${e.prefix}.${t}`, r, void 0, n.getRoute());
|
|
21
|
+
return () => r("div", { class: ["i18n-group", e.groupClass] }, t.default?.({
|
|
21
22
|
prefix: e.prefix,
|
|
22
23
|
t: a
|
|
23
24
|
}));
|
|
24
25
|
}
|
|
25
|
-
})
|
|
26
|
+
});
|
|
27
|
+
new Set("xml txt ico json js css png jpg jpeg gif svg webp avif pdf wasm map mp4 webm mp3 zip gz woff woff2 ttf eot".split(" "));
|
|
28
|
+
function T(e) {
|
|
29
|
+
let t = e.length;
|
|
30
|
+
for (; e[t - 1] === "/";) t--;
|
|
31
|
+
return e.slice(0, t);
|
|
32
|
+
}
|
|
33
|
+
// ../utils/dist/resolve-hreflang.mjs
|
|
34
|
+
function E(e) {
|
|
35
|
+
return e.iso?.trim() || String(e.code);
|
|
36
|
+
}
|
|
37
|
+
function D(e) {
|
|
38
|
+
let t = e.match(/^([A-Za-z]{2,3})(?:[-_](.+))?$/);
|
|
39
|
+
return t ? {
|
|
40
|
+
language: t[1],
|
|
41
|
+
region: t[2]
|
|
42
|
+
} : { language: e };
|
|
43
|
+
}
|
|
44
|
+
function ee(e, t = {}) {
|
|
45
|
+
let { hreflangBaseLanguage: n = !1 } = t;
|
|
46
|
+
if (!n) return e.map((e) => {
|
|
47
|
+
let t = String(e.code);
|
|
48
|
+
return {
|
|
49
|
+
hreflang: E(e),
|
|
50
|
+
localeCode: t
|
|
51
|
+
};
|
|
52
|
+
});
|
|
53
|
+
let r = /* @__PURE__ */ new Map();
|
|
54
|
+
for (let t of e) {
|
|
55
|
+
let e = String(t.code), n = E(t), { language: i, region: a } = D(n);
|
|
56
|
+
i && a && !r.has(i) && r.set(i, e), r.set(n, e);
|
|
57
|
+
}
|
|
58
|
+
let i = /* @__PURE__ */ new Set(), a = [];
|
|
59
|
+
for (let t of e) {
|
|
60
|
+
let e = String(t.code), n = E(t), { language: o, region: s } = D(n);
|
|
61
|
+
o && s && r.get(o) === e && !i.has(o) && (i.add(o), a.push({
|
|
62
|
+
hreflang: o,
|
|
63
|
+
localeCode: e
|
|
64
|
+
})), i.has(n) || (i.add(n), a.push({
|
|
65
|
+
hreflang: n,
|
|
66
|
+
localeCode: e
|
|
67
|
+
}));
|
|
68
|
+
}
|
|
69
|
+
return a;
|
|
70
|
+
}
|
|
71
|
+
// ../utils/dist/resolve-og-locale.mjs
|
|
72
|
+
function O(e) {
|
|
73
|
+
let t = e.og?.trim();
|
|
74
|
+
if (t) return t;
|
|
75
|
+
let n = e.iso?.trim();
|
|
76
|
+
return n ? A(n, "_") ?? A(n, "-") : null;
|
|
77
|
+
}
|
|
78
|
+
function k(e) {
|
|
79
|
+
for (let t = 0; t < e.length; t++) {
|
|
80
|
+
let n = e.charCodeAt(t) | 32;
|
|
81
|
+
if (n < 97 || n > 122) return !1;
|
|
82
|
+
}
|
|
83
|
+
return !0;
|
|
84
|
+
}
|
|
85
|
+
function A(e, t) {
|
|
86
|
+
let n = e.indexOf(t), r = e.slice(0, n), i = e.slice(n + 1);
|
|
87
|
+
return n < 2 || i.length !== 2 || !k(r) || !k(i) ? null : `${r.toLowerCase()}_${i.toUpperCase()}`;
|
|
88
|
+
}
|
|
89
|
+
function j(e, t = {}) {
|
|
90
|
+
if (O(e) !== null || t.missingWarn === !1 || process.env.NODE_ENV === "production") return;
|
|
91
|
+
let n = t.tag ?? "og:locale", r = String(e.code ?? "unknown"), i = e.iso ? `, iso: '${e.iso}'` : "";
|
|
92
|
+
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').`);
|
|
93
|
+
}
|
|
94
|
+
// ../utils/dist/locale-head.mjs
|
|
95
|
+
function M(e) {
|
|
96
|
+
let t = e.indexOf("?"), n = e.indexOf("#");
|
|
97
|
+
return t === -1 ? n : n === -1 || t < n ? t : n;
|
|
98
|
+
}
|
|
99
|
+
function N(e, t) {
|
|
100
|
+
let n = M(e);
|
|
101
|
+
if (n === -1) return e;
|
|
102
|
+
let r = e.slice(0, n) || "/", i = e.indexOf("#", n), a = e.slice(n + 1, i === -1 ? void 0 : i), o = /* @__PURE__ */ new Map();
|
|
103
|
+
for (let e of a.split("&")) {
|
|
104
|
+
let [n] = new URLSearchParams(e);
|
|
105
|
+
if (!n || !t.includes(n[0])) continue;
|
|
106
|
+
let r = new URLSearchParams([n]).toString(), i = e.includes("=") ? r : r.slice(0, -1), a = o.get(n[0]);
|
|
107
|
+
a ? a.push(i) : o.set(n[0], [i]);
|
|
108
|
+
}
|
|
109
|
+
let s = [...new Set(t)].flatMap((e) => o.get(e) ?? []).join("&");
|
|
110
|
+
return s ? `${r}?${s}` : r;
|
|
111
|
+
}
|
|
112
|
+
function P(e) {
|
|
113
|
+
let t = [];
|
|
114
|
+
for (let [n, r] of Object.entries(e ?? {})) for (let e of [r].flat()) {
|
|
115
|
+
if (e === void 0) continue;
|
|
116
|
+
let r = new URLSearchParams([[n, e === null ? "" : String(e)]]).toString();
|
|
117
|
+
t.push(e === null ? r.slice(0, -1) : r);
|
|
118
|
+
}
|
|
119
|
+
return t.length ? `?${t.join("&")}` : "";
|
|
120
|
+
}
|
|
121
|
+
function F(e, t) {
|
|
122
|
+
let n = 0;
|
|
123
|
+
for (; n < t.length; n++) {
|
|
124
|
+
let e = t.charCodeAt(n);
|
|
125
|
+
if (e !== 47 && e !== 92 && e !== 9 && e !== 10 && e !== 13) break;
|
|
126
|
+
}
|
|
127
|
+
return `${T(e)}/${t.slice(n)}`;
|
|
128
|
+
}
|
|
129
|
+
var I = new Set("Adlm Arab Aran Armi Avst Chrs Cprt Elym Hatr Hebr Hung Khar Lydi Mand Mani Mend Merc Mero Narb Nbat Nkoo Orkh Ougr Palm Phli Phlp Phnx Prti Rohg Samr Sarb Sogd Sogo Syrc Thaa Yezi".split(" ")), L = (e) => I.has(new Intl.Locale(e).maximize().script ?? "");
|
|
130
|
+
function R(e) {
|
|
131
|
+
let [t, ...n] = e.split("_").join("-").split("-");
|
|
132
|
+
for (; n[0]?.length === 3 && Number.isNaN(Number(n[0]));) n.shift();
|
|
133
|
+
try {
|
|
134
|
+
return L([t, ...n].join("-"));
|
|
135
|
+
} catch {
|
|
136
|
+
try {
|
|
137
|
+
return !n.includes("") && L(t);
|
|
138
|
+
} catch {
|
|
139
|
+
return !1;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
var z = /* @__PURE__ */ new Map();
|
|
144
|
+
function B(e) {
|
|
145
|
+
let t = z.get(e);
|
|
146
|
+
return t === void 0 && z.set(e, t = R(e)), t;
|
|
147
|
+
}
|
|
148
|
+
function V(e) {
|
|
149
|
+
return e.dir || (B(e.iso || e.code) ? "rtl" : void 0);
|
|
150
|
+
}
|
|
151
|
+
function H(e) {
|
|
152
|
+
let { locale: t, seoLocales: n, hrefOf: r, canonical: i, xDefault: a, alternates: o = !0, addDirAttribute: s = !0, addSeoAttributes: c = !0 } = e, { identifierAttribute: l = "id", hreflangBaseLanguage: u = !1, missingWarn: d = !0 } = e, f = { lang: t.iso || t.code }, p = s ? V(t) : void 0;
|
|
153
|
+
if (p && (f.dir = p), !c) return {
|
|
154
|
+
htmlAttrs: f,
|
|
155
|
+
link: [],
|
|
156
|
+
meta: []
|
|
157
|
+
};
|
|
158
|
+
let m = [], h = O(t);
|
|
159
|
+
h ? m.push({
|
|
160
|
+
[l]: "i18n-og",
|
|
161
|
+
property: "og:locale",
|
|
162
|
+
content: h
|
|
163
|
+
}) : j(t, {
|
|
164
|
+
missingWarn: d,
|
|
165
|
+
tag: "og:locale"
|
|
166
|
+
}), m.push({
|
|
167
|
+
[l]: "i18n-og-url",
|
|
168
|
+
property: "og:url",
|
|
169
|
+
content: i
|
|
170
|
+
});
|
|
171
|
+
for (let e of n) {
|
|
172
|
+
if (e.code === t.code) continue;
|
|
173
|
+
let n = O(e);
|
|
174
|
+
n ? m.push({
|
|
175
|
+
[l]: `i18n-og-alt-${n}`,
|
|
176
|
+
property: "og:locale:alternate",
|
|
177
|
+
content: n
|
|
178
|
+
}) : j(e, {
|
|
179
|
+
missingWarn: d,
|
|
180
|
+
tag: "og:locale:alternate"
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
let g = [{
|
|
184
|
+
[l]: "i18n-can",
|
|
185
|
+
rel: "canonical",
|
|
186
|
+
href: i
|
|
187
|
+
}];
|
|
188
|
+
if (o) for (let { hreflang: e, localeCode: t } of ee(n, { hreflangBaseLanguage: u })) {
|
|
189
|
+
let n = r(t);
|
|
190
|
+
n && g.push({
|
|
191
|
+
[l]: `i18n-alternate-${e}`,
|
|
192
|
+
rel: "alternate",
|
|
193
|
+
href: n,
|
|
194
|
+
hreflang: e
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
return o && a && g.push({
|
|
198
|
+
[l]: "i18n-xd",
|
|
199
|
+
rel: "alternate",
|
|
200
|
+
href: a,
|
|
201
|
+
hreflang: "x-default"
|
|
202
|
+
}), {
|
|
203
|
+
htmlAttrs: f,
|
|
204
|
+
link: g,
|
|
205
|
+
meta: m
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
// src/router/path.ts
|
|
209
|
+
var U = (e) => typeof e == "string" ? e : `${e.path || "/"}${P(e.query)}${e.hash ?? ""}`, W = (e) => e.getRoute?.().fullPath ?? e.getCurrentPath(), G = /*#__PURE__*/ n({
|
|
26
210
|
name: "I18nLink",
|
|
27
211
|
props: {
|
|
28
212
|
to: {
|
|
@@ -38,74 +222,49 @@ var p = Symbol("i18n"), m = Symbol("i18n-locales"), h = Symbol("i18n-default-loc
|
|
|
38
222
|
default: void 0
|
|
39
223
|
}
|
|
40
224
|
},
|
|
41
|
-
setup(
|
|
42
|
-
let a =
|
|
225
|
+
setup(e, { slots: n }) {
|
|
226
|
+
let a = i(b), o = i(C, void 0);
|
|
43
227
|
if (!a) throw Error("[i18n-micro] I18nLink: i18n instance not found. Make sure i18n plugin is installed.");
|
|
44
|
-
let s =
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
onClick: (e) => {
|
|
66
|
-
e.preventDefault(), o ? o.push({ path: c.value }) : window.location.href = c.value;
|
|
67
|
-
}
|
|
68
|
-
}, i.default?.());
|
|
228
|
+
let s = t(() => f(e.to)), c = t(() => e.localeRoute ? U(e.localeRoute(e.to)) : o?.resolvePath ? U(o.resolvePath(e.to, a.locale.value)) : U(e.to)), l = t(() => o !== void 0 && s.value === void 0 && h(o.getCurrentPath(), c.value) ? e.activeStyle : {}), u = (e) => {
|
|
229
|
+
m(e) && (e.preventDefault(), o ? o.push({ path: c.value }) : window.location.href = c.value);
|
|
230
|
+
};
|
|
231
|
+
return () => {
|
|
232
|
+
if (s.value !== void 0) return r("a", {
|
|
233
|
+
href: s.value,
|
|
234
|
+
target: "_blank",
|
|
235
|
+
rel: "noopener noreferrer",
|
|
236
|
+
style: l.value
|
|
237
|
+
}, n.default?.());
|
|
238
|
+
if (o?.linkComponent) return r(o.linkComponent, {
|
|
239
|
+
to: c.value,
|
|
240
|
+
style: l.value
|
|
241
|
+
}, { default: n.default });
|
|
242
|
+
let e = o?.toHref?.(c.value) ?? c.value;
|
|
243
|
+
return r("a", {
|
|
244
|
+
href: e,
|
|
245
|
+
style: l.value,
|
|
246
|
+
onClick: u
|
|
247
|
+
}, n.default?.());
|
|
248
|
+
};
|
|
69
249
|
}
|
|
70
|
-
}),
|
|
250
|
+
}), K = {
|
|
251
|
+
type: Object,
|
|
252
|
+
default: () => ({})
|
|
253
|
+
}, q = /*#__PURE__*/ n({
|
|
71
254
|
name: "I18nSwitcher",
|
|
72
255
|
props: {
|
|
73
256
|
customLabels: {
|
|
74
257
|
type: Object,
|
|
75
258
|
default: () => ({})
|
|
76
259
|
},
|
|
77
|
-
customWrapperStyle:
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
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
|
-
},
|
|
260
|
+
customWrapperStyle: K,
|
|
261
|
+
customButtonStyle: K,
|
|
262
|
+
customDropdownStyle: K,
|
|
263
|
+
customItemStyle: K,
|
|
264
|
+
customLinkStyle: K,
|
|
265
|
+
customActiveLinkStyle: K,
|
|
266
|
+
customDisabledLinkStyle: K,
|
|
267
|
+
customIconStyle: K,
|
|
109
268
|
locales: {
|
|
110
269
|
type: Array,
|
|
111
270
|
default: void 0
|
|
@@ -127,152 +286,45 @@ var p = Symbol("i18n"), m = Symbol("i18n-locales"), h = Symbol("i18n-default-loc
|
|
|
127
286
|
default: void 0
|
|
128
287
|
}
|
|
129
288
|
},
|
|
130
|
-
setup(t, { slots:
|
|
131
|
-
let
|
|
132
|
-
if (!
|
|
133
|
-
if (!
|
|
134
|
-
let
|
|
135
|
-
|
|
136
|
-
|
|
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);
|
|
289
|
+
setup(t, { slots: n }) {
|
|
290
|
+
let c = i(b), l = i(C, void 0), u = i(x, void 0);
|
|
291
|
+
if (!c) throw Error("[i18n-micro] I18nSwitcher: i18n instance not found. Make sure i18n plugin is installed.");
|
|
292
|
+
if (!u && !t.locales) throw Error("[i18n-micro] I18nSwitcher: locales not provided. Make sure app.provide(I18nLocalesKey, locales) is called or pass locales prop.");
|
|
293
|
+
let d = () => t.locales || u || [], f = (e) => {
|
|
294
|
+
let n = l ? W(l) : typeof window < "u" ? window.location.pathname + window.location.search + window.location.hash : "/";
|
|
295
|
+
return t.localeRoute ? t.localeRoute(n, e) : l?.resolvePath ? l.resolvePath(n, e) : n;
|
|
203
296
|
};
|
|
204
|
-
return
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
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));
|
|
297
|
+
return v({
|
|
298
|
+
h: r,
|
|
299
|
+
Fragment: e,
|
|
300
|
+
ref: s,
|
|
301
|
+
onMounted: a,
|
|
302
|
+
onUnmounted: o
|
|
303
|
+
}, {
|
|
304
|
+
locales: d,
|
|
305
|
+
locale: () => typeof t.currentLocale == "function" ? t.currentLocale() : t.currentLocale ?? c.locale.value,
|
|
306
|
+
localeName: () => t.getLocaleName ? t.getLocaleName() : d().find((e) => e.code === c.locale.value)?.displayName ?? null,
|
|
307
|
+
href: (e) => {
|
|
308
|
+
let t = f(e), n = typeof t == "string" ? t : t.path;
|
|
309
|
+
return n ? l?.toHref?.(n) ?? n : "#";
|
|
310
|
+
},
|
|
311
|
+
browserNavigates: () => !l && !t.switchLocale && t.localeRoute !== void 0,
|
|
312
|
+
select: (e) => {
|
|
313
|
+
if (t.switchLocale) return t.switchLocale(e);
|
|
314
|
+
let n = l && U(f(e));
|
|
315
|
+
c.locale.value = e, n && l.push({ path: n });
|
|
263
316
|
}
|
|
264
|
-
|
|
265
|
-
ref: x,
|
|
266
|
-
class: "i18n-switcher-wrapper",
|
|
267
|
-
style: {
|
|
268
|
-
...E,
|
|
269
|
-
...t.customWrapperStyle
|
|
270
|
-
}
|
|
271
|
-
}, e);
|
|
272
|
-
};
|
|
317
|
+
}, t, n);
|
|
273
318
|
}
|
|
274
|
-
}),
|
|
275
|
-
|
|
319
|
+
}), J = {
|
|
320
|
+
h: r,
|
|
321
|
+
Fragment: e
|
|
322
|
+
}, Y = /*#__PURE__*/ Object.assign((e, { slots: t, attrs: n }) => {
|
|
323
|
+
let r = i(b);
|
|
324
|
+
if (!r) throw Error("[i18n-micro] I18nT: i18n instance not found. Make sure i18n plugin is installed.");
|
|
325
|
+
return y(J, r, e, t, n);
|
|
326
|
+
}, {
|
|
327
|
+
displayName: "I18nT",
|
|
276
328
|
inheritAttrs: !1,
|
|
277
329
|
props: {
|
|
278
330
|
keypath: {
|
|
@@ -284,10 +336,7 @@ var p = Symbol("i18n"), m = Symbol("i18n-locales"), h = Symbol("i18n-default-loc
|
|
|
284
336
|
type: String,
|
|
285
337
|
default: "span"
|
|
286
338
|
},
|
|
287
|
-
params: {
|
|
288
|
-
type: Object,
|
|
289
|
-
default: () => ({})
|
|
290
|
-
},
|
|
339
|
+
params: { type: Object },
|
|
291
340
|
defaultValue: {
|
|
292
341
|
type: String,
|
|
293
342
|
default: ""
|
|
@@ -315,139 +364,19 @@ var p = Symbol("i18n"), m = Symbol("i18n-locales"), h = Symbol("i18n-default-loc
|
|
|
315
364
|
String,
|
|
316
365
|
Number
|
|
317
366
|
] }
|
|
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, f = Object.entries(t).filter(([e]) => e !== "default").map(([e, t]) => {
|
|
365
|
-
let n = `{${e}}`;
|
|
366
|
-
return {
|
|
367
|
-
placeholder: n,
|
|
368
|
-
slotFn: t,
|
|
369
|
-
index: l.indexOf(n)
|
|
370
|
-
};
|
|
371
|
-
}).filter(({ index: e }) => e !== -1).sort((e, t) => e.index - t.index);
|
|
372
|
-
for (let { placeholder: e, slotFn: t, index: r } of f) r > d && u.push(l.slice(d, r)), t && u.push(n(t)), d = r + e.length;
|
|
373
|
-
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);
|
|
374
|
-
};
|
|
375
367
|
}
|
|
376
368
|
});
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
return e.iso?.trim() || String(e.code);
|
|
381
|
-
}
|
|
382
|
-
function S(e) {
|
|
383
|
-
let t = e.match(/^([A-Za-z]{2,3})(?:[-_](.+))?$/);
|
|
384
|
-
return t ? {
|
|
385
|
-
language: t[1],
|
|
386
|
-
region: t[2]
|
|
387
|
-
} : { language: e };
|
|
388
|
-
}
|
|
389
|
-
function C(e, t = {}) {
|
|
390
|
-
let { hreflangBaseLanguage: n = !1 } = t;
|
|
391
|
-
if (!n) return e.map((e) => {
|
|
392
|
-
let t = String(e.code);
|
|
393
|
-
return {
|
|
394
|
-
hreflang: x(e),
|
|
395
|
-
localeCode: t
|
|
396
|
-
};
|
|
397
|
-
});
|
|
398
|
-
let r = /* @__PURE__ */ new Map();
|
|
399
|
-
for (let t of e) {
|
|
400
|
-
let e = String(t.code), n = x(t), { language: i, region: a } = S(n);
|
|
401
|
-
i && a && !r.has(i) && r.set(i, e), r.set(n, e);
|
|
402
|
-
}
|
|
403
|
-
let i = /* @__PURE__ */ new Set(), a = [];
|
|
404
|
-
for (let t of e) {
|
|
405
|
-
let e = String(t.code), n = x(t), { language: o, region: s } = S(n);
|
|
406
|
-
o && s && r.get(o) === e && !i.has(o) && (i.add(o), a.push({
|
|
407
|
-
hreflang: o,
|
|
408
|
-
localeCode: e
|
|
409
|
-
})), i.has(n) || (i.add(n), a.push({
|
|
410
|
-
hreflang: n,
|
|
411
|
-
localeCode: e
|
|
412
|
-
}));
|
|
413
|
-
}
|
|
414
|
-
return a;
|
|
415
|
-
}
|
|
416
|
-
//#endregion
|
|
417
|
-
//#region ../utils/dist/resolve-og-locale.mjs
|
|
418
|
-
function w(e) {
|
|
419
|
-
let t = e.og?.trim();
|
|
420
|
-
if (t) return t;
|
|
421
|
-
let n = e.iso?.trim();
|
|
422
|
-
if (!n) return null;
|
|
423
|
-
let r = n.indexOf("_");
|
|
424
|
-
if (r > 0) {
|
|
425
|
-
let e = n.slice(0, r), t = n.slice(r + 1);
|
|
426
|
-
if (e.length >= 2 && t.length === 2) return `${e.toLowerCase()}_${t.toUpperCase()}`;
|
|
427
|
-
}
|
|
428
|
-
let i = n.indexOf("-");
|
|
429
|
-
if (i > 0) {
|
|
430
|
-
let e = n.slice(0, i), t = n.slice(i + 1);
|
|
431
|
-
if (e.length >= 2 && t.length === 2 && /^[A-Za-z]{2}$/.test(t)) return `${e.toLowerCase()}_${t.toUpperCase()}`;
|
|
432
|
-
}
|
|
433
|
-
return null;
|
|
434
|
-
}
|
|
435
|
-
function T(e, t = {}) {
|
|
436
|
-
if (w(e) !== null || t.missingWarn === !1 || process.env.NODE_ENV === "production") return;
|
|
437
|
-
let n = t.tag ?? "og:locale", r = String(e.code ?? "unknown"), i = e.iso ? `, iso: '${e.iso}'` : "";
|
|
438
|
-
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').`);
|
|
439
|
-
}
|
|
440
|
-
//#endregion
|
|
441
|
-
//#region src/use-i18n.ts
|
|
442
|
-
function E(t) {
|
|
443
|
-
let n = r(p), i = r(g, void 0), a = r(m, void 0), o = r(h, void 0);
|
|
369
|
+
// src/use-i18n.ts
|
|
370
|
+
function X(e) {
|
|
371
|
+
let n = i(b), r = i(C, void 0), a = i(x, void 0), o = i(S, void 0);
|
|
444
372
|
if (!n) throw Error("[i18n-micro] useI18n() must be called after app.use(i18n). Make sure i18n plugin is installed.");
|
|
445
|
-
|
|
446
|
-
if (!
|
|
447
|
-
|
|
373
|
+
let s = e?.locales || a, c = e?.defaultLocale || o;
|
|
374
|
+
if (!s) throw Error("[i18n-micro] I18nLocalesKey not provided. Make sure app.provide(I18nLocalesKey, locales) is called.");
|
|
375
|
+
if (!c) throw Error("[i18n-micro] I18nDefaultLocaleKey not provided. Make sure app.provide(I18nDefaultLocaleKey, defaultLocale) is called.");
|
|
376
|
+
let l = (e, t) => r?.resolvePath ? r.resolvePath(e, t || n.locale.value) : e;
|
|
448
377
|
return {
|
|
449
378
|
instance: n,
|
|
450
|
-
locale:
|
|
379
|
+
locale: t({
|
|
451
380
|
get: () => n.locale.value,
|
|
452
381
|
set: (e) => {
|
|
453
382
|
n.locale.value = e;
|
|
@@ -457,15 +386,10 @@ function E(t) {
|
|
|
457
386
|
defaultLocale: () => c,
|
|
458
387
|
getLocaleName: () => s.find((e) => e.code === n.locale.value)?.displayName || null,
|
|
459
388
|
localeRoute: l,
|
|
460
|
-
localePath: (e, t) =>
|
|
461
|
-
let n = l(e, t);
|
|
462
|
-
return typeof n == "string" ? n : n.path || "/";
|
|
463
|
-
},
|
|
389
|
+
localePath: (e, t) => U(l(e, t)),
|
|
464
390
|
switchLocale: (e) => {
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
i.push(typeof n == "string" ? { path: n } : { path: n.path || "/" });
|
|
468
|
-
}
|
|
391
|
+
let t = r && U(l(W(r), e));
|
|
392
|
+
n.locale.value = e, t && r.push({ path: t });
|
|
469
393
|
},
|
|
470
394
|
t: n.t.bind(n),
|
|
471
395
|
ts: n.ts.bind(n),
|
|
@@ -485,129 +409,61 @@ function E(t) {
|
|
|
485
409
|
clearCache: n.clearCache.bind(n)
|
|
486
410
|
};
|
|
487
411
|
}
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
function
|
|
491
|
-
let { addDirAttribute: t = !0, identifierAttribute: n = "id", addSeoAttributes:
|
|
412
|
+
// src/composables/use-locale-head.ts
|
|
413
|
+
var Z = (e) => e.startsWith("http://") || e.startsWith("https://");
|
|
414
|
+
function Q(e = {}) {
|
|
415
|
+
let { addDirAttribute: t = !0, identifierAttribute: n = "id", addSeoAttributes: r = !0, baseUrl: a = "/", hreflangBaseLanguage: o = !1 } = e, { getLocale: c, getLocales: l, localeRoute: u } = X(), d = i(C, void 0), f = i(S, void 0), p = s({
|
|
492
416
|
htmlAttrs: {},
|
|
493
417
|
link: [],
|
|
494
418
|
meta: []
|
|
495
419
|
});
|
|
496
|
-
function p(e, t) {
|
|
497
|
-
let n = new URL(e, "http://localhost"), r = new URLSearchParams(n.search), i = {};
|
|
498
|
-
for (let e of t) r.has(e) && (i[e] = r.get(e));
|
|
499
|
-
let a = new URLSearchParams(i);
|
|
500
|
-
return a.toString() ? `${n.pathname}?${a.toString()}` : n.pathname;
|
|
501
|
-
}
|
|
502
420
|
function m(e = []) {
|
|
503
421
|
if (!d) {
|
|
504
|
-
|
|
422
|
+
p.value = {
|
|
505
423
|
htmlAttrs: {},
|
|
506
424
|
link: [],
|
|
507
425
|
meta: []
|
|
508
426
|
};
|
|
509
427
|
return;
|
|
510
428
|
}
|
|
511
|
-
let
|
|
512
|
-
if (!
|
|
513
|
-
let
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
}
|
|
529
|
-
let j = m.filter((e) => !e.disabled && e.seo !== !1);
|
|
530
|
-
v || T(g, { tag: "og:locale" });
|
|
531
|
-
let M = v ? {
|
|
532
|
-
[n]: "i18n-og",
|
|
533
|
-
property: "og:locale",
|
|
534
|
-
content: v
|
|
535
|
-
} : null, N = {
|
|
536
|
-
[n]: "i18n-og-url",
|
|
537
|
-
property: "og:url",
|
|
538
|
-
content: O
|
|
539
|
-
}, P = j.filter((e) => e.code !== s).map((e) => {
|
|
540
|
-
let t = w(e);
|
|
541
|
-
return t ? {
|
|
542
|
-
[n]: `i18n-og-alt-${t}`,
|
|
543
|
-
property: "og:locale:alternate",
|
|
544
|
-
content: t
|
|
545
|
-
} : (T(e, { tag: "og:locale:alternate" }), null);
|
|
546
|
-
}).filter((e) => e !== null), F = {
|
|
547
|
-
[n]: "i18n-can",
|
|
548
|
-
rel: "canonical",
|
|
549
|
-
href: O
|
|
550
|
-
}, I = (() => {
|
|
551
|
-
if (!u || !d) return [];
|
|
552
|
-
let e = /* @__PURE__ */ new Map(), t = d.getCurrentPath();
|
|
553
|
-
for (let n of j) {
|
|
554
|
-
let r = u(t, n.code), i = typeof r == "string" ? r : r?.path || "/";
|
|
555
|
-
if (!i) continue;
|
|
556
|
-
let o;
|
|
557
|
-
o = i.startsWith("http://") || i.startsWith("https://") ? i : `${typeof a == "function" ? a() : a}${i.startsWith("/") ? "" : "/"}${i}`, e.set(String(n.code), o);
|
|
558
|
-
}
|
|
559
|
-
return C(j, { hreflangBaseLanguage: o }).flatMap(({ hreflang: t, localeCode: r }) => {
|
|
560
|
-
let i = e.get(r);
|
|
561
|
-
return i ? [{
|
|
562
|
-
[n]: `i18n-alternate-${t}`,
|
|
563
|
-
rel: "alternate",
|
|
564
|
-
href: i,
|
|
565
|
-
hreflang: t
|
|
566
|
-
}] : [];
|
|
567
|
-
});
|
|
568
|
-
})(), L = r(h, void 0), R = null, z = L ? m.find((e) => e.code === L) : void 0;
|
|
569
|
-
if (u && d && L && z?.seo !== !1) {
|
|
570
|
-
let e = d.getCurrentPath(), t = u(e, L), r = typeof t == "string" ? t : t?.path || "/";
|
|
571
|
-
if (r) {
|
|
572
|
-
let e;
|
|
573
|
-
e = r.startsWith("http://") || r.startsWith("https://") ? r : `${typeof a == "function" ? a() : a}${r.startsWith("/") ? "" : "/"}${r}`, R = {
|
|
574
|
-
[n]: "i18n-xd",
|
|
575
|
-
rel: "alternate",
|
|
576
|
-
href: e,
|
|
577
|
-
hreflang: "x-default"
|
|
578
|
-
};
|
|
579
|
-
}
|
|
580
|
-
}
|
|
581
|
-
f.value = {
|
|
582
|
-
htmlAttrs: A,
|
|
583
|
-
meta: [
|
|
584
|
-
...M ? [M] : [],
|
|
585
|
-
N,
|
|
586
|
-
...P
|
|
587
|
-
],
|
|
588
|
-
link: [
|
|
589
|
-
F,
|
|
590
|
-
...I,
|
|
591
|
-
...R ? [R] : []
|
|
592
|
-
]
|
|
593
|
-
};
|
|
429
|
+
let i = l(), s = i.find((e) => e.code === c());
|
|
430
|
+
if (!s) return;
|
|
431
|
+
let m = typeof a == "function" ? a() : a, h = _(d.getCurrentPath()) || "/", g = N(W(d), e), v = g.indexOf("?"), y = v === -1 ? "" : g.slice(v), b = (e) => {
|
|
432
|
+
let t = U(u(h, e));
|
|
433
|
+
return t ? `${Z(t) ? t : F(m, t)}${y}` : "";
|
|
434
|
+
}, x = i.find((e) => e.code === f);
|
|
435
|
+
p.value = H({
|
|
436
|
+
locale: s,
|
|
437
|
+
seoLocales: i.filter((e) => !e.disabled && e.seo !== !1),
|
|
438
|
+
hrefOf: b,
|
|
439
|
+
canonical: b(s.code),
|
|
440
|
+
xDefault: x && x.seo !== !1 ? b(x.code) : void 0,
|
|
441
|
+
addDirAttribute: t,
|
|
442
|
+
addSeoAttributes: r,
|
|
443
|
+
identifierAttribute: n,
|
|
444
|
+
hreflangBaseLanguage: o
|
|
445
|
+
});
|
|
594
446
|
}
|
|
595
447
|
return {
|
|
596
|
-
metaObject:
|
|
448
|
+
metaObject: p,
|
|
597
449
|
updateMeta: m
|
|
598
450
|
};
|
|
599
451
|
}
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
var O = class extends l {
|
|
452
|
+
// src/composer.ts
|
|
453
|
+
var $ = class extends l {
|
|
603
454
|
constructor(e) {
|
|
604
455
|
let t = { translations: /* @__PURE__ */ new Map() };
|
|
605
|
-
|
|
456
|
+
super({
|
|
606
457
|
storage: t,
|
|
607
458
|
plural: e.plural,
|
|
608
459
|
missingWarn: e.missingWarn,
|
|
609
|
-
missingHandler: e.missingHandler
|
|
610
|
-
|
|
460
|
+
missingHandler: e.missingHandler,
|
|
461
|
+
numberFormats: e.numberFormats,
|
|
462
|
+
datetimeFormats: e.datetimeFormats,
|
|
463
|
+
timeZone: e.timeZone,
|
|
464
|
+
localeIso: e.localeIso
|
|
465
|
+
}), 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);
|
|
466
|
+
for (let [t, n] of Object.entries(e.messages ?? {})) this.helper.mergeTranslation(t, "index", n);
|
|
611
467
|
}
|
|
612
468
|
get locale() {
|
|
613
469
|
return this._locale;
|
|
@@ -637,16 +493,16 @@ var O = class extends l {
|
|
|
637
493
|
return this._currentRoute.value;
|
|
638
494
|
}
|
|
639
495
|
addTranslations(e, t, n = !0) {
|
|
640
|
-
|
|
496
|
+
this.loadTranslationsCore(e, t, n);
|
|
641
497
|
}
|
|
642
498
|
addRouteTranslations(e, t, n, r = !0) {
|
|
643
|
-
|
|
499
|
+
this.loadTranslationsCore(e, n, r, t);
|
|
644
500
|
}
|
|
645
501
|
mergeTranslations(e, t, n) {
|
|
646
|
-
this.
|
|
502
|
+
this.loadTranslationsCore(e, n, !0, t);
|
|
647
503
|
}
|
|
648
|
-
|
|
649
|
-
|
|
504
|
+
touch() {
|
|
505
|
+
this._revision.value;
|
|
650
506
|
}
|
|
651
507
|
onTranslationsChanged() {
|
|
652
508
|
this._revision.value++, this.notifyListeners();
|
|
@@ -655,7 +511,11 @@ var O = class extends l {
|
|
|
655
511
|
return this.listeners.add(e), () => this.listeners.delete(e);
|
|
656
512
|
}
|
|
657
513
|
notifyListeners() {
|
|
658
|
-
this.listeners.
|
|
514
|
+
for (let e of [...this.listeners]) if (this.listeners.has(e)) try {
|
|
515
|
+
e();
|
|
516
|
+
} catch (e) {
|
|
517
|
+
console.error("[i18n-micro] change listener failed:", e);
|
|
518
|
+
}
|
|
659
519
|
}
|
|
660
520
|
getStorage() {
|
|
661
521
|
return this.storage;
|
|
@@ -666,21 +526,22 @@ var O = class extends l {
|
|
|
666
526
|
return e;
|
|
667
527
|
}
|
|
668
528
|
};
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
529
|
+
// src/plugin.ts
|
|
530
|
+
function te(e) {
|
|
531
|
+
let { routingStrategy: t, locales: n, defaultLocale: r, ...i } = e, a = new $({
|
|
532
|
+
localeIso: n && g(n),
|
|
533
|
+
...i
|
|
534
|
+
}), o = null, s = t || null;
|
|
673
535
|
return {
|
|
674
536
|
global: a,
|
|
675
537
|
setRoutingStrategy: (e) => {
|
|
676
|
-
s = e, o && o.provide(
|
|
538
|
+
s = e, o && o.provide(C, e);
|
|
677
539
|
},
|
|
678
540
|
install(e) {
|
|
679
|
-
o = e, e.provide(
|
|
541
|
+
o = e, e.provide(b, a), s && e.provide(C, s), n && e.provide(x, n), r && e.provide(S, 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", Y), e.component("I18nLink", G), e.component("I18nGroup", w), e.component("I18nSwitcher", q);
|
|
680
542
|
}
|
|
681
543
|
};
|
|
682
544
|
}
|
|
683
|
-
|
|
684
|
-
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 };
|
|
545
|
+
export { u as FormatService, S as I18nDefaultLocaleKey, w as I18nGroup, b as I18nInjectionKey, G as I18nLink, x as I18nLocalesKey, q as I18nSwitcher, Y as I18nT, $ as VueI18n, te as createI18n, d as defaultPlural, p as interpolate, X as useI18n, Q as useLocaleHead };
|
|
685
546
|
|
|
686
547
|
//# sourceMappingURL=index.mjs.map
|