@i18n-micro/solid 1.1.0 → 1.2.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/index.mjs CHANGED
@@ -1,80 +1,8 @@
1
- import { createSignal as A, createContext as E, useContext as j, createMemo as P, splitProps as V, onMount as dt, onCleanup as ft, createEffect as ht } from "solid-js";
2
- import { BaseI18n as pt } from "@i18n-micro/core";
1
+ import { BaseI18n as dt } from "@i18n-micro/core";
3
2
  import { FormatService as Ot, defaultPlural as Wt, interpolate as Ht } from "@i18n-micro/core";
4
- import { createComponent as k, memo as v, Dynamic as W, mergeProps as R, spread as T, insert as x, template as C, delegateEvents as gt, use as mt, setAttribute as K, effect as H, style as $, className as yt } from "solid-js/web";
3
+ import { spread as T, mergeProps as x, insert as S, 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
5
  import { A as vt } from "@solidjs/router";
6
- class Lt extends pt {
7
- _locale;
8
- _setLocale;
9
- _fallbackLocale;
10
- _currentRoute;
11
- _setRoute;
12
- storage;
13
- listeners = /* @__PURE__ */ new Set();
14
- constructor(t) {
15
- const e = {
16
- translations: /* @__PURE__ */ new Map()
17
- };
18
- super({
19
- storage: e,
20
- plural: t.plural,
21
- missingWarn: t.missingWarn,
22
- missingHandler: t.missingHandler
23
- }), this.storage = e;
24
- const [o, n] = A(t.locale), [f] = A(t.fallbackLocale || t.locale), [h, c] = A("general");
25
- if (this._locale = o, this._setLocale = n, this._fallbackLocale = f, this._currentRoute = h, this._setRoute = c, t.messages)
26
- for (const [a, s] of Object.entries(t.messages))
27
- this.addTranslations(a, s);
28
- }
29
- getLocale() {
30
- return this._locale();
31
- }
32
- getFallbackLocale() {
33
- return this._fallbackLocale();
34
- }
35
- getRoute() {
36
- return this._currentRoute();
37
- }
38
- set locale(t) {
39
- this._setLocale(t), this.notifyListeners();
40
- }
41
- get locale() {
42
- return this._locale();
43
- }
44
- get localeAccessor() {
45
- return this._locale;
46
- }
47
- get fallbackLocale() {
48
- return this._fallbackLocale();
49
- }
50
- get currentRoute() {
51
- return this._currentRoute();
52
- }
53
- get routeAccessor() {
54
- return this._currentRoute;
55
- }
56
- setRoute(t) {
57
- this._setRoute(t), this.notifyListeners();
58
- }
59
- addTranslations(t, e, o = !0) {
60
- super.loadTranslationsCore(t, e, o), this.notifyListeners();
61
- }
62
- addRouteTranslations(t, e, o, n = !0) {
63
- super.loadRouteTranslationsCore(t, e, o, n), this.notifyListeners();
64
- }
65
- clearCache() {
66
- super.clearCache(), this.notifyListeners();
67
- }
68
- subscribe(t) {
69
- return this.listeners.add(t), () => this.listeners.delete(t);
70
- }
71
- notifyListeners() {
72
- this.listeners.forEach((t) => t());
73
- }
74
- }
75
- function At(r) {
76
- return new Lt(r);
77
- }
78
6
  const Q = E(), U = E(), X = E(), Y = E(), D = () => {
79
7
  const r = j(Q);
80
8
  if (!r)
@@ -85,157 +13,38 @@ const Q = E(), U = E(), X = E(), Y = E(), D = () => {
85
13
  if (!r)
86
14
  throw new Error("[i18n-micro] I18nLocalesContext not found. Make sure I18nLocalesContext is provided.");
87
15
  return r;
88
- }, bt = () => {
16
+ }, Lt = () => {
89
17
  const r = j(X);
90
18
  if (!r)
91
19
  throw new Error("[i18n-micro] I18nDefaultLocaleContext not found. Make sure I18nDefaultLocaleContext is provided.");
92
20
  return r;
93
- }, F = () => j(Y), Dt = (r) => {
94
- const t = r.children;
95
- return (
96
- // @ts-expect-error - Provider components type conflict with Vue JSX
97
- k(Q.Provider, {
98
- get value() {
99
- return r.i18n;
100
- },
101
- get children() {
102
- return [v(() => v(() => !!r.locales)() && // @ts-expect-error - Provider components type conflict with Vue JSX
103
- k(U.Provider, {
104
- get value() {
105
- return r.locales;
106
- },
107
- get children() {
108
- return [v(() => v(() => !!r.defaultLocale)() && // @ts-expect-error - Provider components type conflict with Vue JSX
109
- k(X.Provider, {
110
- get value() {
111
- return r.defaultLocale;
112
- },
113
- get children() {
114
- return [v(() => v(() => !!r.routingStrategy)() && // @ts-expect-error - Provider components type conflict with Vue JSX
115
- k(Y.Provider, {
116
- get value() {
117
- return r.routingStrategy;
118
- },
119
- children: t
120
- })), v(() => !r.routingStrategy && t)];
121
- }
122
- })), v(() => !r.defaultLocale && t)];
123
- }
124
- })), v(() => !r.locales && t)];
125
- }
126
- })
127
- );
128
- };
129
- function Nt(r) {
130
- const t = D(), e = F(), o = tt(), n = bt(), f = r?.locales || o, h = r?.defaultLocale || n, c = (a, s) => e?.resolvePath ? e.resolvePath(a, s || t.getLocale()) : a;
131
- return {
132
- // Direct access to instance
133
- instance: t,
134
- // Locale (reactive) - используем accessor для отслеживания изменений
135
- locale: P(() => t.localeAccessor()),
136
- // Locale helpers
137
- getLocales: () => f,
138
- defaultLocale: () => h,
139
- getLocaleName: () => f.find((s) => s.code === t.localeAccessor())?.displayName || null,
140
- // Routing helpers
141
- localeRoute: c,
142
- localePath: (a, s) => {
143
- const l = c(a, s);
144
- return typeof l == "string" ? l : l.path || "/";
145
- },
146
- switchLocale: (a) => {
147
- if (t.locale = a, e) {
148
- const s = e.getCurrentPath(), l = c(s, a);
149
- e.push(typeof l == "string" ? { path: l } : { path: l.path || "/" });
150
- }
151
- },
152
- // Translation methods (delegate to instance)
153
- t: t.t.bind(t),
154
- ts: t.ts.bind(t),
155
- tc: t.tc.bind(t),
156
- tn: t.tn.bind(t),
157
- td: t.td.bind(t),
158
- tdr: t.tdr.bind(t),
159
- has: t.has.bind(t),
160
- // Route management
161
- setRoute: t.setRoute.bind(t),
162
- getRoute: t.getRoute.bind(t),
163
- getLocale: () => t.getLocale(),
164
- // Translation management
165
- addTranslations: t.addTranslations.bind(t),
166
- addRouteTranslations: t.addRouteTranslations.bind(t),
167
- clearCache: t.clearCache.bind(t)
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);
168
27
  };
169
- }
170
- const Tt = (r) => {
171
- const t = D(), [e, o] = V(r, ["keypath", "params", "tag", "plural", "defaultValue", "html", "hideIfEmpty", "customPluralRule", "number", "date", "relativeDate"]), n = P(() => {
172
- const h = t.localeAccessor(), c = t.routeAccessor();
173
- if (e.number !== void 0) {
174
- const s = Number(e.number), l = t.tn(s), g = t.t(e.keypath, {
175
- number: l,
176
- ...e.params || {}
177
- }, void 0, c);
178
- return typeof g == "string" ? g : String(g);
179
- }
180
- if (e.date !== void 0) {
181
- const s = t.td(e.date), l = t.t(e.keypath, {
182
- date: s,
183
- ...e.params || {}
184
- }, void 0, c);
185
- return typeof l == "string" ? l : String(l);
186
- }
187
- if (e.relativeDate !== void 0) {
188
- const s = t.tdr(e.relativeDate), l = t.t(e.keypath, {
189
- relativeDate: s,
190
- ...e.params || {}
191
- }, void 0, c);
192
- return typeof l == "string" ? l : String(l);
193
- }
194
- if (e.plural !== void 0) {
195
- const s = Number.parseInt(e.plural.toString());
196
- return e.customPluralRule ? e.customPluralRule(e.keypath, s, e.params || {}, h, (g, i, p) => t.t(g, i, p, c)) || "" : t.tc(e.keypath, {
197
- count: s,
198
- ...e.params || {}
199
- }, e.defaultValue);
200
- }
201
- const a = (t.t(e.keypath, e.params, e.defaultValue, c) ?? "").toString();
202
- return e.hideIfEmpty && !a.trim() ? e.defaultValue || "" : a;
203
- });
204
- if (e.html)
205
- return (
206
- // @ts-expect-error - Dynamic component type conflict with Vue JSX
207
- k(W, R({
208
- get component() {
209
- return e.tag || "span";
210
- }
211
- }, o, {
212
- get innerHTML() {
213
- return n();
28
+ return (
29
+ // @ts-expect-error - Type conflict with Vue JSX in monorepo
30
+ (() => {
31
+ var f = bt();
32
+ return T(f, x({
33
+ get class() {
34
+ return ["i18n-group", e.groupClass].filter(Boolean).join(" ");
214
35
  }
215
- }))
216
- );
217
- const f = n();
218
- return e.hideIfEmpty && !f.trim() ? e.defaultValue ? k(W, R({
219
- get component() {
220
- return e.tag || "span";
221
- }
222
- }, o, {
223
- get children() {
224
- return e.defaultValue;
225
- }
226
- })) : null : (
227
- // @ts-expect-error - Dynamic component type conflict with Vue JSX
228
- k(W, R({
229
- get component() {
230
- return e.tag || "span";
231
- }
232
- }, o, {
233
- children: f
234
- }))
36
+ }, o), !1, !0), S(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
+ })()
235
44
  );
236
45
  };
237
46
  var Pt = /* @__PURE__ */ C('<a target=_blank rel="noopener noreferrer">'), kt = /* @__PURE__ */ C("<a>");
238
- const Et = (r) => {
47
+ const Dt = (r) => {
239
48
  const t = F(), e = D(), [o, n] = V(r, ["to", "localeRoute", "activeStyle", "style", "children"]), h = t?.getCurrentPathAccessor, c = P(() => {
240
49
  const i = e.localeAccessor();
241
50
  let p;
@@ -263,18 +72,18 @@ const Et = (r) => {
263
72
  // @ts-expect-error - Type conflict with Vue JSX
264
73
  (() => {
265
74
  var i = Pt();
266
- return T(i, R({
75
+ return T(i, x({
267
76
  get href() {
268
77
  return v(() => typeof o.to == "string")() ? o.to : "";
269
78
  },
270
79
  get style() {
271
80
  return l();
272
81
  }
273
- }, n), !1, !0), x(i, () => o.children), i;
82
+ }, n), !1, !0), S(i, () => o.children), i;
274
83
  })()
275
84
  ) : g ? (
276
85
  // @ts-expect-error - Type conflict with router component types
277
- k(g, R({
86
+ k(g, x({
278
87
  get href() {
279
88
  return c();
280
89
  },
@@ -290,7 +99,7 @@ const Et = (r) => {
290
99
  // @ts-expect-error - Type conflict with Vue JSX
291
100
  (() => {
292
101
  var i = kt();
293
- return T(i, R({
102
+ return T(i, x({
294
103
  get href() {
295
104
  return c();
296
105
  },
@@ -303,12 +112,12 @@ const Et = (r) => {
303
112
  path: c()
304
113
  }));
305
114
  }
306
- }), !1, !0), x(i, () => o.children), i;
115
+ }), !1, !0), S(i, () => o.children), i;
307
116
  })()
308
117
  );
309
118
  };
310
- 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>");
311
- const jt = (r) => {
119
+ var xt = /* @__PURE__ */ C("<div class=i18n-switcher-wrapper><button type=button class=i18n-switcher-button aria-haspopup=true><span></span><span>▼"), Rt = /* @__PURE__ */ C("<ul class=i18n-switcher-dropdown>"), St = /* @__PURE__ */ C("<li><a>");
120
+ const Nt = (r) => {
312
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);
313
122
  let a;
314
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) => {
@@ -323,13 +132,13 @@ const jt = (r) => {
323
132
  }
324
133
  if (t.locale = u, !e)
325
134
  return;
326
- const m = e, S = m.getCurrentPathAccessor ? m.getCurrentPathAccessor() : e.getCurrentPath(), w = n.localeRoute ? (() => {
327
- const d = n.localeRoute(S, u);
135
+ const m = e, R = m.getCurrentPathAccessor ? m.getCurrentPathAccessor() : e.getCurrentPath(), w = n.localeRoute ? (() => {
136
+ const d = n.localeRoute(R, u);
328
137
  return typeof d == "string" ? d : d.path || "/";
329
138
  })() : e?.resolvePath ? (() => {
330
- const d = e.resolvePath(S, u);
139
+ const d = e.resolvePath(R, u);
331
140
  return typeof d == "string" ? d : d.path || "/";
332
- })() : S;
141
+ })() : R;
333
142
  e.push({
334
143
  path: w
335
144
  });
@@ -382,18 +191,18 @@ const jt = (r) => {
382
191
  if (!h()) return;
383
192
  const m = u.target;
384
193
  if (!m || !a) return;
385
- const S = a.contains(m), w = m.closest(".i18n-switcher-button") !== null;
386
- !S && !w && c(!1);
194
+ const R = a.contains(m), w = m.closest(".i18n-switcher-button") !== null;
195
+ !R && !w && c(!1);
387
196
  };
388
- return dt(() => {
197
+ return gt(() => {
389
198
  document.addEventListener("click", Z);
390
- }), ft(() => {
199
+ }), mt(() => {
391
200
  document.removeEventListener("click", Z);
392
201
  }), (() => {
393
- var u = Rt(), m = u.firstChild, S = m.firstChild, w = S.nextSibling;
394
- return mt((d) => {
202
+ var u = xt(), m = u.firstChild, R = m.firstChild, w = R.nextSibling;
203
+ return ht((d) => {
395
204
  a = d;
396
- }, u), T(u, R({
205
+ }, u), T(u, x({
397
206
  get style() {
398
207
  return {
399
208
  ...et,
@@ -402,17 +211,17 @@ const jt = (r) => {
402
211
  }
403
212
  }, f), !1, !0), m.$$click = (d) => {
404
213
  d.preventDefault(), d.stopPropagation(), i(d);
405
- }, x(S, y), x(u, (() => {
214
+ }, S(R, y), S(u, (() => {
406
215
  var d = v(() => !!h());
407
216
  return () => d() && (() => {
408
- var _ = St();
409
- return x(_, () => s().map((L) => {
217
+ var _ = Rt();
218
+ return S(_, () => s().map((L) => {
410
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 || "#";
411
220
  return (() => {
412
- var O = xt(), I = O.firstChild;
413
- return I.$$click = (b) => {
221
+ var O = St(), $ = O.firstChild;
222
+ return $.$$click = (b) => {
414
223
  b.preventDefault(), b.stopPropagation(), M(L.code);
415
- }, K(I, "href", typeof G == "string" ? G : "#"), x(I, () => p(L)), H((b) => {
224
+ }, K($, "href", typeof G == "string" ? G : "#"), S($, () => p(L)), W((b) => {
416
225
  var it = {
417
226
  ...ot,
418
227
  ...n.customItemStyle
@@ -422,19 +231,19 @@ const jt = (r) => {
422
231
  ...n.customLinkStyle,
423
232
  ...N ? n.customActiveLinkStyle : {}
424
233
  };
425
- return b.e = $(O, it, b.e), J !== b.t && yt(I, b.t = J), b.a = $(I, ut, b.a), b;
234
+ return b.e = I(O, it, b.e), J !== b.t && pt($, b.t = J), b.a = I($, ut, b.a), b;
426
235
  }, {
427
236
  e: void 0,
428
237
  t: void 0,
429
238
  a: void 0
430
239
  }), O;
431
240
  })();
432
- })), H((L) => $(_, {
241
+ })), W((L) => I(_, {
433
242
  ...nt,
434
243
  ...n.customDropdownStyle
435
244
  }, L)), _;
436
245
  })();
437
- })(), null), H((d) => {
246
+ })(), null), W((d) => {
438
247
  var _ = {
439
248
  ...rt,
440
249
  ...n.customButtonStyle
@@ -443,7 +252,7 @@ const jt = (r) => {
443
252
  ...h() ? ct : {},
444
253
  ...n.customIconStyle
445
254
  };
446
- return d.e = $(m, _, d.e), L !== d.t && K(m, "aria-expanded", d.t = L), d.a = $(w, N, d.a), d;
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;
447
256
  }, {
448
257
  e: void 0,
449
258
  t: void 0,
@@ -451,40 +260,190 @@ const jt = (r) => {
451
260
  }), u;
452
261
  })();
453
262
  };
454
- gt(["click"]);
455
- var Ct = /* @__PURE__ */ C("<div>");
456
- const Vt = (r) => {
457
- const t = D(), [e, o] = V(r, ["prefix", "groupClass"]), n = (f, h) => {
458
- const c = t.t(`${e.prefix}.${f}`, h, void 0, t.getRoute());
459
- return typeof c == "string" ? c : String(c);
460
- };
461
- return (
462
- // @ts-expect-error - Type conflict with Vue JSX in monorepo
463
- (() => {
464
- var f = Ct();
465
- return T(f, R({
466
- get class() {
467
- return ["i18n-group", e.groupClass].filter(Boolean).join(" ");
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, x({
302
+ get component() {
303
+ return e.tag || "span";
468
304
  }
469
- }, o), !1, !0), x(f, (() => {
470
- var h = v(() => typeof r.children == "function");
471
- return () => h() ? r.children({
472
- prefix: e.prefix,
473
- t: n
474
- }) : r.children;
475
- })()), f;
476
- })()
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, x({
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, x({
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
+ })
477
364
  );
478
365
  };
479
- function Mt(r, t, e, o) {
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("index");
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) {
480
439
  const n = r.map((a) => a.code), [f, h] = A(o.pathname);
481
- ht(() => {
440
+ yt(() => {
482
441
  h(o.pathname);
483
442
  });
484
443
  const c = (a, s) => {
485
444
  const g = (typeof a == "string" ? a : a.path || "/").split("/").filter(Boolean);
486
445
  g.length > 0 && n.includes(g[0]) && g.shift();
487
- const i = "/" + g.join("/");
446
+ const i = `/${g.join("/")}`;
488
447
  return s === t ? i : `/${s}${i === "/" ? "" : i}`;
489
448
  };
490
449
  return {
@@ -514,7 +473,7 @@ function Mt(r, t, e, o) {
514
473
  style: i,
515
474
  ...p
516
475
  } = a;
517
- return k(vt, R({
476
+ return k(vt, x({
518
477
  href: s,
519
478
  class: g,
520
479
  style: i
@@ -524,25 +483,66 @@ function Mt(r, t, e, o) {
524
483
  })
525
484
  };
526
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) - use accessor to track changes
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
+ }
527
527
  export {
528
528
  Ot as FormatService,
529
529
  Q as I18nContext,
530
530
  X as I18nDefaultLocaleContext,
531
- Vt as I18nGroup,
532
- Et as I18nLink,
531
+ At as I18nGroup,
532
+ Dt as I18nLink,
533
533
  U as I18nLocalesContext,
534
- Dt as I18nProvider,
534
+ Et as I18nProvider,
535
535
  Y as I18nRouterContext,
536
- jt as I18nSwitcher,
536
+ Nt as I18nSwitcher,
537
537
  Tt as I18nT,
538
- Lt as SolidI18n,
539
- At as createI18n,
540
- Mt as createSolidRouterAdapter,
538
+ Ct as SolidI18n,
539
+ jt as createI18n,
540
+ Vt as createSolidRouterAdapter,
541
541
  Wt as defaultPlural,
542
542
  Ht as interpolate,
543
- Nt as useI18n,
543
+ Mt as useI18n,
544
544
  D as useI18nContext,
545
- bt as useI18nDefaultLocale,
545
+ Lt as useI18nDefaultLocale,
546
546
  tt as useI18nLocales,
547
547
  F as useI18nRouter
548
548
  };