@i18n-micro/solid 1.2.1 → 1.2.4

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,96 +1,96 @@
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 x, insert as S, memo as v, template as C, createComponent as k, use as ft, setAttribute as K, effect as W, style as I, className as ht, delegateEvents 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";
6
- const Q = E(), U = E(), X = E(), Y = E(), D = () => {
7
- const r = j(Q);
8
- if (!r)
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 r;
10
+ return n;
11
11
  }, tt = () => {
12
- const r = j(U);
13
- if (!r)
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 r;
16
- }, Lt = () => {
17
- const r = j(X);
18
- if (!r)
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 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);
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 = bt();
32
- return T(f, x({
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), S(f, (() => {
37
- var h = v(() => typeof r.children == "function");
38
- return () => h() ? r.children({
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: n
41
- }) : r.children;
40
+ t: r
41
+ }) : n.children;
42
42
  })()), f;
43
43
  })()
44
44
  );
45
45
  };
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();
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, i);
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, i);
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
- }), a = P(() => typeof o.to == "string" ? /^(?:https?:\/\/|\/\/|[a-zA-Z0-9-]+\.[a-zA-Z]{2,})|tel:|mailto:/.test(o.to) : !1), s = P(() => {
60
- if (a())
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 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(() => {
65
- const i = o.style || {}, y = s() ? o.activeStyle || {} : {};
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 i == "object" ? i : {},
67
+ ...typeof u == "object" ? u : {},
68
68
  ...typeof y == "object" ? y : {}
69
69
  };
70
70
  }), g = t?.linkComponent;
71
- return a() ? (
71
+ return s() ? (
72
72
  // @ts-expect-error - Type conflict with Vue JSX
73
73
  (() => {
74
- var i = Pt();
75
- return T(i, x({
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
- }, n), !1, !0), S(i, () => o.children), i;
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, x({
86
+ k(g, P({
87
87
  get href() {
88
- return c();
88
+ return i();
89
89
  },
90
90
  get style() {
91
91
  return l();
92
92
  }
93
- }, n, {
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 i = kt();
102
- return T(i, x({
101
+ var u = Ct();
102
+ return E(u, P({
103
103
  get href() {
104
- return c();
104
+ return i();
105
105
  },
106
106
  get style() {
107
107
  return l();
108
108
  }
109
- }, n, {
109
+ }, r, {
110
110
  onClick: (p) => {
111
- t && !a() && (p.preventDefault(), t.push({
112
- path: c()
111
+ t && !s() && (p.preventDefault(), t.push({
112
+ path: i()
113
113
  }));
114
114
  }
115
- }), !1, !0), S(i, () => o.children), i;
115
+ }), !1, !0), C(u, () => o.children), u;
116
116
  })()
117
117
  );
118
118
  };
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) => {
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);
122
- let a;
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);
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 = u, !e)
133
+ if (t.locale = c, !e)
134
134
  return;
135
- const m = e, R = m.getCurrentPathAccessor ? m.getCurrentPathAccessor() : e.getCurrentPath(), w = n.localeRoute ? (() => {
136
- const d = n.localeRoute(R, u);
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(R, u);
139
+ const d = e.resolvePath(x, c);
140
140
  return typeof d == "string" ? d : d.path || "/";
141
- })() : R;
141
+ })() : x;
142
142
  e.push({
143
143
  path: w
144
144
  });
145
- }, et = {
145
+ }, nt = {
146
146
  position: "relative",
147
147
  display: "inline-block",
148
148
  "vertical-align": "middle"
149
- }, rt = {
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
- }, nt = {
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
- }, ot = {
171
+ }, at = {
172
172
  margin: "0",
173
173
  padding: "0"
174
- }, at = {
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
- }, st = {
181
+ }, ct = {
182
182
  "font-weight": "bold",
183
- color: "#007bff"
184
- }, lt = {
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
- }, ct = {
189
+ }, ut = {
189
190
  transform: "rotate(180deg)"
190
- }, Z = (u) => {
191
+ }, Z = (c) => {
191
192
  if (!h()) return;
192
- const m = u.target;
193
- if (!m || !a) return;
194
- const R = a.contains(m), w = m.closest(".i18n-switcher-button") !== null;
195
- !R && !w && c(!1);
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 gt(() => {
198
+ return vt(() => {
198
199
  document.addEventListener("click", Z);
199
- }), mt(() => {
200
+ }), Lt(() => {
200
201
  document.removeEventListener("click", Z);
201
202
  }), (() => {
202
- var u = xt(), m = u.firstChild, R = m.firstChild, w = R.nextSibling;
203
- return ft((d) => {
204
- a = d;
205
- }, u), T(u, x({
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
- ...et,
209
- ...n.customWrapperStyle
209
+ ...nt,
210
+ ...r.customWrapperStyle
210
211
  };
211
212
  }
212
213
  }, f), !1, !0), m.$$click = (d) => {
213
- d.preventDefault(), d.stopPropagation(), i(d);
214
- }, S(R, y), S(u, (() => {
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 _ = Rt();
218
- return S(_, () => s().map((L) => {
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 || "#";
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 = St(), $ = O.firstChild;
222
- return $.$$click = (b) => {
223
- b.preventDefault(), b.stopPropagation(), M(L.code);
224
- }, K($, "href", typeof G == "string" ? G : "#"), S($, () => p(L)), W((b) => {
225
- var it = {
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
- ...N ? st : {},
231
- ...n.customLinkStyle,
232
- ...N ? n.customActiveLinkStyle : {}
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 b.e = I(O, it, b.e), J !== b.t && ht($, b.t = J), b.a = I($, ut, b.a), b;
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((L) => I(_, {
242
- ...nt,
243
- ...n.customDropdownStyle
244
- }, L)), _;
244
+ })), W((b) => $(_, {
245
+ ...st,
246
+ ...r.customDropdownStyle
247
+ }, b)), _;
245
248
  })();
246
249
  })(), null), W((d) => {
247
250
  var _ = {
248
- ...rt,
249
- ...n.customButtonStyle
250
- }, L = h(), N = {
251
- ...lt,
252
- ...h() ? ct : {},
253
- ...n.customIconStyle
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 = I(m, _, d.e), L !== d.t && K(m, "aria-expanded", d.t = L), d.a = I(w, N, d.a), d;
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
- }), u;
264
+ }), c;
261
265
  })();
262
266
  };
263
- pt(["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
+ 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 s = Number(e.number), l = t.tn(s), g = t.t(e.keypath, {
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, c);
275
+ }, void 0, i);
272
276
  return typeof g == "string" ? g : String(g);
273
277
  }
274
278
  if (e.date !== void 0) {
275
- const s = t.td(e.date), l = t.t(e.keypath, {
276
- date: s,
279
+ const a = t.td(e.date), l = t.t(e.keypath, {
280
+ date: a,
277
281
  ...e.params || {}
278
- }, void 0, c);
282
+ }, void 0, i);
279
283
  return typeof l == "string" ? l : String(l);
280
284
  }
281
285
  if (e.relativeDate !== void 0) {
282
- const s = t.tdr(e.relativeDate), l = t.t(e.keypath, {
283
- relativeDate: s,
286
+ const a = t.tdr(e.relativeDate), l = t.t(e.keypath, {
287
+ relativeDate: a,
284
288
  ...e.params || {}
285
- }, void 0, c);
289
+ }, void 0, i);
286
290
  return typeof l == "string" ? l : String(l);
287
291
  }
288
292
  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,
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 a = (t.t(e.keypath, e.params, e.defaultValue, c) ?? "").toString();
296
- return e.hideIfEmpty && !a.trim() ? e.defaultValue || "" : a;
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(H, x({
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 n();
311
+ return r();
308
312
  }
309
313
  }))
310
314
  );
311
- const f = n();
312
- return e.hideIfEmpty && !f.trim() ? e.defaultValue ? k(H, x({
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(H, x({
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
- }, Et = (r) => {
331
- const t = r.children;
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 r.i18n;
340
+ return n.i18n;
337
341
  },
338
342
  get children() {
339
- return [v(() => v(() => !!r.locales)() && // @ts-expect-error - Provider components type conflict with Vue JSX
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 r.locales;
346
+ return n.locales;
343
347
  },
344
348
  get children() {
345
- return [v(() => v(() => !!r.defaultLocale)() && // @ts-expect-error - Provider components type conflict with Vue JSX
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 r.defaultLocale;
352
+ return n.defaultLocale;
349
353
  },
350
354
  get children() {
351
- return [v(() => v(() => !!r.routingStrategy)() && // @ts-expect-error - Provider components type conflict with Vue JSX
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 r.routingStrategy;
358
+ return n.routingStrategy;
355
359
  },
356
360
  children: t
357
- })), v(() => !r.routingStrategy && t)];
361
+ })), v(() => !n.routingStrategy && t)];
358
362
  }
359
- })), v(() => !r.defaultLocale && t)];
363
+ })), v(() => !n.defaultLocale && t)];
360
364
  }
361
- })), v(() => !r.locales && t)];
365
+ })), v(() => !n.locales && t)];
362
366
  }
363
367
  })
364
368
  );
365
369
  };
366
- class Ct extends dt {
367
- _locale;
368
- _setLocale;
369
- _fallbackLocale;
370
- _currentRoute;
371
- _setRoute;
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
- 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);
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._locale();
399
+ return this.store.getLocale();
391
400
  }
392
401
  getFallbackLocale() {
393
- return this._fallbackLocale();
402
+ return this.store.getFallbackLocale();
394
403
  }
395
404
  getRoute() {
396
- return this._currentRoute();
405
+ return this.store.getRoute();
397
406
  }
398
407
  set locale(t) {
399
- this._setLocale(t), this.notifyListeners();
408
+ this.store.setLocale(t), this._setLocaleSignal(t), this.notifyListeners();
400
409
  }
401
410
  get locale() {
402
- return this._locale();
411
+ return this._localeSignal();
403
412
  }
404
413
  get localeAccessor() {
405
- return this._locale;
414
+ return this._localeSignal;
406
415
  }
407
416
  get fallbackLocale() {
408
- return this._fallbackLocale();
417
+ return this._fallbackSignal();
409
418
  }
410
419
  get currentRoute() {
411
- return this._currentRoute();
420
+ return this._routeSignal();
412
421
  }
413
422
  get routeAccessor() {
414
- return this._currentRoute;
423
+ return this._routeSignal;
415
424
  }
416
425
  setRoute(t) {
417
- this._setRoute(t), this.notifyListeners();
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, n = !0) {
423
- super.loadRouteTranslationsCore(t, e, o, n), this.notifyListeners();
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 jt(r) {
436
- return new Ct(r);
451
+ function Bt(n) {
452
+ return new It(n);
437
453
  }
438
- function Vt(r, t, e, o) {
439
- const n = r.map((a) => a.code), [f, h] = A(o.pathname);
440
- yt(() => {
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 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}`;
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: (a) => {
455
- e(a.path);
470
+ push: (s) => {
471
+ e(s.path);
456
472
  },
457
- replace: (a) => {
458
- e(a.path, {
473
+ replace: (s) => {
474
+ e(s.path, {
459
475
  replace: !0
460
476
  });
461
477
  },
462
- resolvePath: (a, s) => c(a, s),
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: ((a) => {
484
+ linkComponent: ((s) => {
469
485
  const {
470
- href: s,
486
+ href: a,
471
487
  children: l,
472
488
  class: g,
473
- style: i,
489
+ style: u,
474
490
  ...p
475
- } = a;
476
- return k(vt, x({
477
- href: s,
491
+ } = s;
492
+ return k(St, P({
493
+ href: a,
478
494
  class: g,
479
- style: i
495
+ style: u
480
496
  }, p, {
481
497
  children: l
482
498
  }));
483
499
  })
484
500
  };
485
501
  }
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;
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: P(() => t.localeAccessor()),
508
+ locale: L(() => t.localeAccessor()),
493
509
  // Locale helpers
494
510
  getLocales: () => f,
495
511
  defaultLocale: () => h,
496
- getLocaleName: () => f.find((s) => s.code === t.localeAccessor())?.displayName || null,
512
+ getLocaleName: () => f.find((a) => a.code === t.localeAccessor())?.displayName || null,
497
513
  // Routing helpers
498
- localeRoute: c,
499
- localePath: (a, s) => {
500
- const l = c(a, s);
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: (a) => {
504
- if (t.locale = a, e) {
505
- const s = e.getCurrentPath(), l = c(s, a);
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
- Ot as FormatService,
546
+ Ht as FormatService,
529
547
  Q as I18nContext,
530
548
  X as I18nDefaultLocaleContext,
531
- At as I18nGroup,
532
- Dt as I18nLink,
549
+ Nt as I18nGroup,
550
+ Et as I18nLink,
533
551
  U as I18nLocalesContext,
534
- Et as I18nProvider,
552
+ Mt as I18nProvider,
535
553
  Y as I18nRouterContext,
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,
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
- Lt as useI18nDefaultLocale,
563
+ kt as useI18nDefaultLocale,
546
564
  tt as useI18nLocales,
547
- F as useI18nRouter
565
+ H as useI18nRouter
548
566
  };
549
567
  //# sourceMappingURL=index.mjs.map