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