@prefabs.tech/vue3-i18n 0.13.0 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/PrefabsTechVue3I18n.es.js +178 -158
- package/dist/PrefabsTechVue3I18n.umd.js +1 -1
- package/dist/src/locale-switcher/Index.vue.d.ts +13 -1
- package/dist/src/locale-switcher/Index.vue.d.ts.map +1 -1
- package/dist/src/locale-switcher/LocaleOption.vue.d.ts +11 -1
- package/dist/src/locale-switcher/LocaleOption.vue.d.ts.map +1 -1
- package/dist/vue3-i18n.css +1 -1
- package/package.json +4 -3
|
@@ -1,145 +1,144 @@
|
|
|
1
|
-
import { useI18n as
|
|
2
|
-
import { useI18n as
|
|
3
|
-
import { watch as D, getCurrentScope as
|
|
4
|
-
import { useConfig as
|
|
5
|
-
const Y = "data:image/svg+xml,%3c?xml%20version='1.0'%20?%3e%3c!--%20Uploaded%20to:%20SVG%20Repo,%20www.svgrepo.com,%20Generator:%20SVG%20Repo%20Mixer%20Tools%20--%3e%3csvg%20width='800px'%20height='800px'%20viewBox='0%200%2024%2024'%20xmlns='http://www.w3.org/2000/svg'%3e%3ctitle/%3e%3cg%20id='Complete'%3e%3cg%20id='F-Chevron'%3e%3cpolyline%20fill='none'%20id='Down'%20points='5%208.5%2012%2015.5%2019%208.5'%20stroke='%23000000'%20stroke-linecap='round'%20stroke-linejoin='round'%20stroke-width='2'/%3e%3c/g%3e%3c/g%3e%3c/svg%3e";
|
|
1
|
+
import { useI18n as G, createI18n as z } from "vue-i18n";
|
|
2
|
+
import { useI18n as Pe } from "vue-i18n";
|
|
3
|
+
import { watch as D, getCurrentScope as R, onScopeDispose as U, computed as I, toValue as v, unref as N, defineComponent as A, createElementBlock as L, openBlock as _, createTextVNode as V, createCommentVNode as j, toDisplayString as E, createBlock as H, ref as P, normalizeClass as T, createElementVNode as w, renderSlot as J, Fragment as K, renderList as Q, createVNode as X } from "vue";
|
|
4
|
+
import { useConfig as Y } from "@prefabs.tech/vue3-config";
|
|
6
5
|
function Z(e) {
|
|
7
|
-
return
|
|
6
|
+
return R() ? (U(e), !0) : !1;
|
|
8
7
|
}
|
|
9
|
-
const
|
|
8
|
+
const W = typeof window < "u" && typeof document < "u";
|
|
10
9
|
typeof WorkerGlobalScope < "u" && globalThis instanceof WorkerGlobalScope;
|
|
11
|
-
const ee = Object.prototype.toString, te = (e) => ee.call(e) === "[object Object]",
|
|
12
|
-
},
|
|
13
|
-
function
|
|
10
|
+
const ee = Object.prototype.toString, te = (e) => ee.call(e) === "[object Object]", y = () => {
|
|
11
|
+
}, ne = /* @__PURE__ */ oe();
|
|
12
|
+
function oe() {
|
|
14
13
|
var e, t;
|
|
15
|
-
return
|
|
14
|
+
return W && ((e = window?.navigator) == null ? void 0 : e.userAgent) && (/iP(?:ad|hone|od)/.test(window.navigator.userAgent) || ((t = window?.navigator) == null ? void 0 : t.maxTouchPoints) > 2 && /iPad|Macintosh/.test(window?.navigator.userAgent));
|
|
16
15
|
}
|
|
17
|
-
function
|
|
16
|
+
function B(e) {
|
|
18
17
|
return Array.isArray(e) ? e : [e];
|
|
19
18
|
}
|
|
20
|
-
function le(e, t,
|
|
19
|
+
function le(e, t, n) {
|
|
21
20
|
return D(
|
|
22
21
|
e,
|
|
23
22
|
t,
|
|
24
23
|
{
|
|
25
|
-
...
|
|
24
|
+
...n,
|
|
26
25
|
immediate: !0
|
|
27
26
|
}
|
|
28
27
|
);
|
|
29
28
|
}
|
|
30
|
-
const
|
|
29
|
+
const q = W ? window : void 0;
|
|
31
30
|
function b(e) {
|
|
32
31
|
var t;
|
|
33
|
-
const
|
|
34
|
-
return (t =
|
|
32
|
+
const n = v(e);
|
|
33
|
+
return (t = n?.$el) != null ? t : n;
|
|
35
34
|
}
|
|
36
|
-
function
|
|
37
|
-
const t = [],
|
|
35
|
+
function S(...e) {
|
|
36
|
+
const t = [], n = () => {
|
|
38
37
|
t.forEach((a) => a()), t.length = 0;
|
|
39
|
-
},
|
|
40
|
-
const a =
|
|
38
|
+
}, o = (a, r, u, p) => (a.addEventListener(r, u, p), () => a.removeEventListener(r, u, p)), l = I(() => {
|
|
39
|
+
const a = B(v(e[0])).filter((r) => r != null);
|
|
41
40
|
return a.every((r) => typeof r != "string") ? a : void 0;
|
|
42
|
-
}),
|
|
41
|
+
}), c = le(
|
|
43
42
|
() => {
|
|
44
43
|
var a, r;
|
|
45
44
|
return [
|
|
46
|
-
(r = (a = l.value) == null ? void 0 : a.map((u) => b(u))) != null ? r : [
|
|
47
|
-
|
|
48
|
-
|
|
45
|
+
(r = (a = l.value) == null ? void 0 : a.map((u) => b(u))) != null ? r : [q].filter((u) => u != null),
|
|
46
|
+
B(v(l.value ? e[1] : e[0])),
|
|
47
|
+
B(N(l.value ? e[2] : e[1])),
|
|
49
48
|
// @ts-expect-error - TypeScript gets the correct types, but somehow still complains
|
|
50
|
-
|
|
49
|
+
v(l.value ? e[3] : e[2])
|
|
51
50
|
];
|
|
52
51
|
},
|
|
53
|
-
([a, r, u,
|
|
54
|
-
if (
|
|
52
|
+
([a, r, u, p]) => {
|
|
53
|
+
if (n(), !a?.length || !r?.length || !u?.length)
|
|
55
54
|
return;
|
|
56
|
-
const
|
|
55
|
+
const g = te(p) ? { ...p } : p;
|
|
57
56
|
t.push(
|
|
58
57
|
...a.flatMap(
|
|
59
|
-
(
|
|
60
|
-
(
|
|
58
|
+
(h) => r.flatMap(
|
|
59
|
+
(m) => u.map((k) => o(h, m, k, g))
|
|
61
60
|
)
|
|
62
61
|
)
|
|
63
62
|
);
|
|
64
63
|
},
|
|
65
64
|
{ flush: "post" }
|
|
66
|
-
),
|
|
67
|
-
|
|
65
|
+
), f = () => {
|
|
66
|
+
c(), n();
|
|
68
67
|
};
|
|
69
|
-
return Z(
|
|
68
|
+
return Z(n), f;
|
|
70
69
|
}
|
|
71
|
-
let
|
|
72
|
-
function
|
|
73
|
-
const { window:
|
|
74
|
-
if (!
|
|
75
|
-
return a ? { stop:
|
|
76
|
-
if (
|
|
77
|
-
|
|
78
|
-
const
|
|
79
|
-
Array.from(
|
|
70
|
+
let M = !1;
|
|
71
|
+
function se(e, t, n = {}) {
|
|
72
|
+
const { window: o = q, ignore: l = [], capture: c = !0, detectIframe: f = !1, controls: a = !1 } = n;
|
|
73
|
+
if (!o)
|
|
74
|
+
return a ? { stop: y, cancel: y, trigger: y } : y;
|
|
75
|
+
if (ne && !M) {
|
|
76
|
+
M = !0;
|
|
77
|
+
const s = { passive: !0 };
|
|
78
|
+
Array.from(o.document.body.children).forEach((i) => S(i, "click", y, s)), S(o.document.documentElement, "click", y, s);
|
|
80
79
|
}
|
|
81
80
|
let r = !0;
|
|
82
|
-
const u = (
|
|
81
|
+
const u = (s) => v(l).some((i) => {
|
|
83
82
|
if (typeof i == "string")
|
|
84
|
-
return Array.from(
|
|
83
|
+
return Array.from(o.document.querySelectorAll(i)).some((d) => d === s.target || s.composedPath().includes(d));
|
|
85
84
|
{
|
|
86
85
|
const d = b(i);
|
|
87
|
-
return d && (
|
|
86
|
+
return d && (s.target === d || s.composedPath().includes(d));
|
|
88
87
|
}
|
|
89
88
|
});
|
|
90
|
-
function
|
|
91
|
-
const i =
|
|
89
|
+
function p(s) {
|
|
90
|
+
const i = v(s);
|
|
92
91
|
return i && i.$.subTree.shapeFlag === 16;
|
|
93
92
|
}
|
|
94
|
-
function
|
|
95
|
-
const d =
|
|
96
|
-
return
|
|
93
|
+
function g(s, i) {
|
|
94
|
+
const d = v(s), $ = d.$.subTree && d.$.subTree.children;
|
|
95
|
+
return $ == null || !Array.isArray($) ? !1 : $.some((x) => x.el === i.target || i.composedPath().includes(x.el));
|
|
97
96
|
}
|
|
98
|
-
const
|
|
97
|
+
const h = (s) => {
|
|
99
98
|
const i = b(e);
|
|
100
|
-
if (
|
|
101
|
-
if ("detail" in
|
|
99
|
+
if (s.target != null && !(!(i instanceof Element) && p(e) && g(e, s)) && !(!i || i === s.target || s.composedPath().includes(i))) {
|
|
100
|
+
if ("detail" in s && s.detail === 0 && (r = !u(s)), !r) {
|
|
102
101
|
r = !0;
|
|
103
102
|
return;
|
|
104
103
|
}
|
|
105
|
-
t(
|
|
104
|
+
t(s);
|
|
106
105
|
}
|
|
107
106
|
};
|
|
108
|
-
let
|
|
107
|
+
let m = !1;
|
|
109
108
|
const k = [
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
}, 0),
|
|
114
|
-
}, { passive: !0, capture:
|
|
115
|
-
|
|
109
|
+
S(o, "click", (s) => {
|
|
110
|
+
m || (m = !0, setTimeout(() => {
|
|
111
|
+
m = !1;
|
|
112
|
+
}, 0), h(s));
|
|
113
|
+
}, { passive: !0, capture: c }),
|
|
114
|
+
S(o, "pointerdown", (s) => {
|
|
116
115
|
const i = b(e);
|
|
117
|
-
r = !u(
|
|
116
|
+
r = !u(s) && !!(i && !s.composedPath().includes(i));
|
|
118
117
|
}, { passive: !0 }),
|
|
119
|
-
|
|
118
|
+
f && S(o, "blur", (s) => {
|
|
120
119
|
setTimeout(() => {
|
|
121
120
|
var i;
|
|
122
121
|
const d = b(e);
|
|
123
|
-
((i =
|
|
122
|
+
((i = o.document.activeElement) == null ? void 0 : i.tagName) === "IFRAME" && !d?.contains(o.document.activeElement) && t(s);
|
|
124
123
|
}, 0);
|
|
125
124
|
}, { passive: !0 })
|
|
126
|
-
].filter(Boolean),
|
|
125
|
+
].filter(Boolean), O = () => k.forEach((s) => s());
|
|
127
126
|
return a ? {
|
|
128
|
-
stop:
|
|
127
|
+
stop: O,
|
|
129
128
|
cancel: () => {
|
|
130
129
|
r = !1;
|
|
131
130
|
},
|
|
132
|
-
trigger: (
|
|
133
|
-
r = !0,
|
|
131
|
+
trigger: (s) => {
|
|
132
|
+
r = !0, h(s), r = !1;
|
|
134
133
|
}
|
|
135
|
-
} :
|
|
134
|
+
} : O;
|
|
136
135
|
}
|
|
137
|
-
const
|
|
136
|
+
const ce = { class: "badge" }, re = {
|
|
138
137
|
key: 0,
|
|
139
138
|
class: "country"
|
|
140
139
|
}, ae = {
|
|
141
140
|
name: "LocaleBadge"
|
|
142
|
-
}, ie = /* @__PURE__ */
|
|
141
|
+
}, ie = /* @__PURE__ */ A({
|
|
143
142
|
...ae,
|
|
144
143
|
props: {
|
|
145
144
|
locale: {
|
|
@@ -148,25 +147,25 @@ const se = { class: "badge" }, re = {
|
|
|
148
147
|
}
|
|
149
148
|
},
|
|
150
149
|
setup(e) {
|
|
151
|
-
const t = e,
|
|
150
|
+
const t = e, n = I(() => t.locale.substring(0, 2)), o = I(() => {
|
|
152
151
|
const l = t.locale.split("-");
|
|
153
152
|
if (l.length > 1)
|
|
154
153
|
return l[1];
|
|
155
154
|
});
|
|
156
|
-
return (l,
|
|
157
|
-
|
|
158
|
-
|
|
155
|
+
return (l, c) => (_(), L("span", ce, [
|
|
156
|
+
V(E(n.value) + " ", 1),
|
|
157
|
+
o.value ? (_(), L("span", re, E(o.value), 1)) : j("", !0)
|
|
159
158
|
]));
|
|
160
159
|
}
|
|
161
|
-
}),
|
|
162
|
-
const
|
|
163
|
-
for (const [
|
|
164
|
-
o
|
|
165
|
-
return
|
|
166
|
-
}, ue = /* @__PURE__ */
|
|
160
|
+
}), C = (e, t) => {
|
|
161
|
+
const n = e.__vccOpts || e;
|
|
162
|
+
for (const [o, l] of t)
|
|
163
|
+
n[o] = l;
|
|
164
|
+
return n;
|
|
165
|
+
}, ue = /* @__PURE__ */ C(ie, [["__scopeId", "data-v-c1291edf"]]), de = { class: "locale" }, fe = {
|
|
167
166
|
name: "LocaleOption"
|
|
168
|
-
},
|
|
169
|
-
...
|
|
167
|
+
}, pe = /* @__PURE__ */ A({
|
|
168
|
+
...fe,
|
|
170
169
|
props: {
|
|
171
170
|
locale: {
|
|
172
171
|
required: !0,
|
|
@@ -175,15 +174,22 @@ const se = { class: "badge" }, re = {
|
|
|
175
174
|
name: {
|
|
176
175
|
required: !0,
|
|
177
176
|
type: String
|
|
177
|
+
},
|
|
178
|
+
showBadges: {
|
|
179
|
+
default: !0,
|
|
180
|
+
type: Boolean
|
|
178
181
|
}
|
|
179
182
|
},
|
|
180
183
|
setup(e) {
|
|
181
|
-
return (t,
|
|
182
|
-
|
|
183
|
-
|
|
184
|
+
return (t, n) => (_(), L("div", de, [
|
|
185
|
+
e.showBadges ? (_(), H(ue, {
|
|
186
|
+
key: 0,
|
|
187
|
+
locale: e.locale
|
|
188
|
+
}, null, 8, ["locale"])) : j("", !0),
|
|
189
|
+
V(" " + E(e.name), 1)
|
|
184
190
|
]));
|
|
185
191
|
}
|
|
186
|
-
}),
|
|
192
|
+
}), ge = /* @__PURE__ */ C(pe, [["__scopeId", "data-v-3d8a4124"]]), F = (e) => {
|
|
187
193
|
const t = `${e}.locale`;
|
|
188
194
|
return { getLocale: () => {
|
|
189
195
|
const l = localStorage.getItem(t);
|
|
@@ -191,131 +197,145 @@ const se = { class: "badge" }, re = {
|
|
|
191
197
|
}, setLocale: (l) => {
|
|
192
198
|
l ? localStorage.setItem(t, l) : localStorage.removeItem(t);
|
|
193
199
|
} };
|
|
194
|
-
},
|
|
200
|
+
}, me = { class: "locale truncated" }, he = { class: "truncated" }, ve = { class: "dropdown" }, _e = ["onClick"], we = {
|
|
195
201
|
name: "LocaleSwitcher"
|
|
196
|
-
}, ye = /* @__PURE__ */
|
|
202
|
+
}, ye = /* @__PURE__ */ A({
|
|
197
203
|
...we,
|
|
204
|
+
props: {
|
|
205
|
+
showBadges: {
|
|
206
|
+
default: !0,
|
|
207
|
+
type: Boolean
|
|
208
|
+
}
|
|
209
|
+
},
|
|
198
210
|
setup(e) {
|
|
199
|
-
const { availableLocales: t, locale:
|
|
200
|
-
|
|
201
|
-
const { setLocale:
|
|
202
|
-
|
|
211
|
+
const { availableLocales: t, locale: n, t: o } = G(), l = Y(), c = P(!1), f = (g) => {
|
|
212
|
+
n.value = g, c.value = !1;
|
|
213
|
+
const { setLocale: h } = F(l.slug);
|
|
214
|
+
h(g);
|
|
203
215
|
}, a = I(() => ({
|
|
204
|
-
locale:
|
|
205
|
-
name: u(
|
|
216
|
+
locale: n.value,
|
|
217
|
+
name: u(n.value)
|
|
206
218
|
})), r = () => {
|
|
207
|
-
|
|
208
|
-
}, u = (
|
|
209
|
-
return
|
|
210
|
-
|
|
211
|
-
}), (
|
|
219
|
+
c.value = !c.value;
|
|
220
|
+
}, u = (g) => o(`locales.${g}`), p = P(null);
|
|
221
|
+
return se(p, (g) => {
|
|
222
|
+
c.value = !1;
|
|
223
|
+
}), (g, h) => (_(), L("nav", {
|
|
212
224
|
ref_key: "dzangolabVueI18nLocaleSwitcher",
|
|
213
|
-
ref:
|
|
214
|
-
class:
|
|
225
|
+
ref: p,
|
|
226
|
+
class: T(["locale-switcher", { expanded: c.value }])
|
|
215
227
|
}, [
|
|
216
|
-
|
|
228
|
+
w("div", {
|
|
217
229
|
class: "locale-trigger",
|
|
218
230
|
onClick: r
|
|
219
231
|
}, [
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
J(
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
232
|
+
w("div", me, E(a.value.name), 1),
|
|
233
|
+
w("span", he, [
|
|
234
|
+
J(g.$slots, "icon", {}, () => [
|
|
235
|
+
h[0] || (h[0] = w("svg", {
|
|
236
|
+
height: "24",
|
|
237
|
+
viewBox: "0 0 24 24",
|
|
238
|
+
width: "24",
|
|
239
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
240
|
+
}, [
|
|
241
|
+
w("path", {
|
|
242
|
+
d: "M12 15.25a.74.74 0 0 1-.53-.22l-5-5A.75.75 0 0 1 7.53 9L12 13.44L16.47 9a.75.75 0 0 1 1.06 1l-5 5a.74.74 0 0 1-.53.25",
|
|
243
|
+
fill: "currentColor"
|
|
244
|
+
})
|
|
245
|
+
], -1))
|
|
227
246
|
], !0)
|
|
228
247
|
])
|
|
229
248
|
]),
|
|
230
|
-
|
|
231
|
-
(
|
|
232
|
-
key:
|
|
233
|
-
class:
|
|
234
|
-
onClick: (k) =>
|
|
249
|
+
w("ul", ve, [
|
|
250
|
+
(_(!0), L(K, null, Q(N(t), (m) => (_(), L("li", {
|
|
251
|
+
key: m,
|
|
252
|
+
class: T([{ current: m === a.value.locale }, "truncated"]),
|
|
253
|
+
onClick: (k) => f(m)
|
|
235
254
|
}, [
|
|
236
|
-
|
|
237
|
-
locale:
|
|
238
|
-
name: u(
|
|
239
|
-
|
|
255
|
+
X(ge, {
|
|
256
|
+
locale: m,
|
|
257
|
+
name: u(m),
|
|
258
|
+
"show-badges": e.showBadges
|
|
259
|
+
}, null, 8, ["locale", "name", "show-badges"])
|
|
240
260
|
], 10, _e))), 128))
|
|
241
261
|
])
|
|
242
262
|
], 2));
|
|
243
263
|
}
|
|
244
|
-
}),
|
|
264
|
+
}), Ae = /* @__PURE__ */ C(ye, [["__scopeId", "data-v-368e3886"]]), Le = {
|
|
245
265
|
en: "English",
|
|
246
266
|
"en-GB": "English (GB)",
|
|
247
267
|
"en-US": "English (US)",
|
|
248
268
|
fr: "Français",
|
|
249
269
|
th: "ไทย"
|
|
250
|
-
},
|
|
270
|
+
}, Se = (e) => {
|
|
251
271
|
const t = {};
|
|
252
|
-
for (const
|
|
253
|
-
t[
|
|
254
|
-
locales:
|
|
272
|
+
for (const n of e)
|
|
273
|
+
t[n] = {
|
|
274
|
+
locales: Le
|
|
255
275
|
};
|
|
256
276
|
return t;
|
|
257
277
|
}, be = (e, t) => {
|
|
258
|
-
let
|
|
259
|
-
return e.some((
|
|
260
|
-
const l =
|
|
261
|
-
let
|
|
262
|
-
for (let
|
|
263
|
-
if (
|
|
264
|
-
return
|
|
265
|
-
}),
|
|
278
|
+
let n;
|
|
279
|
+
return e.some((o) => {
|
|
280
|
+
const l = o.split("-");
|
|
281
|
+
let c = [];
|
|
282
|
+
for (let f = 1; f <= l.length; f++)
|
|
283
|
+
if (c = (c.length === 0 ? t : c).filter((a) => a.startsWith(l.slice(0, f).join("-"))), c.length === 1)
|
|
284
|
+
return n = c[0], !0;
|
|
285
|
+
}), n;
|
|
266
286
|
}, ke = (e, t) => {
|
|
267
287
|
if (!t)
|
|
268
288
|
return e;
|
|
269
|
-
const
|
|
270
|
-
for (const
|
|
271
|
-
const l = t[
|
|
272
|
-
o
|
|
273
|
-
...
|
|
289
|
+
const n = {};
|
|
290
|
+
for (const o in t) {
|
|
291
|
+
const l = t[o], c = e[o];
|
|
292
|
+
n[o] = c ? {
|
|
293
|
+
...c,
|
|
274
294
|
...l
|
|
275
295
|
} : l;
|
|
276
296
|
}
|
|
277
|
-
for (const
|
|
278
|
-
if (o
|
|
297
|
+
for (const o in e) {
|
|
298
|
+
if (n[o])
|
|
279
299
|
continue;
|
|
280
|
-
const l = t[
|
|
281
|
-
o
|
|
282
|
-
...
|
|
300
|
+
const l = t[o], c = e[o];
|
|
301
|
+
n[o] = l ? {
|
|
302
|
+
...c,
|
|
283
303
|
...l
|
|
284
|
-
} :
|
|
304
|
+
} : c;
|
|
285
305
|
}
|
|
286
|
-
return
|
|
306
|
+
return n;
|
|
287
307
|
}, Ie = (e) => {
|
|
288
|
-
const t = e.config.i18n,
|
|
289
|
-
if (!
|
|
308
|
+
const t = e.config.i18n, n = e.config.slug, { getLocale: o, setLocale: l } = F(n), c = o();
|
|
309
|
+
if (!c) {
|
|
290
310
|
const r = be(
|
|
291
311
|
navigator.languages,
|
|
292
312
|
t.supportedLocales
|
|
293
313
|
);
|
|
294
314
|
l(r);
|
|
295
315
|
}
|
|
296
|
-
const
|
|
297
|
-
|
|
316
|
+
const f = ke(
|
|
317
|
+
Se(t.supportedLocales),
|
|
298
318
|
t?.messages
|
|
299
319
|
);
|
|
300
|
-
return
|
|
320
|
+
return z({
|
|
301
321
|
...t,
|
|
302
322
|
globalInjection: !0,
|
|
303
323
|
legacy: !1,
|
|
304
|
-
locale:
|
|
305
|
-
messages:
|
|
324
|
+
locale: c,
|
|
325
|
+
messages: f
|
|
306
326
|
});
|
|
307
|
-
},
|
|
327
|
+
}, Ce = {
|
|
308
328
|
install: (e, t) => {
|
|
309
|
-
const
|
|
310
|
-
e.use(
|
|
329
|
+
const n = Ie(t);
|
|
330
|
+
e.use(n);
|
|
311
331
|
}
|
|
312
332
|
};
|
|
313
333
|
export {
|
|
314
|
-
|
|
334
|
+
Ae as LocaleSwitcher,
|
|
315
335
|
Ie as createI18n,
|
|
316
|
-
|
|
336
|
+
Ce as default,
|
|
317
337
|
be as getPreferredLocale,
|
|
318
338
|
ke as prependMessages,
|
|
319
|
-
|
|
339
|
+
Pe as useI18n,
|
|
320
340
|
F as useLocaleStore
|
|
321
341
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(f,k){typeof exports=="object"&&typeof module<"u"?k(exports,require("vue-i18n"),require("vue"),require("@prefabs.tech/vue3-config")):typeof define=="function"&&define.amd?define(["exports","vue-i18n","vue","@prefabs.tech/vue3-config"],k):(f=typeof globalThis<"u"?globalThis:f||self,k(f.PrefabsTechVue3I18n={},f.VueI18n,f.Vue,f.PrefabsTechVue3Config))})(this,function(f,k,
|
|
1
|
+
(function(f,k){typeof exports=="object"&&typeof module<"u"?k(exports,require("vue-i18n"),require("vue"),require("@prefabs.tech/vue3-config")):typeof define=="function"&&define.amd?define(["exports","vue-i18n","vue","@prefabs.tech/vue3-config"],k):(f=typeof globalThis<"u"?globalThis:f||self,k(f.PrefabsTechVue3I18n={},f.VueI18n,f.Vue,f.PrefabsTechVue3Config))})(this,function(f,k,e,j){"use strict";function v(t){return e.getCurrentScope()?(e.onScopeDispose(t),!0):!1}const C=typeof window<"u"&&typeof document<"u";typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope;const q=Object.prototype.toString,x=t=>q.call(t)==="[object Object]",w=()=>{},D=W();function W(){var t,n;return C&&((t=window?.navigator)==null?void 0:t.userAgent)&&(/iP(?:ad|hone|od)/.test(window.navigator.userAgent)||((n=window?.navigator)==null?void 0:n.maxTouchPoints)>2&&/iPad|Macintosh/.test(window?.navigator.userAgent))}function E(t){return Array.isArray(t)?t:[t]}function z(t,n,o){return e.watch(t,n,{...o,immediate:!0})}const P=C?window:void 0;function S(t){var n;const o=e.toValue(t);return(n=o?.$el)!=null?n:o}function b(...t){const n=[],o=()=>{n.forEach(i=>i()),n.length=0},l=(i,a,d,g)=>(i.addEventListener(a,d,g),()=>i.removeEventListener(a,d,g)),c=e.computed(()=>{const i=E(e.toValue(t[0])).filter(a=>a!=null);return i.every(a=>typeof a!="string")?i:void 0}),s=z(()=>{var i,a;return[(a=(i=c.value)==null?void 0:i.map(d=>S(d)))!=null?a:[P].filter(d=>d!=null),E(e.toValue(c.value?t[1]:t[0])),E(e.unref(c.value?t[2]:t[1])),e.toValue(c.value?t[3]:t[2])]},([i,a,d,g])=>{if(o(),!i?.length||!a?.length||!d?.length)return;const h=x(g)?{...g}:g;n.push(...i.flatMap(y=>a.flatMap(_=>d.map(L=>l(y,_,L,h)))))},{flush:"post"}),m=()=>{s(),o()};return v(o),m}let O=!1;function F(t,n,o={}){const{window:l=P,ignore:c=[],capture:s=!0,detectIframe:m=!1,controls:i=!1}=o;if(!l)return i?{stop:w,cancel:w,trigger:w}:w;if(D&&!O){O=!0;const r={passive:!0};Array.from(l.document.body.children).forEach(u=>b(u,"click",w,r)),b(l.document.documentElement,"click",w,r)}let a=!0;const d=r=>e.toValue(c).some(u=>{if(typeof u=="string")return Array.from(l.document.querySelectorAll(u)).some(p=>p===r.target||r.composedPath().includes(p));{const p=S(u);return p&&(r.target===p||r.composedPath().includes(p))}});function g(r){const u=e.toValue(r);return u&&u.$.subTree.shapeFlag===16}function h(r,u){const p=e.toValue(r),I=p.$.subTree&&p.$.subTree.children;return I==null||!Array.isArray(I)?!1:I.some(M=>M.el===u.target||u.composedPath().includes(M.el))}const y=r=>{const u=S(t);if(r.target!=null&&!(!(u instanceof Element)&&g(t)&&h(t,r))&&!(!u||u===r.target||r.composedPath().includes(u))){if("detail"in r&&r.detail===0&&(a=!d(r)),!a){a=!0;return}n(r)}};let _=!1;const L=[b(l,"click",r=>{_||(_=!0,setTimeout(()=>{_=!1},0),y(r))},{passive:!0,capture:s}),b(l,"pointerdown",r=>{const u=S(t);a=!d(r)&&!!(u&&!r.composedPath().includes(u))},{passive:!0}),m&&b(l,"blur",r=>{setTimeout(()=>{var u;const p=S(t);((u=l.document.activeElement)==null?void 0:u.tagName)==="IFRAME"&&!p?.contains(l.document.activeElement)&&n(r)},0)},{passive:!0})].filter(Boolean),A=()=>L.forEach(r=>r());return i?{stop:A,cancel:()=>{a=!1},trigger:r=>{a=!0,y(r),a=!1}}:A}const G={class:"badge"},R={key:0,class:"country"},U={name:"LocaleBadge"},H=e.defineComponent({...U,props:{locale:{required:!0,type:String}},setup(t){const n=t,o=e.computed(()=>n.locale.substring(0,2)),l=e.computed(()=>{const c=n.locale.split("-");if(c.length>1)return c[1]});return(c,s)=>(e.openBlock(),e.createElementBlock("span",G,[e.createTextVNode(e.toDisplayString(o.value)+" ",1),l.value?(e.openBlock(),e.createElementBlock("span",R,e.toDisplayString(l.value),1)):e.createCommentVNode("",!0)]))}}),B=(t,n)=>{const o=t.__vccOpts||t;for(const[l,c]of n)o[l]=c;return o},J=B(H,[["__scopeId","data-v-c1291edf"]]),K={class:"locale"},Q={name:"LocaleOption"},X=e.defineComponent({...Q,props:{locale:{required:!0,type:String},name:{required:!0,type:String},showBadges:{default:!0,type:Boolean}},setup(t){return(n,o)=>(e.openBlock(),e.createElementBlock("div",K,[t.showBadges?(e.openBlock(),e.createBlock(J,{key:0,locale:t.locale},null,8,["locale"])):e.createCommentVNode("",!0),e.createTextVNode(" "+e.toDisplayString(t.name),1)]))}}),Y=B(X,[["__scopeId","data-v-3d8a4124"]]),V=t=>{const n=`${t}.locale`;return{getLocale:()=>{const c=localStorage.getItem(n);return c||void 0},setLocale:c=>{c?localStorage.setItem(n,c):localStorage.removeItem(n)}}},Z={class:"locale truncated"},ee={class:"truncated"},te={class:"dropdown"},ne=["onClick"],oe={name:"LocaleSwitcher"},le=e.defineComponent({...oe,props:{showBadges:{default:!0,type:Boolean}},setup(t){const{availableLocales:n,locale:o,t:l}=k.useI18n(),c=j.useConfig(),s=e.ref(!1),m=h=>{o.value=h,s.value=!1;const{setLocale:y}=V(c.slug);y(h)},i=e.computed(()=>({locale:o.value,name:d(o.value)})),a=()=>{s.value=!s.value},d=h=>l(`locales.${h}`),g=e.ref(null);return F(g,h=>{s.value=!1}),(h,y)=>(e.openBlock(),e.createElementBlock("nav",{ref_key:"dzangolabVueI18nLocaleSwitcher",ref:g,class:e.normalizeClass(["locale-switcher",{expanded:s.value}])},[e.createElementVNode("div",{class:"locale-trigger",onClick:a},[e.createElementVNode("div",Z,e.toDisplayString(i.value.name),1),e.createElementVNode("span",ee,[e.renderSlot(h.$slots,"icon",{},()=>[y[0]||(y[0]=e.createElementVNode("svg",{height:"24",viewBox:"0 0 24 24",width:"24",xmlns:"http://www.w3.org/2000/svg"},[e.createElementVNode("path",{d:"M12 15.25a.74.74 0 0 1-.53-.22l-5-5A.75.75 0 0 1 7.53 9L12 13.44L16.47 9a.75.75 0 0 1 1.06 1l-5 5a.74.74 0 0 1-.53.25",fill:"currentColor"})],-1))],!0)])]),e.createElementVNode("ul",te,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(n),_=>(e.openBlock(),e.createElementBlock("li",{key:_,class:e.normalizeClass([{current:_===i.value.locale},"truncated"]),onClick:L=>m(_)},[e.createVNode(Y,{locale:_,name:d(_),"show-badges":t.showBadges},null,8,["locale","name","show-badges"])],10,ne))),128))])],2))}}),ce=B(le,[["__scopeId","data-v-368e3886"]]),re={en:"English","en-GB":"English (GB)","en-US":"English (US)",fr:"Français",th:"ไทย"},se=t=>{const n={};for(const o of t)n[o]={locales:re};return n},T=(t,n)=>{let o;return t.some(l=>{const c=l.split("-");let s=[];for(let m=1;m<=c.length;m++)if(s=(s.length===0?n:s).filter(i=>i.startsWith(c.slice(0,m).join("-"))),s.length===1)return o=s[0],!0}),o},$=(t,n)=>{if(!n)return t;const o={};for(const l in n){const c=n[l],s=t[l];o[l]=s?{...s,...c}:c}for(const l in t){if(o[l])continue;const c=n[l],s=t[l];o[l]=c?{...s,...c}:s}return o},N=t=>{const n=t.config.i18n,o=t.config.slug,{getLocale:l,setLocale:c}=V(o),s=l();if(!s){const a=T(navigator.languages,n.supportedLocales);c(a)}const m=$(se(n.supportedLocales),n?.messages);return k.createI18n({...n,globalInjection:!0,legacy:!1,locale:s,messages:m})},ae={install:(t,n)=>{const o=N(n);t.use(o)}};Object.defineProperty(f,"useI18n",{enumerable:!0,get:()=>k.useI18n}),f.LocaleSwitcher=ce,f.createI18n=N,f.default=ae,f.getPreferredLocale=T,f.prependMessages=$,f.useLocaleStore=V,Object.defineProperties(f,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
@@ -1,4 +1,16 @@
|
|
|
1
|
-
declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<
|
|
1
|
+
declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
2
|
+
showBadges: {
|
|
3
|
+
default: boolean;
|
|
4
|
+
type: BooleanConstructor;
|
|
5
|
+
};
|
|
6
|
+
}>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
7
|
+
showBadges: {
|
|
8
|
+
default: boolean;
|
|
9
|
+
type: BooleanConstructor;
|
|
10
|
+
};
|
|
11
|
+
}>> & Readonly<{}>, {
|
|
12
|
+
showBadges: boolean;
|
|
13
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>, {
|
|
2
14
|
icon: (_: {}) => any;
|
|
3
15
|
}>;
|
|
4
16
|
export default _default;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Index.vue.d.ts","sourceRoot":"","sources":["../../../src/locale-switcher/Index.vue.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Index.vue.d.ts","sourceRoot":"","sources":["../../../src/locale-switcher/Index.vue.ts"],"names":[],"mappings":";;;;;;;;;;;;;UA8KM,CAAC,CAAC,IAAgB,KAAK,GAAG;;AAjKhC,wBAsLc;AACd,KAAK,uBAAuB,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG;IAAE,QAAO;QAAE,MAAM,EAAE,CAAC,CAAA;KAAE,CAAA;CAAE,CAAC"}
|
|
@@ -8,6 +8,10 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
8
8
|
required: true;
|
|
9
9
|
type: PropType<string>;
|
|
10
10
|
};
|
|
11
|
+
showBadges: {
|
|
12
|
+
default: boolean;
|
|
13
|
+
type: BooleanConstructor;
|
|
14
|
+
};
|
|
11
15
|
}>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
12
16
|
locale: {
|
|
13
17
|
required: true;
|
|
@@ -17,6 +21,12 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
17
21
|
required: true;
|
|
18
22
|
type: PropType<string>;
|
|
19
23
|
};
|
|
20
|
-
|
|
24
|
+
showBadges: {
|
|
25
|
+
default: boolean;
|
|
26
|
+
type: BooleanConstructor;
|
|
27
|
+
};
|
|
28
|
+
}>> & Readonly<{}>, {
|
|
29
|
+
showBadges: boolean;
|
|
30
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
21
31
|
export default _default;
|
|
22
32
|
//# sourceMappingURL=LocaleOption.vue.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LocaleOption.vue.d.ts","sourceRoot":"","sources":["../../../src/locale-switcher/LocaleOption.vue.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,KAAK,CAAC;;;;
|
|
1
|
+
{"version":3,"file":"LocaleOption.vue.d.ts","sourceRoot":"","sources":["../../../src/locale-switcher/LocaleOption.vue.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,KAAK,CAAC;;;;cAuBhB,QAAQ,CAAC,MAAM,CAAC;;;;cAIhB,QAAQ,CAAC,MAAM,CAAC;;;;;;;;;cAJhB,QAAQ,CAAC,MAAM,CAAC;;;;cAIhB,QAAQ,CAAC,MAAM,CAAC;;;;;;;;;AAxBpC,wBAiGc"}
|
package/dist/vue3-i18n.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.country[data-v-c1291edf]{bottom:-.35rem;background:var(--locale-switcher-badge-country-bf-color, #007aff);color:var(--locale-switcher-badge-country-color, #fff);font-size:.5rem;font-weight:700;line-height:1.25;padding:1px 2px;position:absolute;right:-.25rem}.badge[data-v-c1291edf]{align-items:center;background-color:var(--locale-switcher-badge-bg-color, #007aff);border-radius:50%;display:flex;font-size:.9rem;height:2em;justify-content:center;position:relative;text-align:center;width:2em}.locale[data-v-
|
|
1
|
+
.country[data-v-c1291edf]{bottom:-.35rem;background:var(--locale-switcher-badge-country-bf-color, #007aff);color:var(--locale-switcher-badge-country-color, #fff);font-size:.5rem;font-weight:700;line-height:1.25;padding:1px 2px;position:absolute;right:-.25rem}.badge[data-v-c1291edf]{align-items:center;background-color:var(--locale-switcher-badge-bg-color, #007aff);border-radius:50%;display:flex;font-size:.9rem;height:2em;justify-content:center;position:relative;text-align:center;width:2em}.locale[data-v-3d8a4124]{align-items:center;display:flex;gap:.5rem;justify-content:flex-start}nav.locale-switcher[data-v-368e3886]{--_hover-bg: var(--nav-item-hover-bg, #f0f2f7ad);--_hover-color: var(--nav-item-hover-color, #2c2c2c);--_width: var(--locale-switcher-width, 10rem);border-radius:.325rem;cursor:pointer;padding:0;position:relative;width:var(--_width)}nav.locale-switcher.expanded[data-v-368e3886],nav.locale-switcher[data-v-368e3886]:hover{background:var(--_hover-bg);color:var(--_hover-color)}nav.locale-switcher>.locale-trigger[data-v-368e3886]{--_padding-h: var(--locale-switcher-padding-h, 1rem);--_padding-v: var(--locale-switcher-padding-v, .625rem);align-items:center;display:flex;gap:0;justify-content:space-between;padding:var(--_padding-v) var(--_padding-h)}.locale[data-v-368e3886]{flex:1}nav.locale-switcher>.locale-trigger>span[data-v-368e3886]{align-self:start;font-size:1.5rem;line-height:1.25rem;text-align:center;width:1.5rem}nav.locale-switcher>ul.dropdown[data-v-368e3886]{--_bg-color: var(--locale-switcher-bg-color, #fff);--_border: var(--locale-switcher-border, 1px solid #e5e5e5);--_min-width: var(--locale-switcher-width, 10rem);background-color:var(--_bg-color);border:var(--_border);border-radius:.325rem;box-shadow:0 2px 5px #0000001a;display:none;list-style:none;min-width:var(--_min-width);padding-inline-start:0;padding:.15rem 0;position:absolute;right:0;top:120%;z-index:1000}nav.locale-switcher.expanded ul[data-v-368e3886]{display:block}nav.locale-switcher>.dropdown>li[data-v-368e3886]{--_active-bg: var(--nav-item-active-bg, #eff6ff);--_active-color: var(--nav-item-active-color, #2c2c2c);--_hover-bg: var(--nav-item-hover-bg, #f0f2f7ad);--_hover-color: var(--nav-item-hover-color, #2c2c2c);cursor:pointer;list-style:none;padding:.7rem 1.25rem}nav.locale-switcher.expanded li[data-v-368e3886]:hover{background:var(--_hover-bg);color:var(--_hover-color)}nav.locale-switcher>.dropdown>li.current[data-v-368e3886]{background-color:var(--_active-bg);color:var(--_active-color)}.locale-switcher .truncated[data-v-368e3886]{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.locale-switcher .truncated>svg[data-v-368e3886]{transition:transform .3s ease}nav.locale-switcher.expanded .truncated>svg[data-v-368e3886]{transform:rotate(180deg)}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prefabs.tech/vue3-i18n",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.0",
|
|
4
4
|
"description": "Vue3 I18n Plugin",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"devDependencies": {
|
|
23
23
|
"@prefabs.tech/eslint-config": "0.2.0",
|
|
24
24
|
"@prefabs.tech/tsconfig": "0.2.0",
|
|
25
|
-
"@prefabs.tech/vue3-config": "0.
|
|
25
|
+
"@prefabs.tech/vue3-config": "0.14.0",
|
|
26
26
|
"@types/node": "22.13.5",
|
|
27
27
|
"@typescript-eslint/eslint-plugin": "8.24.1",
|
|
28
28
|
"@typescript-eslint/parser": "8.24.1",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"vue-tsc": "1.2.0"
|
|
50
50
|
},
|
|
51
51
|
"peerDependencies": {
|
|
52
|
-
"@prefabs.tech/vue3-config": "0.
|
|
52
|
+
"@prefabs.tech/vue3-config": "0.14.0",
|
|
53
53
|
"@vueuse/core": ">=9.4.0",
|
|
54
54
|
"pinia": ">=2.0",
|
|
55
55
|
"vue": ">=3.2"
|
|
@@ -62,6 +62,7 @@
|
|
|
62
62
|
"build": "vite build && vue-tsc --emitDeclarationOnly",
|
|
63
63
|
"lint": "eslint . --ext .vue",
|
|
64
64
|
"lint:fix": "eslint . --ext .vue --fix",
|
|
65
|
+
"snapshot:update": "vitest --environment jsdom run --update",
|
|
65
66
|
"sort-package": "npx sort-package-json",
|
|
66
67
|
"test": "vitest --environment jsdom run --coverage",
|
|
67
68
|
"test:component": "vitest --environment jsdom run component/",
|