@i18n-micro/solid 1.2.1 → 1.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +30 -11
- package/dist/index.d.ts +30 -11
- package/dist/index.mjs +248 -230
- package/dist/index.mjs.map +1 -1
- package/package.json +37 -39
package/dist/index.mjs
CHANGED
|
@@ -1,96 +1,96 @@
|
|
|
1
|
-
import { BaseI18n as
|
|
2
|
-
import { FormatService as
|
|
3
|
-
import { spread as
|
|
4
|
-
import { createContext as
|
|
5
|
-
import { A as
|
|
6
|
-
const Q =
|
|
7
|
-
const
|
|
8
|
-
if (!
|
|
1
|
+
import { BaseI18n as ht, createReactiveI18nStore as gt } from "@i18n-micro/core";
|
|
2
|
+
import { FormatService as Ht, defaultPlural as Zt, interpolate as qt } from "@i18n-micro/core";
|
|
3
|
+
import { spread as E, mergeProps as P, insert as C, memo as v, template as R, createComponent as k, use as pt, setAttribute as K, effect as W, style as $, className as mt, delegateEvents as yt, Dynamic as F } from "solid-js/web";
|
|
4
|
+
import { createContext as j, useContext as V, splitProps as M, createMemo as L, createSignal as A, onMount as vt, onCleanup as Lt, createEffect as bt } from "solid-js";
|
|
5
|
+
import { A as St } from "@solidjs/router";
|
|
6
|
+
const Q = j(), U = j(), X = j(), Y = j(), D = () => {
|
|
7
|
+
const n = V(Q);
|
|
8
|
+
if (!n)
|
|
9
9
|
throw new Error("[i18n-micro] I18nContext not found. Make sure I18nProvider is used.");
|
|
10
|
-
return
|
|
10
|
+
return n;
|
|
11
11
|
}, tt = () => {
|
|
12
|
-
const
|
|
13
|
-
if (!
|
|
12
|
+
const n = V(U);
|
|
13
|
+
if (!n)
|
|
14
14
|
throw new Error("[i18n-micro] I18nLocalesContext not found. Make sure I18nLocalesContext is provided.");
|
|
15
|
-
return
|
|
16
|
-
},
|
|
17
|
-
const
|
|
18
|
-
if (!
|
|
15
|
+
return n;
|
|
16
|
+
}, kt = () => {
|
|
17
|
+
const n = V(X);
|
|
18
|
+
if (!n)
|
|
19
19
|
throw new Error("[i18n-micro] I18nDefaultLocaleContext not found. Make sure I18nDefaultLocaleContext is provided.");
|
|
20
|
-
return
|
|
21
|
-
},
|
|
22
|
-
var
|
|
23
|
-
const
|
|
24
|
-
const t = D(), [e, o] =
|
|
25
|
-
const
|
|
26
|
-
return typeof
|
|
20
|
+
return n;
|
|
21
|
+
}, H = () => V(Y);
|
|
22
|
+
var Pt = /* @__PURE__ */ R("<div>");
|
|
23
|
+
const Nt = (n) => {
|
|
24
|
+
const t = D(), [e, o] = M(n, ["prefix", "groupClass"]), r = (f, h) => {
|
|
25
|
+
const i = t.t(`${e.prefix}.${f}`, h, void 0, t.getRoute());
|
|
26
|
+
return typeof i == "string" ? i : String(i);
|
|
27
27
|
};
|
|
28
28
|
return (
|
|
29
29
|
// @ts-expect-error - Type conflict with Vue JSX in monorepo
|
|
30
30
|
(() => {
|
|
31
|
-
var f =
|
|
32
|
-
return
|
|
31
|
+
var f = Pt();
|
|
32
|
+
return E(f, P({
|
|
33
33
|
get class() {
|
|
34
34
|
return ["i18n-group", e.groupClass].filter(Boolean).join(" ");
|
|
35
35
|
}
|
|
36
|
-
}, o), !1, !0),
|
|
37
|
-
var h = v(() => typeof
|
|
38
|
-
return () => h() ?
|
|
36
|
+
}, o), !1, !0), C(f, (() => {
|
|
37
|
+
var h = v(() => typeof n.children == "function");
|
|
38
|
+
return () => h() ? n.children({
|
|
39
39
|
prefix: e.prefix,
|
|
40
|
-
t:
|
|
41
|
-
}) :
|
|
40
|
+
t: r
|
|
41
|
+
}) : n.children;
|
|
42
42
|
})()), f;
|
|
43
43
|
})()
|
|
44
44
|
);
|
|
45
45
|
};
|
|
46
|
-
var
|
|
47
|
-
const
|
|
48
|
-
const t =
|
|
49
|
-
const
|
|
46
|
+
var xt = /* @__PURE__ */ R('<a target=_blank rel="noopener noreferrer">'), Ct = /* @__PURE__ */ R("<a>");
|
|
47
|
+
const Et = (n) => {
|
|
48
|
+
const t = H(), e = D(), [o, r] = M(n, ["to", "localeRoute", "activeStyle", "style", "children"]), h = t?.getCurrentPathAccessor, i = L(() => {
|
|
49
|
+
const u = e.localeAccessor();
|
|
50
50
|
let p;
|
|
51
51
|
if (o.localeRoute) {
|
|
52
|
-
const y = o.localeRoute(o.to,
|
|
52
|
+
const y = o.localeRoute(o.to, u);
|
|
53
53
|
p = typeof y == "string" ? y : y?.path || "/";
|
|
54
54
|
} else if (t?.resolvePath) {
|
|
55
|
-
const y = t.resolvePath(o.to,
|
|
55
|
+
const y = t.resolvePath(o.to, u);
|
|
56
56
|
p = typeof y == "string" ? y : y?.path || "/";
|
|
57
57
|
} else typeof o.to == "string" ? p = o.to : p = o.to?.path || "/";
|
|
58
58
|
return p;
|
|
59
|
-
}),
|
|
60
|
-
if (
|
|
59
|
+
}), s = L(() => typeof o.to == "string" ? /^(?:https?:\/\/|\/\/|[a-zA-Z0-9-]+\.[a-zA-Z]{2,})|tel:|mailto:/.test(o.to) : !1), a = L(() => {
|
|
60
|
+
if (s())
|
|
61
61
|
return !1;
|
|
62
|
-
const
|
|
63
|
-
return y ===
|
|
64
|
-
}), l =
|
|
65
|
-
const
|
|
62
|
+
const u = h ? h() : t ? t.getCurrentPath() : typeof window < "u" ? window.location.pathname : "/", p = i(), y = u === "/" ? "/" : u.replace(/\/$/, ""), T = p === "/" ? "/" : p.replace(/\/$/, "");
|
|
63
|
+
return y === T;
|
|
64
|
+
}), l = L(() => {
|
|
65
|
+
const u = o.style || {}, y = a() ? o.activeStyle || {} : {};
|
|
66
66
|
return {
|
|
67
|
-
...typeof
|
|
67
|
+
...typeof u == "object" ? u : {},
|
|
68
68
|
...typeof y == "object" ? y : {}
|
|
69
69
|
};
|
|
70
70
|
}), g = t?.linkComponent;
|
|
71
|
-
return
|
|
71
|
+
return s() ? (
|
|
72
72
|
// @ts-expect-error - Type conflict with Vue JSX
|
|
73
73
|
(() => {
|
|
74
|
-
var
|
|
75
|
-
return
|
|
74
|
+
var u = xt();
|
|
75
|
+
return E(u, P({
|
|
76
76
|
get href() {
|
|
77
77
|
return v(() => typeof o.to == "string")() ? o.to : "";
|
|
78
78
|
},
|
|
79
79
|
get style() {
|
|
80
80
|
return l();
|
|
81
81
|
}
|
|
82
|
-
},
|
|
82
|
+
}, r), !1, !0), C(u, () => o.children), u;
|
|
83
83
|
})()
|
|
84
84
|
) : g ? (
|
|
85
85
|
// @ts-expect-error - Type conflict with router component types
|
|
86
|
-
k(g,
|
|
86
|
+
k(g, P({
|
|
87
87
|
get href() {
|
|
88
|
-
return
|
|
88
|
+
return i();
|
|
89
89
|
},
|
|
90
90
|
get style() {
|
|
91
91
|
return l();
|
|
92
92
|
}
|
|
93
|
-
},
|
|
93
|
+
}, r, {
|
|
94
94
|
get children() {
|
|
95
95
|
return o.children;
|
|
96
96
|
}
|
|
@@ -98,55 +98,55 @@ const Dt = (r) => {
|
|
|
98
98
|
) : (
|
|
99
99
|
// @ts-expect-error - Type conflict with Vue JSX
|
|
100
100
|
(() => {
|
|
101
|
-
var
|
|
102
|
-
return
|
|
101
|
+
var u = Ct();
|
|
102
|
+
return E(u, P({
|
|
103
103
|
get href() {
|
|
104
|
-
return
|
|
104
|
+
return i();
|
|
105
105
|
},
|
|
106
106
|
get style() {
|
|
107
107
|
return l();
|
|
108
108
|
}
|
|
109
|
-
},
|
|
109
|
+
}, r, {
|
|
110
110
|
onClick: (p) => {
|
|
111
|
-
t && !
|
|
112
|
-
path:
|
|
111
|
+
t && !s() && (p.preventDefault(), t.push({
|
|
112
|
+
path: i()
|
|
113
113
|
}));
|
|
114
114
|
}
|
|
115
|
-
}), !1, !0),
|
|
115
|
+
}), !1, !0), C(u, () => o.children), u;
|
|
116
116
|
})()
|
|
117
117
|
);
|
|
118
118
|
};
|
|
119
|
-
var
|
|
120
|
-
const
|
|
121
|
-
const t = D(), e =
|
|
122
|
-
let
|
|
123
|
-
const
|
|
124
|
-
|
|
125
|
-
},
|
|
126
|
-
const
|
|
127
|
-
return
|
|
128
|
-
}),
|
|
129
|
-
if (
|
|
130
|
-
|
|
119
|
+
var Rt = /* @__PURE__ */ R("<div class=i18n-switcher-wrapper><button type=button class=i18n-switcher-button aria-haspopup=true><span></span><span>▼"), wt = /* @__PURE__ */ R("<ul class=i18n-switcher-dropdown>"), _t = /* @__PURE__ */ R("<li><a>");
|
|
120
|
+
const jt = (n) => {
|
|
121
|
+
const t = D(), e = H(), o = tt(), [r, f] = M(n, ["locales", "currentLocale", "getLocaleName", "switchLocale", "localeRoute", "customLabels", "customWrapperStyle", "customButtonStyle", "customDropdownStyle", "customItemStyle", "customLinkStyle", "customActiveLinkStyle", "customDisabledLinkStyle", "customIconStyle"]), [h, i] = A(!1);
|
|
122
|
+
let s;
|
|
123
|
+
const a = L(() => r.locales || o || []), l = L(() => a().filter((c) => !c.disabled)), g = L(() => r.currentLocale !== void 0 ? typeof r.currentLocale == "function" ? r.currentLocale() : r.currentLocale : t.localeAccessor()), u = L(() => a().some((c) => c.code === g() && c.disabled)), p = L(() => r.getLocaleName ? r.getLocaleName() || null : l().find((m) => m.code === t.localeAccessor())?.displayName || null), y = (c) => {
|
|
124
|
+
c && (c.stopPropagation(), c.preventDefault()), i(!h());
|
|
125
|
+
}, T = (c) => r.customLabels?.[c.code] || c.displayName || c.code, et = L(() => {
|
|
126
|
+
const c = l().find((m) => m.code === g());
|
|
127
|
+
return c ? T(c) : p() || g();
|
|
128
|
+
}), rt = async (c) => {
|
|
129
|
+
if (i(!1), r.switchLocale) {
|
|
130
|
+
r.switchLocale(c);
|
|
131
131
|
return;
|
|
132
132
|
}
|
|
133
|
-
if (t.locale =
|
|
133
|
+
if (t.locale = c, !e)
|
|
134
134
|
return;
|
|
135
|
-
const m = e,
|
|
136
|
-
const d =
|
|
135
|
+
const m = e, x = m.getCurrentPathAccessor ? m.getCurrentPathAccessor() : e.getCurrentPath(), w = r.localeRoute ? (() => {
|
|
136
|
+
const d = r.localeRoute(x, c);
|
|
137
137
|
return typeof d == "string" ? d : d.path || "/";
|
|
138
138
|
})() : e?.resolvePath ? (() => {
|
|
139
|
-
const d = e.resolvePath(
|
|
139
|
+
const d = e.resolvePath(x, c);
|
|
140
140
|
return typeof d == "string" ? d : d.path || "/";
|
|
141
|
-
})() :
|
|
141
|
+
})() : x;
|
|
142
142
|
e.push({
|
|
143
143
|
path: w
|
|
144
144
|
});
|
|
145
|
-
},
|
|
145
|
+
}, nt = {
|
|
146
146
|
position: "relative",
|
|
147
147
|
display: "inline-block",
|
|
148
148
|
"vertical-align": "middle"
|
|
149
|
-
},
|
|
149
|
+
}, ot = {
|
|
150
150
|
padding: "4px 12px",
|
|
151
151
|
"font-size": "16px",
|
|
152
152
|
cursor: "pointer",
|
|
@@ -156,7 +156,7 @@ const Nt = (r) => {
|
|
|
156
156
|
display: "flex",
|
|
157
157
|
"align-items": "center",
|
|
158
158
|
"justify-content": "space-between"
|
|
159
|
-
},
|
|
159
|
+
}, st = {
|
|
160
160
|
position: "absolute",
|
|
161
161
|
top: "100%",
|
|
162
162
|
left: "0",
|
|
@@ -168,148 +168,152 @@ const Nt = (r) => {
|
|
|
168
168
|
margin: "4px 0 0 0",
|
|
169
169
|
"min-width": "150px",
|
|
170
170
|
"box-shadow": "0 2px 8px rgba(0,0,0,0.15)"
|
|
171
|
-
},
|
|
171
|
+
}, at = {
|
|
172
172
|
margin: "0",
|
|
173
173
|
padding: "0"
|
|
174
|
-
},
|
|
174
|
+
}, lt = {
|
|
175
175
|
display: "block",
|
|
176
176
|
padding: "8px 12px",
|
|
177
177
|
color: "#333",
|
|
178
178
|
"text-decoration": "none",
|
|
179
179
|
transition: "background-color 0.3s ease",
|
|
180
180
|
cursor: "pointer"
|
|
181
|
-
},
|
|
181
|
+
}, ct = {
|
|
182
182
|
"font-weight": "bold",
|
|
183
|
-
color: "#007bff"
|
|
184
|
-
|
|
183
|
+
color: "#007bff",
|
|
184
|
+
cursor: "not-allowed"
|
|
185
|
+
}, it = {
|
|
185
186
|
"margin-left": "8px",
|
|
186
187
|
display: "inline-block",
|
|
187
188
|
transition: "transform 0.3s ease"
|
|
188
|
-
},
|
|
189
|
+
}, ut = {
|
|
189
190
|
transform: "rotate(180deg)"
|
|
190
|
-
}, Z = (
|
|
191
|
+
}, Z = (c) => {
|
|
191
192
|
if (!h()) return;
|
|
192
|
-
const m =
|
|
193
|
-
if (!m || !
|
|
194
|
-
const
|
|
195
|
-
!
|
|
193
|
+
const m = c.target;
|
|
194
|
+
if (!m || !s) return;
|
|
195
|
+
const x = s.contains(m), w = m.closest(".i18n-switcher-button") !== null;
|
|
196
|
+
!x && !w && i(!1);
|
|
196
197
|
};
|
|
197
|
-
return
|
|
198
|
+
return vt(() => {
|
|
198
199
|
document.addEventListener("click", Z);
|
|
199
|
-
}),
|
|
200
|
+
}), Lt(() => {
|
|
200
201
|
document.removeEventListener("click", Z);
|
|
201
202
|
}), (() => {
|
|
202
|
-
var
|
|
203
|
-
return
|
|
204
|
-
|
|
205
|
-
},
|
|
203
|
+
var c = Rt(), m = c.firstChild, x = m.firstChild, w = x.nextSibling;
|
|
204
|
+
return pt((d) => {
|
|
205
|
+
s = d;
|
|
206
|
+
}, c), E(c, P({
|
|
206
207
|
get style() {
|
|
207
208
|
return {
|
|
208
|
-
...
|
|
209
|
-
...
|
|
209
|
+
...nt,
|
|
210
|
+
...r.customWrapperStyle
|
|
210
211
|
};
|
|
211
212
|
}
|
|
212
213
|
}, f), !1, !0), m.$$click = (d) => {
|
|
213
|
-
d.preventDefault(), d.stopPropagation(),
|
|
214
|
-
},
|
|
214
|
+
d.preventDefault(), d.stopPropagation(), y(d);
|
|
215
|
+
}, C(x, et), C(c, (() => {
|
|
215
216
|
var d = v(() => !!h());
|
|
216
217
|
return () => d() && (() => {
|
|
217
|
-
var _ =
|
|
218
|
-
return
|
|
219
|
-
const N =
|
|
218
|
+
var _ = wt();
|
|
219
|
+
return C(_, () => l().map((b) => {
|
|
220
|
+
const N = b.code === g(), q = e, B = q?.getCurrentPathAccessor ? q.getCurrentPathAccessor() : e?.getCurrentPath() || (typeof window < "u" ? window.location.pathname : "/"), z = r.localeRoute ? r.localeRoute(B, b.code) : e?.resolvePath ? e.resolvePath(B, b.code) : B, G = typeof z == "string" ? z : z?.path || "#";
|
|
220
221
|
return (() => {
|
|
221
|
-
var O =
|
|
222
|
-
return
|
|
223
|
-
|
|
224
|
-
}, K(
|
|
225
|
-
var
|
|
226
|
-
...ot,
|
|
227
|
-
...n.customItemStyle
|
|
228
|
-
}, J = `switcher-locale-${L.code}`, ut = {
|
|
222
|
+
var O = _t(), I = O.firstChild;
|
|
223
|
+
return I.$$click = (S) => {
|
|
224
|
+
S.preventDefault(), S.stopPropagation(), rt(b.code);
|
|
225
|
+
}, K(I, "href", typeof G == "string" ? G : "#"), C(I, () => T(b)), W((S) => {
|
|
226
|
+
var dt = {
|
|
229
227
|
...at,
|
|
230
|
-
...
|
|
231
|
-
|
|
232
|
-
...
|
|
228
|
+
...r.customItemStyle
|
|
229
|
+
}, J = `switcher-locale-${b.code}`, ft = {
|
|
230
|
+
...lt,
|
|
231
|
+
...N ? ct : {},
|
|
232
|
+
...r.customLinkStyle,
|
|
233
|
+
// active-specific customization wins over the generic link style
|
|
234
|
+
// (matches the React/Preact/Vue switchers)
|
|
235
|
+
...N ? r.customActiveLinkStyle : {}
|
|
233
236
|
};
|
|
234
|
-
return
|
|
237
|
+
return S.e = $(O, dt, S.e), J !== S.t && mt(I, S.t = J), S.a = $(I, ft, S.a), S;
|
|
235
238
|
}, {
|
|
236
239
|
e: void 0,
|
|
237
240
|
t: void 0,
|
|
238
241
|
a: void 0
|
|
239
242
|
}), O;
|
|
240
243
|
})();
|
|
241
|
-
})), W((
|
|
242
|
-
...
|
|
243
|
-
...
|
|
244
|
-
},
|
|
244
|
+
})), W((b) => $(_, {
|
|
245
|
+
...st,
|
|
246
|
+
...r.customDropdownStyle
|
|
247
|
+
}, b)), _;
|
|
245
248
|
})();
|
|
246
249
|
})(), null), W((d) => {
|
|
247
250
|
var _ = {
|
|
248
|
-
...
|
|
249
|
-
...
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
...
|
|
253
|
-
...
|
|
251
|
+
...ot,
|
|
252
|
+
...r.customButtonStyle,
|
|
253
|
+
...u() ? r.customDisabledLinkStyle : {}
|
|
254
|
+
}, b = h(), N = {
|
|
255
|
+
...it,
|
|
256
|
+
...h() ? ut : {},
|
|
257
|
+
...r.customIconStyle
|
|
254
258
|
};
|
|
255
|
-
return d.e =
|
|
259
|
+
return d.e = $(m, _, d.e), b !== d.t && K(m, "aria-expanded", d.t = b), d.a = $(w, N, d.a), d;
|
|
256
260
|
}, {
|
|
257
261
|
e: void 0,
|
|
258
262
|
t: void 0,
|
|
259
263
|
a: void 0
|
|
260
|
-
}),
|
|
264
|
+
}), c;
|
|
261
265
|
})();
|
|
262
266
|
};
|
|
263
|
-
|
|
264
|
-
const
|
|
265
|
-
const t = D(), [e, o] =
|
|
266
|
-
const h = t.localeAccessor(),
|
|
267
|
+
yt(["click"]);
|
|
268
|
+
const Vt = (n) => {
|
|
269
|
+
const t = D(), [e, o] = M(n, ["keypath", "params", "tag", "plural", "defaultValue", "html", "hideIfEmpty", "customPluralRule", "number", "date", "relativeDate"]), r = L(() => {
|
|
270
|
+
const h = t.localeAccessor(), i = t.routeAccessor();
|
|
267
271
|
if (e.number !== void 0) {
|
|
268
|
-
const
|
|
272
|
+
const a = Number(e.number), l = t.tn(a), g = t.t(e.keypath, {
|
|
269
273
|
number: l,
|
|
270
274
|
...e.params || {}
|
|
271
|
-
}, void 0,
|
|
275
|
+
}, void 0, i);
|
|
272
276
|
return typeof g == "string" ? g : String(g);
|
|
273
277
|
}
|
|
274
278
|
if (e.date !== void 0) {
|
|
275
|
-
const
|
|
276
|
-
date:
|
|
279
|
+
const a = t.td(e.date), l = t.t(e.keypath, {
|
|
280
|
+
date: a,
|
|
277
281
|
...e.params || {}
|
|
278
|
-
}, void 0,
|
|
282
|
+
}, void 0, i);
|
|
279
283
|
return typeof l == "string" ? l : String(l);
|
|
280
284
|
}
|
|
281
285
|
if (e.relativeDate !== void 0) {
|
|
282
|
-
const
|
|
283
|
-
relativeDate:
|
|
286
|
+
const a = t.tdr(e.relativeDate), l = t.t(e.keypath, {
|
|
287
|
+
relativeDate: a,
|
|
284
288
|
...e.params || {}
|
|
285
|
-
}, void 0,
|
|
289
|
+
}, void 0, i);
|
|
286
290
|
return typeof l == "string" ? l : String(l);
|
|
287
291
|
}
|
|
288
292
|
if (e.plural !== void 0) {
|
|
289
|
-
const
|
|
290
|
-
return e.customPluralRule ? e.customPluralRule(e.keypath,
|
|
291
|
-
count:
|
|
293
|
+
const a = Number.parseInt(e.plural.toString(), 10);
|
|
294
|
+
return e.customPluralRule ? e.customPluralRule(e.keypath, a, e.params || {}, h, (g, u, p) => t.t(g, u, p, i)) || "" : t.tc(e.keypath, {
|
|
295
|
+
count: a,
|
|
292
296
|
...e.params || {}
|
|
293
297
|
}, e.defaultValue);
|
|
294
298
|
}
|
|
295
|
-
const
|
|
296
|
-
return e.hideIfEmpty && !
|
|
299
|
+
const s = (t.t(e.keypath, e.params, e.defaultValue, i) ?? "").toString();
|
|
300
|
+
return e.hideIfEmpty && !s.trim() ? e.defaultValue || "" : s;
|
|
297
301
|
});
|
|
298
302
|
if (e.html)
|
|
299
303
|
return (
|
|
300
304
|
// @ts-expect-error - Dynamic component type conflict with Vue JSX
|
|
301
|
-
k(
|
|
305
|
+
k(F, P({
|
|
302
306
|
get component() {
|
|
303
307
|
return e.tag || "span";
|
|
304
308
|
}
|
|
305
309
|
}, o, {
|
|
306
310
|
get innerHTML() {
|
|
307
|
-
return
|
|
311
|
+
return r();
|
|
308
312
|
}
|
|
309
313
|
}))
|
|
310
314
|
);
|
|
311
|
-
const f =
|
|
312
|
-
return e.hideIfEmpty && !f.trim() ? e.defaultValue ? k(
|
|
315
|
+
const f = r();
|
|
316
|
+
return e.hideIfEmpty && !f.trim() ? e.defaultValue ? k(F, P({
|
|
313
317
|
get component() {
|
|
314
318
|
return e.tag || "span";
|
|
315
319
|
}
|
|
@@ -319,7 +323,7 @@ const Tt = (r) => {
|
|
|
319
323
|
}
|
|
320
324
|
})) : null : (
|
|
321
325
|
// @ts-expect-error - Dynamic component type conflict with Vue JSX
|
|
322
|
-
k(
|
|
326
|
+
k(F, P({
|
|
323
327
|
get component() {
|
|
324
328
|
return e.tag || "span";
|
|
325
329
|
}
|
|
@@ -327,50 +331,50 @@ const Tt = (r) => {
|
|
|
327
331
|
children: f
|
|
328
332
|
}))
|
|
329
333
|
);
|
|
330
|
-
},
|
|
331
|
-
const t =
|
|
334
|
+
}, Mt = (n) => {
|
|
335
|
+
const t = n.children;
|
|
332
336
|
return (
|
|
333
337
|
// @ts-expect-error - Provider components type conflict with Vue JSX
|
|
334
338
|
k(Q.Provider, {
|
|
335
339
|
get value() {
|
|
336
|
-
return
|
|
340
|
+
return n.i18n;
|
|
337
341
|
},
|
|
338
342
|
get children() {
|
|
339
|
-
return [v(() => v(() => !!
|
|
343
|
+
return [v(() => v(() => !!n.locales)() && // @ts-expect-error - Provider components type conflict with Vue JSX
|
|
340
344
|
k(U.Provider, {
|
|
341
345
|
get value() {
|
|
342
|
-
return
|
|
346
|
+
return n.locales;
|
|
343
347
|
},
|
|
344
348
|
get children() {
|
|
345
|
-
return [v(() => v(() => !!
|
|
349
|
+
return [v(() => v(() => !!n.defaultLocale)() && // @ts-expect-error - Provider components type conflict with Vue JSX
|
|
346
350
|
k(X.Provider, {
|
|
347
351
|
get value() {
|
|
348
|
-
return
|
|
352
|
+
return n.defaultLocale;
|
|
349
353
|
},
|
|
350
354
|
get children() {
|
|
351
|
-
return [v(() => v(() => !!
|
|
355
|
+
return [v(() => v(() => !!n.routingStrategy)() && // @ts-expect-error - Provider components type conflict with Vue JSX
|
|
352
356
|
k(Y.Provider, {
|
|
353
357
|
get value() {
|
|
354
|
-
return
|
|
358
|
+
return n.routingStrategy;
|
|
355
359
|
},
|
|
356
360
|
children: t
|
|
357
|
-
})), v(() => !
|
|
361
|
+
})), v(() => !n.routingStrategy && t)];
|
|
358
362
|
}
|
|
359
|
-
})), v(() => !
|
|
363
|
+
})), v(() => !n.defaultLocale && t)];
|
|
360
364
|
}
|
|
361
|
-
})), v(() => !
|
|
365
|
+
})), v(() => !n.locales && t)];
|
|
362
366
|
}
|
|
363
367
|
})
|
|
364
368
|
);
|
|
365
369
|
};
|
|
366
|
-
class
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
370
|
+
class It extends ht {
|
|
371
|
+
store;
|
|
372
|
+
_localeSignal;
|
|
373
|
+
_setLocaleSignal;
|
|
374
|
+
_routeSignal;
|
|
375
|
+
_setRouteSignal;
|
|
376
|
+
_fallbackSignal;
|
|
372
377
|
storage;
|
|
373
|
-
listeners = /* @__PURE__ */ new Set();
|
|
374
378
|
constructor(t) {
|
|
375
379
|
const e = {
|
|
376
380
|
translations: /* @__PURE__ */ new Map()
|
|
@@ -380,129 +384,141 @@ class Ct extends dt {
|
|
|
380
384
|
plural: t.plural,
|
|
381
385
|
missingWarn: t.missingWarn,
|
|
382
386
|
missingHandler: t.missingHandler
|
|
383
|
-
}), this.storage = e
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
387
|
+
}), this.storage = e, this.store = gt({
|
|
388
|
+
locale: t.locale,
|
|
389
|
+
fallbackLocale: t.fallbackLocale || t.locale
|
|
390
|
+
});
|
|
391
|
+
const [o, r] = A(t.locale), [f] = A(t.fallbackLocale || t.locale), [h, i] = A("index");
|
|
392
|
+
if (this._localeSignal = o, this._setLocaleSignal = r, this._fallbackSignal = f, this._routeSignal = h, this._setRouteSignal = i, this.store.subscribe(() => {
|
|
393
|
+
r(this.store.getLocale()), i(this.store.getRoute());
|
|
394
|
+
}), t.messages)
|
|
395
|
+
for (const [s, a] of Object.entries(t.messages))
|
|
396
|
+
this.addTranslations(s, a);
|
|
388
397
|
}
|
|
389
398
|
getLocale() {
|
|
390
|
-
return this.
|
|
399
|
+
return this.store.getLocale();
|
|
391
400
|
}
|
|
392
401
|
getFallbackLocale() {
|
|
393
|
-
return this.
|
|
402
|
+
return this.store.getFallbackLocale();
|
|
394
403
|
}
|
|
395
404
|
getRoute() {
|
|
396
|
-
return this.
|
|
405
|
+
return this.store.getRoute();
|
|
397
406
|
}
|
|
398
407
|
set locale(t) {
|
|
399
|
-
this.
|
|
408
|
+
this.store.setLocale(t), this._setLocaleSignal(t), this.notifyListeners();
|
|
400
409
|
}
|
|
401
410
|
get locale() {
|
|
402
|
-
return this.
|
|
411
|
+
return this._localeSignal();
|
|
403
412
|
}
|
|
404
413
|
get localeAccessor() {
|
|
405
|
-
return this.
|
|
414
|
+
return this._localeSignal;
|
|
406
415
|
}
|
|
407
416
|
get fallbackLocale() {
|
|
408
|
-
return this.
|
|
417
|
+
return this._fallbackSignal();
|
|
409
418
|
}
|
|
410
419
|
get currentRoute() {
|
|
411
|
-
return this.
|
|
420
|
+
return this._routeSignal();
|
|
412
421
|
}
|
|
413
422
|
get routeAccessor() {
|
|
414
|
-
return this.
|
|
423
|
+
return this._routeSignal;
|
|
415
424
|
}
|
|
416
425
|
setRoute(t) {
|
|
417
|
-
this.
|
|
426
|
+
this.store.setRoute(t), this._setRouteSignal(t), this.notifyListeners();
|
|
418
427
|
}
|
|
419
428
|
addTranslations(t, e, o = !0) {
|
|
420
|
-
super.loadTranslationsCore(t, e, o), this.notifyListeners();
|
|
429
|
+
super.loadTranslationsCore(t, e, o), this.store.notify(), this.notifyListeners();
|
|
421
430
|
}
|
|
422
|
-
addRouteTranslations(t, e, o,
|
|
423
|
-
super.loadRouteTranslationsCore(t, e, o,
|
|
431
|
+
addRouteTranslations(t, e, o, r = !0) {
|
|
432
|
+
super.loadRouteTranslationsCore(t, e, o, r), this.store.notify(), this.notifyListeners();
|
|
424
433
|
}
|
|
425
434
|
clearCache() {
|
|
426
|
-
super.clearCache(), this.notifyListeners();
|
|
435
|
+
super.clearCache(), this.store.notify(), this.notifyListeners();
|
|
436
|
+
}
|
|
437
|
+
onTranslationsChanged() {
|
|
438
|
+
this.store.notify(), this.notifyListeners();
|
|
427
439
|
}
|
|
440
|
+
listeners = /* @__PURE__ */ new Set();
|
|
428
441
|
subscribe(t) {
|
|
429
442
|
return this.listeners.add(t), () => this.listeners.delete(t);
|
|
430
443
|
}
|
|
444
|
+
getSnapshot() {
|
|
445
|
+
return this.store.getSnapshot();
|
|
446
|
+
}
|
|
431
447
|
notifyListeners() {
|
|
432
448
|
this.listeners.forEach((t) => t());
|
|
433
449
|
}
|
|
434
450
|
}
|
|
435
|
-
function
|
|
436
|
-
return new
|
|
451
|
+
function Bt(n) {
|
|
452
|
+
return new It(n);
|
|
437
453
|
}
|
|
438
|
-
function
|
|
439
|
-
const
|
|
440
|
-
|
|
454
|
+
function zt(n, t, e, o) {
|
|
455
|
+
const r = n.map((s) => s.code), [f, h] = A(o.pathname);
|
|
456
|
+
bt(() => {
|
|
441
457
|
h(o.pathname);
|
|
442
458
|
});
|
|
443
|
-
const
|
|
444
|
-
const g = (typeof
|
|
445
|
-
g.length > 0 &&
|
|
446
|
-
const
|
|
447
|
-
return
|
|
459
|
+
const i = (s, a) => {
|
|
460
|
+
const g = (typeof s == "string" ? s : s.path || "/").split("/").filter(Boolean);
|
|
461
|
+
g.length > 0 && r.includes(g[0]) && g.shift();
|
|
462
|
+
const u = `/${g.join("/")}`;
|
|
463
|
+
return a === t ? u : `/${a}${u === "/" ? "" : u}`;
|
|
448
464
|
};
|
|
449
465
|
return {
|
|
450
466
|
getCurrentPath: () => f(),
|
|
451
467
|
// Returns current value for compatibility
|
|
452
468
|
getCurrentPathAccessor: f,
|
|
453
469
|
// Returns accessor for reactivity
|
|
454
|
-
push: (
|
|
455
|
-
e(
|
|
470
|
+
push: (s) => {
|
|
471
|
+
e(s.path);
|
|
456
472
|
},
|
|
457
|
-
replace: (
|
|
458
|
-
e(
|
|
473
|
+
replace: (s) => {
|
|
474
|
+
e(s.path, {
|
|
459
475
|
replace: !0
|
|
460
476
|
});
|
|
461
477
|
},
|
|
462
|
-
resolvePath: (
|
|
478
|
+
resolvePath: (s, a) => i(s, a),
|
|
463
479
|
getRoute: () => ({
|
|
464
480
|
fullPath: f(),
|
|
465
481
|
query: {}
|
|
466
482
|
}),
|
|
467
483
|
// Use A component from @solidjs/router
|
|
468
|
-
linkComponent: ((
|
|
484
|
+
linkComponent: ((s) => {
|
|
469
485
|
const {
|
|
470
|
-
href:
|
|
486
|
+
href: a,
|
|
471
487
|
children: l,
|
|
472
488
|
class: g,
|
|
473
|
-
style:
|
|
489
|
+
style: u,
|
|
474
490
|
...p
|
|
475
|
-
} =
|
|
476
|
-
return k(
|
|
477
|
-
href:
|
|
491
|
+
} = s;
|
|
492
|
+
return k(St, P({
|
|
493
|
+
href: a,
|
|
478
494
|
class: g,
|
|
479
|
-
style:
|
|
495
|
+
style: u
|
|
480
496
|
}, p, {
|
|
481
497
|
children: l
|
|
482
498
|
}));
|
|
483
499
|
})
|
|
484
500
|
};
|
|
485
501
|
}
|
|
486
|
-
function
|
|
487
|
-
const t = D(), e =
|
|
502
|
+
function Ot(n) {
|
|
503
|
+
const t = D(), e = H(), o = tt(), r = kt(), f = n?.locales || o, h = n?.defaultLocale || r, i = (s, a) => e?.resolvePath ? e.resolvePath(s, a || t.getLocale()) : s;
|
|
488
504
|
return {
|
|
489
505
|
// Direct access to instance
|
|
490
506
|
instance: t,
|
|
491
507
|
// Locale (reactive) - use accessor to track changes
|
|
492
|
-
locale:
|
|
508
|
+
locale: L(() => t.localeAccessor()),
|
|
493
509
|
// Locale helpers
|
|
494
510
|
getLocales: () => f,
|
|
495
511
|
defaultLocale: () => h,
|
|
496
|
-
getLocaleName: () => f.find((
|
|
512
|
+
getLocaleName: () => f.find((a) => a.code === t.localeAccessor())?.displayName || null,
|
|
497
513
|
// Routing helpers
|
|
498
|
-
localeRoute:
|
|
499
|
-
localePath: (
|
|
500
|
-
const l =
|
|
514
|
+
localeRoute: i,
|
|
515
|
+
localePath: (s, a) => {
|
|
516
|
+
const l = i(s, a);
|
|
501
517
|
return typeof l == "string" ? l : l.path || "/";
|
|
502
518
|
},
|
|
503
|
-
switchLocale: (
|
|
504
|
-
if (t.locale =
|
|
505
|
-
const
|
|
519
|
+
switchLocale: (s) => {
|
|
520
|
+
if (t.locale = s, e) {
|
|
521
|
+
const a = e.getCurrentPath(), l = i(a, s);
|
|
506
522
|
e.push(typeof l == "string" ? { path: l } : { path: l.path || "/" });
|
|
507
523
|
}
|
|
508
524
|
},
|
|
@@ -521,29 +537,31 @@ function Mt(r) {
|
|
|
521
537
|
// Translation management
|
|
522
538
|
addTranslations: t.addTranslations.bind(t),
|
|
523
539
|
addRouteTranslations: t.addRouteTranslations.bind(t),
|
|
540
|
+
resolveTranslations: t.resolveTranslations.bind(t),
|
|
541
|
+
setTranslation: t.setTranslation.bind(t),
|
|
524
542
|
clearCache: t.clearCache.bind(t)
|
|
525
543
|
};
|
|
526
544
|
}
|
|
527
545
|
export {
|
|
528
|
-
|
|
546
|
+
Ht as FormatService,
|
|
529
547
|
Q as I18nContext,
|
|
530
548
|
X as I18nDefaultLocaleContext,
|
|
531
|
-
|
|
532
|
-
|
|
549
|
+
Nt as I18nGroup,
|
|
550
|
+
Et as I18nLink,
|
|
533
551
|
U as I18nLocalesContext,
|
|
534
|
-
|
|
552
|
+
Mt as I18nProvider,
|
|
535
553
|
Y as I18nRouterContext,
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
554
|
+
jt as I18nSwitcher,
|
|
555
|
+
Vt as I18nT,
|
|
556
|
+
It as SolidI18n,
|
|
557
|
+
Bt as createI18n,
|
|
558
|
+
zt as createSolidRouterAdapter,
|
|
559
|
+
Zt as defaultPlural,
|
|
560
|
+
qt as interpolate,
|
|
561
|
+
Ot as useI18n,
|
|
544
562
|
D as useI18nContext,
|
|
545
|
-
|
|
563
|
+
kt as useI18nDefaultLocale,
|
|
546
564
|
tt as useI18nLocales,
|
|
547
|
-
|
|
565
|
+
H as useI18nRouter
|
|
548
566
|
};
|
|
549
567
|
//# sourceMappingURL=index.mjs.map
|