@i18n-micro/vue 1.3.4 → 1.3.6

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,8 +1,8 @@
1
- import { defineComponent as B, inject as k, h as p, computed as I, ref as q, onMounted as ee, onUnmounted as te, nextTick as ne, shallowRef as K } from "vue";
1
+ import { defineComponent as z, inject as k, h as g, computed as S, ref as G, onMounted as ee, onUnmounted as te, nextTick as ne, shallowRef as B } from "vue";
2
2
  import { BaseI18n as ae } from "@i18n-micro/core";
3
- import { FormatService as Le, defaultPlural as ke, interpolate as we } from "@i18n-micro/core";
4
- import { RouterLink as re } from "vue-router";
5
- const N = /* @__PURE__ */ Symbol("i18n"), Z = /* @__PURE__ */ Symbol("i18n-locales"), J = /* @__PURE__ */ Symbol("i18n-default-locale"), E = /* @__PURE__ */ Symbol("i18n-router-strategy"), oe = B({
3
+ import { FormatService as Le, defaultPlural as ke, interpolate as Se } from "@i18n-micro/core";
4
+ import { RouterLink as oe } from "vue-router";
5
+ const N = /* @__PURE__ */ Symbol("i18n"), J = /* @__PURE__ */ Symbol("i18n-locales"), Q = /* @__PURE__ */ Symbol("i18n-default-locale"), E = /* @__PURE__ */ Symbol("i18n-router-strategy"), re = z({
6
6
  name: "I18nGroup",
7
7
  props: {
8
8
  prefix: {
@@ -18,8 +18,8 @@ const N = /* @__PURE__ */ Symbol("i18n"), Z = /* @__PURE__ */ Symbol("i18n-local
18
18
  const n = k(N);
19
19
  if (!n)
20
20
  throw new Error("[i18n-micro] I18nGroup: i18n instance not found. Make sure i18n plugin is installed.");
21
- const a = (c, o) => n.t(`${t.prefix}.${c}`, o, void 0, n.getRoute());
22
- return () => p(
21
+ const a = (s, o) => n.t(`${t.prefix}.${s}`, o, void 0, n.getRoute());
22
+ return () => g(
23
23
  "div",
24
24
  {
25
25
  class: ["i18n-group", t.groupClass]
@@ -27,7 +27,7 @@ const N = /* @__PURE__ */ Symbol("i18n"), Z = /* @__PURE__ */ Symbol("i18n-local
27
27
  e.default?.({ prefix: t.prefix, t: a })
28
28
  );
29
29
  }
30
- }), le = B({
30
+ }), le = z({
31
31
  name: "I18nLink",
32
32
  props: {
33
33
  to: {
@@ -47,8 +47,8 @@ const N = /* @__PURE__ */ Symbol("i18n"), Z = /* @__PURE__ */ Symbol("i18n-local
47
47
  const n = k(N), a = k(E, void 0);
48
48
  if (!n)
49
49
  throw new Error("[i18n-micro] I18nLink: i18n instance not found. Make sure i18n plugin is installed.");
50
- const c = I(() => typeof t.to == "string" ? /^(?:https?:\/\/|\/\/|[a-zA-Z0-9-]+\.[a-zA-Z]{2,})|tel:|mailto:/.test(t.to) : !1), o = I(() => {
51
- if (c.value)
50
+ const s = S(() => typeof t.to == "string" ? /^(?:https?:\/\/|\/\/|[a-zA-Z0-9-]+\.[a-zA-Z]{2,})|tel:|mailto:/.test(t.to) : !1), o = S(() => {
51
+ if (s.value)
52
52
  return t.to;
53
53
  if (t.localeRoute) {
54
54
  const r = t.localeRoute(t.to);
@@ -56,15 +56,15 @@ const N = /* @__PURE__ */ Symbol("i18n"), Z = /* @__PURE__ */ Symbol("i18n-local
56
56
  }
57
57
  if (!a?.resolvePath)
58
58
  return typeof t.to == "string" ? t.to : t.to.path || "/";
59
- const l = a.resolvePath(t.to, n.locale.value);
60
- return typeof l == "string" ? l : l.path || "/";
61
- }), u = I(() => {
62
- if (c.value || !a)
59
+ const i = a.resolvePath(t.to, n.locale.value);
60
+ return typeof i == "string" ? i : i.path || "/";
61
+ }), u = S(() => {
62
+ if (s.value || !a)
63
63
  return !1;
64
- const l = a.getCurrentPath().replace(/\/$/, ""), r = o.value.replace(/\/$/, "");
65
- return l === r;
66
- }), d = I(() => u.value ? t.activeStyle : {});
67
- return () => c.value ? p(
64
+ const i = a.getCurrentPath().replace(/\/$/, ""), r = o.value.replace(/\/$/, "");
65
+ return i === r;
66
+ }), d = S(() => u.value ? t.activeStyle : {});
67
+ return () => s.value ? g(
68
68
  "a",
69
69
  {
70
70
  href: o.value,
@@ -73,26 +73,26 @@ const N = /* @__PURE__ */ Symbol("i18n"), Z = /* @__PURE__ */ Symbol("i18n-local
73
73
  style: d.value
74
74
  },
75
75
  e.default?.()
76
- ) : a?.linkComponent ? p(
76
+ ) : a?.linkComponent ? g(
77
77
  a.linkComponent,
78
78
  {
79
79
  to: o.value,
80
80
  style: d.value
81
81
  },
82
82
  { default: e.default }
83
- ) : p(
83
+ ) : g(
84
84
  "a",
85
85
  {
86
86
  href: o.value,
87
87
  style: d.value,
88
- onClick: (l) => {
89
- l.preventDefault(), a ? a.push({ path: o.value }) : window.location.href = o.value;
88
+ onClick: (i) => {
89
+ i.preventDefault(), a ? a.push({ path: o.value }) : window.location.href = o.value;
90
90
  }
91
91
  },
92
92
  e.default?.()
93
93
  );
94
94
  }
95
- }), ie = B({
95
+ }), ie = z({
96
96
  name: "I18nSwitcher",
97
97
  props: {
98
98
  customLabels: {
@@ -123,6 +123,13 @@ const N = /* @__PURE__ */ Symbol("i18n"), Z = /* @__PURE__ */ Symbol("i18n-local
123
123
  type: Object,
124
124
  default: () => ({})
125
125
  },
126
+ /**
127
+ * Inline style applied to the switcher button when the *current* locale is
128
+ * marked as `disabled: true` in the locale config.
129
+ *
130
+ * Note: disabled locales are omitted from the dropdown list, but the current
131
+ * locale label is still shown on the button.
132
+ */
126
133
  customDisabledLinkStyle: {
127
134
  type: Object,
128
135
  default: () => ({})
@@ -153,38 +160,38 @@ const N = /* @__PURE__ */ Symbol("i18n"), Z = /* @__PURE__ */ Symbol("i18n-local
153
160
  }
154
161
  },
155
162
  setup(t, { slots: e }) {
156
- const n = k(N), a = k(E, void 0), c = k(Z, void 0);
163
+ const n = k(N), a = k(E, void 0), s = k(J, void 0);
157
164
  if (!n)
158
165
  throw new Error("[i18n-micro] I18nSwitcher: i18n instance not found. Make sure i18n plugin is installed.");
159
- if (!c && !t.locales)
166
+ if (!s && !t.locales)
160
167
  throw new Error(
161
168
  "[i18n-micro] I18nSwitcher: locales not provided. Make sure app.provide(I18nLocalesKey, locales) is called or pass locales prop."
162
169
  );
163
- const o = I(() => t.locales || c || []), u = I(() => t.currentLocale !== void 0 ? typeof t.currentLocale == "function" ? t.currentLocale() : t.currentLocale : n.locale.value), d = I(() => t.getLocaleName ? t.getLocaleName() || null : o.value.find((y) => y.code === n.locale.value)?.displayName || null), l = q(!1), r = q(null), i = (s) => {
164
- s && (s.stopPropagation(), s.preventDefault()), l.value = !l.value;
165
- }, h = (s) => t.customLabels[s.code] || s.displayName || s.code, m = I(() => {
166
- const s = o.value.find((y) => y.code === u.value);
167
- return s ? h(s) : d.value || u.value;
168
- }), b = async (s) => {
170
+ const o = S(() => t.locales || s || []), u = S(() => o.value.filter((c) => !c.disabled)), d = S(() => t.currentLocale !== void 0 ? typeof t.currentLocale == "function" ? t.currentLocale() : t.currentLocale : n.locale.value), i = S(() => o.value.some((c) => c.code === d.value && c.disabled)), r = S(() => t.getLocaleName ? t.getLocaleName() || null : o.value.find((y) => y.code === n.locale.value)?.displayName || null), l = G(!1), m = G(null), v = (c) => {
171
+ c && (c.stopPropagation(), c.preventDefault()), l.value = !l.value;
172
+ }, b = (c) => t.customLabels[c.code] || c.displayName || c.code, w = S(() => {
173
+ const c = o.value.find((y) => y.code === d.value);
174
+ return c ? b(c) : r.value || d.value;
175
+ }), P = async (c) => {
169
176
  if (l.value = !1, await ne(), t.switchLocale) {
170
- t.switchLocale(s);
177
+ t.switchLocale(c);
171
178
  return;
172
179
  }
173
- if (n.locale.value = s, !a)
180
+ if (n.locale.value = c, !a)
174
181
  return;
175
- const y = a.getCurrentPath(), v = t.localeRoute ? (() => {
176
- const g = t.localeRoute(y, s);
177
- return typeof g == "string" ? g : g.path || "/";
182
+ const y = a.getCurrentPath(), L = t.localeRoute ? (() => {
183
+ const h = t.localeRoute(y, c);
184
+ return typeof h == "string" ? h : h.path || "/";
178
185
  })() : a?.resolvePath ? (() => {
179
- const g = a.resolvePath(y, s);
180
- return typeof g == "string" ? g : g.path || "/";
186
+ const h = a.resolvePath(y, c);
187
+ return typeof h == "string" ? h : h.path || "/";
181
188
  })() : y;
182
- a.push({ path: v });
183
- }, w = {
189
+ a.push({ path: L });
190
+ }, _ = {
184
191
  position: "relative",
185
192
  display: "inline-block",
186
193
  verticalAlign: "middle"
187
- }, S = {
194
+ }, I = {
188
195
  padding: "4px 12px",
189
196
  fontSize: "16px",
190
197
  cursor: "pointer",
@@ -194,7 +201,7 @@ const N = /* @__PURE__ */ Symbol("i18n"), Z = /* @__PURE__ */ Symbol("i18n-local
194
201
  display: "flex",
195
202
  alignItems: "center",
196
203
  justifyContent: "space-between"
197
- }, j = {
204
+ }, O = {
198
205
  position: "absolute",
199
206
  top: "100%",
200
207
  left: "0",
@@ -206,60 +213,66 @@ const N = /* @__PURE__ */ Symbol("i18n"), Z = /* @__PURE__ */ Symbol("i18n-local
206
213
  margin: "4px 0 0 0",
207
214
  minWidth: "150px",
208
215
  boxShadow: "0 2px 8px rgba(0,0,0,0.15)"
209
- }, D = {
216
+ }, C = {
210
217
  margin: "0",
211
218
  padding: "0"
212
- }, O = {
219
+ }, q = {
213
220
  display: "block",
214
221
  padding: "8px 12px",
215
222
  color: "#333",
216
223
  textDecoration: "none",
217
224
  transition: "background-color 0.3s ease",
218
225
  cursor: "pointer"
219
- }, $ = {
226
+ }, V = {
220
227
  fontWeight: "bold",
221
- color: "#007bff"
222
- }, z = {
228
+ color: "#007bff",
229
+ // Current locale is not a meaningful switch target
230
+ cursor: "not-allowed"
231
+ }, F = {
223
232
  marginLeft: "8px",
224
233
  display: "inline-block",
225
234
  transition: "transform 0.3s ease"
226
- }, V = {
235
+ }, T = {
227
236
  transform: "rotate(180deg)"
228
- }, L = (s) => s ? Array.isArray(s) ? s : [s] : [], C = (s) => {
237
+ }, p = (c) => c ? Array.isArray(c) ? c : [c] : [], U = (c) => {
229
238
  if (!l.value) return;
230
- const y = s.target;
231
- if (!y || !r.value) return;
232
- const v = r.value.contains(y), g = y.closest(".i18n-switcher-button") !== null;
233
- !v && !g && (l.value = !1);
239
+ const y = c.target;
240
+ if (!y || !m.value) return;
241
+ const L = m.value.contains(y), h = y.closest(".i18n-switcher-button") !== null;
242
+ !L && !h && (l.value = !1);
234
243
  };
235
244
  return ee(() => {
236
- document.addEventListener("click", C);
245
+ document.addEventListener("click", U);
237
246
  }), te(() => {
238
- document.removeEventListener("click", C);
247
+ document.removeEventListener("click", U);
239
248
  }), () => {
240
- const s = [];
241
- e["before-button"] && s.push(...L(e["before-button"]()));
249
+ const c = [];
250
+ e["before-button"] && c.push(...p(e["before-button"]()));
242
251
  const y = [];
243
- if (e["before-selected-locale"] && y.push(...L(e["before-selected-locale"]())), y.push(p("span", m.value)), e["after-selected-locale"] && y.push(...L(e["after-selected-locale"]())), y.push(
244
- p(
252
+ if (e["before-selected-locale"] && y.push(...p(e["before-selected-locale"]())), y.push(g("span", w.value)), e["after-selected-locale"] && y.push(...p(e["after-selected-locale"]())), y.push(
253
+ g(
245
254
  "span",
246
255
  {
247
256
  style: {
248
- ...z,
249
- ...l.value ? V : {},
257
+ ...F,
258
+ ...l.value ? T : {},
250
259
  ...t.customIconStyle
251
260
  }
252
261
  },
253
262
  "▼"
254
263
  )
255
- ), s.push(
256
- p(
264
+ ), c.push(
265
+ g(
257
266
  "button",
258
267
  {
259
268
  class: "i18n-switcher-button",
260
- style: { ...S, ...t.customButtonStyle },
261
- onClick: (v) => {
262
- v.preventDefault(), v.stopPropagation(), i(v);
269
+ style: {
270
+ ...I,
271
+ ...t.customButtonStyle,
272
+ ...i.value ? t.customDisabledLinkStyle : {}
273
+ },
274
+ onClick: (L) => {
275
+ L.preventDefault(), L.stopPropagation(), v(L);
263
276
  },
264
277
  type: "button",
265
278
  ariaHaspopup: !0,
@@ -267,65 +280,68 @@ const N = /* @__PURE__ */ Symbol("i18n"), Z = /* @__PURE__ */ Symbol("i18n-local
267
280
  },
268
281
  y
269
282
  )
270
- ), e["before-dropdown"] && s.push(...L(e["before-dropdown"]())), l.value) {
271
- const v = [];
272
- e["before-dropdown-items"] && v.push(...L(e["before-dropdown-items"]())), o.value.forEach((g) => {
273
- const T = [];
274
- e["before-item"] && T.push(...L(e["before-item"]({ locale: g })));
275
- const _ = [];
276
- e["before-link-content"] && _.push(...L(e["before-link-content"]({ locale: g }))), _.push(h(g)), e["after-link-content"] && _.push(...L(e["after-link-content"]({ locale: g })));
277
- const U = typeof window < "u" ? window.location.pathname : "/", W = t.localeRoute ? t.localeRoute(U, g.code) : a?.resolvePath ? a.resolvePath(U, g.code) : U, F = typeof W == "string" ? W : W.path || "#", M = g.code === u.value;
278
- T.push(
279
- p(
283
+ ), e["before-dropdown"] && c.push(...p(e["before-dropdown"]())), l.value) {
284
+ const L = [];
285
+ e["before-dropdown-items"] && L.push(...p(e["before-dropdown-items"]())), u.value.forEach((h) => {
286
+ const j = [];
287
+ e["before-item"] && j.push(...p(e["before-item"]({ locale: h })));
288
+ const M = [];
289
+ e["before-link-content"] && M.push(...p(e["before-link-content"]({ locale: h }))), M.push(b(h)), e["after-link-content"] && M.push(...p(e["after-link-content"]({ locale: h })));
290
+ const W = typeof window < "u" ? window.location.pathname : "/", D = t.localeRoute ? t.localeRoute(W, h.code) : a?.resolvePath ? a.resolvePath(W, h.code) : W, A = typeof D == "string" ? D : D.path || "#", K = h.code === d.value;
291
+ j.push(
292
+ g(
280
293
  "a",
281
294
  {
282
- class: `switcher-locale-${g.code}`,
283
- href: typeof F == "string" ? F : "#",
295
+ class: `switcher-locale-${h.code}`,
296
+ href: typeof A == "string" ? A : "#",
284
297
  style: {
285
- ...O,
286
- ...M ? $ : {},
287
- ...t.customLinkStyle
298
+ ...q,
299
+ ...K ? V : {},
300
+ ...t.customLinkStyle,
301
+ // active-specific customization wins over the generic link style
302
+ // (matches the React/Preact/Solid switchers)
303
+ ...K ? t.customActiveLinkStyle : {}
288
304
  },
289
305
  // Prevent default navigation, use only handleSwitchLocale
290
- onClick: (A) => {
291
- A.preventDefault(), A.stopPropagation(), b(g.code);
306
+ onClick: (f) => {
307
+ f.preventDefault(), f.stopPropagation(), P(h.code);
292
308
  }
293
309
  },
294
- _
310
+ M
295
311
  )
296
- ), e["after-item"] && T.push(...L(e["after-item"]({ locale: g }))), v.push(
297
- p(
312
+ ), e["after-item"] && j.push(...p(e["after-item"]({ locale: h }))), L.push(
313
+ g(
298
314
  "li",
299
315
  {
300
- key: g.code,
301
- style: { ...D, ...t.customItemStyle }
316
+ key: h.code,
317
+ style: { ...C, ...t.customItemStyle }
302
318
  },
303
- T
319
+ j
304
320
  )
305
321
  );
306
- }), e["after-dropdown-items"] && v.push(...L(e["after-dropdown-items"]())), s.push(
307
- p(
322
+ }), e["after-dropdown-items"] && L.push(...p(e["after-dropdown-items"]())), c.push(
323
+ g(
308
324
  "ul",
309
325
  {
310
326
  class: "i18n-switcher-dropdown",
311
- style: { ...j, ...t.customDropdownStyle }
327
+ style: { ...O, ...t.customDropdownStyle }
312
328
  },
313
- v
329
+ L
314
330
  )
315
331
  );
316
332
  }
317
- return e["after-dropdown"] && s.push(...L(e["after-dropdown"]())), p(
333
+ return e["after-dropdown"] && c.push(...p(e["after-dropdown"]())), g(
318
334
  "div",
319
335
  {
320
- ref: r,
336
+ ref: m,
321
337
  class: "i18n-switcher-wrapper",
322
- style: { ...w, ...t.customWrapperStyle }
338
+ style: { ..._, ...t.customWrapperStyle }
323
339
  },
324
- s
340
+ c
325
341
  );
326
342
  };
327
343
  }
328
- }), ce = B({
344
+ }), ce = z({
329
345
  name: "I18nT",
330
346
  props: {
331
347
  keypath: {
@@ -374,54 +390,54 @@ const N = /* @__PURE__ */ Symbol("i18n"), Z = /* @__PURE__ */ Symbol("i18n-local
374
390
  if (!a)
375
391
  throw new Error("[i18n-micro] I18nT: i18n instance not found. Make sure i18n plugin is installed.");
376
392
  return () => {
377
- const c = {}, o = a.getRoute();
393
+ const s = {}, o = a.getRoute();
378
394
  if (t.number !== void 0) {
379
- const r = Number(t.number), i = a.tn(r), h = a.t(t.keypath, { number: i, ...t.params }, void 0, o);
380
- return p(t.tag, { ...n, innerHTML: h });
395
+ const r = Number(t.number), l = a.tn(r), m = a.t(t.keypath, { number: l, ...t.params }, void 0, o);
396
+ return g(t.tag, { ...n, innerHTML: m });
381
397
  }
382
398
  if (t.date !== void 0) {
383
- const r = a.td(t.date), i = a.t(t.keypath, { date: r, ...t.params }, void 0, o);
384
- return p(t.tag, { ...n, innerHTML: i });
399
+ const r = a.td(t.date), l = a.t(t.keypath, { date: r, ...t.params }, void 0, o);
400
+ return g(t.tag, { ...n, innerHTML: l });
385
401
  }
386
402
  if (t.relativeDate !== void 0) {
387
- const r = a.tdr(t.relativeDate), i = a.t(t.keypath, { relativeDate: r, ...t.params }, void 0, o);
388
- return p(t.tag, { ...n, innerHTML: i });
403
+ const r = a.tdr(t.relativeDate), l = a.t(t.keypath, { relativeDate: r, ...t.params }, void 0, o);
404
+ return g(t.tag, { ...n, innerHTML: l });
389
405
  }
390
406
  if (t.plural !== void 0) {
391
407
  const r = Number.parseInt(t.plural.toString(), 10);
392
408
  if (t.customPluralRule) {
393
- const i = t.customPluralRule(
409
+ const l = t.customPluralRule(
394
410
  t.keypath,
395
411
  r,
396
412
  t.params,
397
413
  a.locale.value,
398
- (h, m, b) => a.t(h, m, b, o)
414
+ (m, v, b) => a.t(m, v, b, o)
399
415
  );
400
- return p(t.tag, { ...n, innerHTML: i || "" });
416
+ return g(t.tag, { ...n, innerHTML: l || "" });
401
417
  } else {
402
- const i = a.tc(t.keypath, { count: r, ...t.params });
403
- return p(t.tag, { ...n, innerHTML: i });
418
+ const l = a.tc(t.keypath, { count: r, ...t.params });
419
+ return g(t.tag, { ...n, innerHTML: l });
404
420
  }
405
421
  }
406
- const u = (a.t(t.keypath, { ...t.params, ...c }, void 0, o) ?? "").toString();
422
+ const u = (a.t(t.keypath, { ...t.params, ...s }, void 0, o) ?? "").toString();
407
423
  if (t.hideIfEmpty && !u.trim())
408
424
  return t.defaultValue ?? null;
409
425
  if (t.html)
410
- return p(t.tag, { ...n, innerHTML: u });
426
+ return g(t.tag, { ...n, innerHTML: u });
411
427
  if (e.default)
412
- return p(t.tag, n, e.default({ translation: u }));
428
+ return g(t.tag, n, e.default({ translation: u }));
413
429
  const d = [];
414
- let l = 0;
415
- for (const [r, i] of Object.entries(e)) {
430
+ let i = 0;
431
+ for (const [r, l] of Object.entries(e)) {
416
432
  if (r === "default") continue;
417
- const h = `{${r}}`, m = u.indexOf(h, l);
418
- m !== -1 && (m > l && d.push(u.slice(l, m)), i && d.push(p(i)), l = m + h.length);
433
+ const m = `{${r}}`, v = u.indexOf(m, i);
434
+ v !== -1 && (v > i && d.push(u.slice(i, v)), l && d.push(g(l)), i = v + m.length);
419
435
  }
420
- return l < u.length && d.push(u.slice(l)), e.default ? p(t.tag, n, e.default({ children: d })) : d.length > 0 ? p(t.tag, n, d) : p(t.tag, n, u);
436
+ return i < u.length && d.push(u.slice(i)), e.default ? g(t.tag, n, e.default({ children: d })) : d.length > 0 ? g(t.tag, n, d) : g(t.tag, n, u);
421
437
  };
422
438
  }
423
439
  });
424
- function G(t) {
440
+ function Z(t) {
425
441
  const e = t.og?.trim();
426
442
  if (e) return e;
427
443
  const n = t.iso?.trim();
@@ -432,38 +448,38 @@ function G(t) {
432
448
  if (o.length >= 2 && u.length === 2)
433
449
  return `${o.toLowerCase()}_${u.toUpperCase()}`;
434
450
  }
435
- const c = n.indexOf("-");
436
- if (c > 0) {
437
- const o = n.slice(0, c), u = n.slice(c + 1);
451
+ const s = n.indexOf("-");
452
+ if (s > 0) {
453
+ const o = n.slice(0, s), u = n.slice(s + 1);
438
454
  if (o.length >= 2 && u.length === 2 && /^[A-Za-z]{2}$/.test(u))
439
455
  return `${o.toLowerCase()}_${u.toUpperCase()}`;
440
456
  }
441
457
  return null;
442
458
  }
443
- function X(t, e = {}) {
444
- if (G(t) !== null || e.missingWarn === !1 || process.env.NODE_ENV === "production") return;
445
- const n = e.tag ?? "og:locale", a = String(t.code ?? "unknown"), c = t.iso ? `, iso: '${t.iso}'` : "";
459
+ function Y(t, e = {}) {
460
+ if (Z(t) !== null || e.missingWarn === !1 || process.env.NODE_ENV === "production") return;
461
+ const n = e.tag ?? "og:locale", a = String(t.code ?? "unknown"), s = t.iso ? `, iso: '${t.iso}'` : "";
446
462
  console.warn(
447
- `[i18n] Cannot derive ${n} for locale '${a}'${c}. Set locale.og (e.g. 'en_US') or use iso with a 2-letter region (e.g. 'en-US').`
463
+ `[i18n] Cannot derive ${n} for locale '${a}'${s}. Set locale.og (e.g. 'en_US') or use iso with a 2-letter region (e.g. 'en-US').`
448
464
  );
449
465
  }
450
466
  function se(t) {
451
- const e = k(N), n = k(E, void 0), a = k(Z, void 0), c = k(J, void 0);
467
+ const e = k(N), n = k(E, void 0), a = k(J, void 0), s = k(Q, void 0);
452
468
  if (!e)
453
469
  throw new Error("[i18n-micro] useI18n() must be called after app.use(i18n). Make sure i18n plugin is installed.");
454
470
  if (!a)
455
471
  throw new Error("[i18n-micro] I18nLocalesKey not provided. Make sure app.provide(I18nLocalesKey, locales) is called.");
456
- if (!c)
472
+ if (!s)
457
473
  throw new Error("[i18n-micro] I18nDefaultLocaleKey not provided. Make sure app.provide(I18nDefaultLocaleKey, defaultLocale) is called.");
458
- const o = t?.locales || a, u = t?.defaultLocale || c, d = (l, r) => n?.resolvePath ? n.resolvePath(l, r || e.locale.value) : l;
474
+ const o = t?.locales || a, u = t?.defaultLocale || s, d = (i, r) => n?.resolvePath ? n.resolvePath(i, r || e.locale.value) : i;
459
475
  return {
460
476
  // Direct access to instance
461
477
  instance: e,
462
478
  // Locale (reactive)
463
- locale: I({
479
+ locale: S({
464
480
  get: () => e.locale.value,
465
- set: (l) => {
466
- e.locale.value = l;
481
+ set: (i) => {
482
+ e.locale.value = i;
467
483
  }
468
484
  }),
469
485
  // Locale helpers
@@ -472,14 +488,14 @@ function se(t) {
472
488
  getLocaleName: () => o.find((r) => r.code === e.locale.value)?.displayName || null,
473
489
  // Routing helpers
474
490
  localeRoute: d,
475
- localePath: (l, r) => {
476
- const i = d(l, r);
477
- return typeof i == "string" ? i : i.path || "/";
491
+ localePath: (i, r) => {
492
+ const l = d(i, r);
493
+ return typeof l == "string" ? l : l.path || "/";
478
494
  },
479
- switchLocale: (l) => {
480
- if (e.locale.value = l, n) {
481
- const r = n.getCurrentPath(), i = d(r, l);
482
- n.push(typeof i == "string" ? { path: i } : { path: i.path || "/" });
495
+ switchLocale: (i) => {
496
+ if (e.locale.value = i, n) {
497
+ const r = n.getCurrentPath(), l = d(r, i);
498
+ n.push(typeof l == "string" ? { path: l } : { path: l.path || "/" });
483
499
  }
484
500
  },
485
501
  // Translation methods (delegate to instance)
@@ -490,6 +506,8 @@ function se(t) {
490
506
  td: e.td.bind(e),
491
507
  tdr: e.tdr.bind(e),
492
508
  has: e.has.bind(e),
509
+ resolveTranslations: e.resolveTranslations.bind(e),
510
+ setTranslation: e.setTranslation.bind(e),
493
511
  // Route management
494
512
  setRoute: e.setRoute.bind(e),
495
513
  getRoute: e.getRoute.bind(e),
@@ -501,77 +519,77 @@ function se(t) {
501
519
  clearCache: e.clearCache.bind(e)
502
520
  };
503
521
  }
504
- function pe(t = {}) {
505
- const { addDirAttribute: e = !0, identifierAttribute: n = "id", addSeoAttributes: a = !0, baseUrl: c = "/" } = t, { getLocale: o, getLocales: u, localeRoute: d } = se(), l = k(E, void 0), r = q({
522
+ function ye(t = {}) {
523
+ const { addDirAttribute: e = !0, identifierAttribute: n = "id", addSeoAttributes: a = !0, baseUrl: s = "/" } = t, { getLocale: o, getLocales: u, localeRoute: d } = se(), i = k(E, void 0), r = G({
506
524
  htmlAttrs: {},
507
525
  link: [],
508
526
  meta: []
509
527
  });
510
- function i(m, b) {
511
- const w = new URL(m, "http://localhost"), S = new URLSearchParams(w.search), j = {};
528
+ function l(v, b) {
529
+ const w = new URL(v, "http://localhost"), P = new URLSearchParams(w.search), _ = {};
512
530
  for (const O of b)
513
- S.has(O) && (j[O] = S.get(O));
514
- const D = new URLSearchParams(j);
515
- return D.toString() ? `${w.pathname}?${D.toString()}` : w.pathname;
531
+ P.has(O) && (_[O] = P.get(O));
532
+ const I = new URLSearchParams(_);
533
+ return I.toString() ? `${w.pathname}?${I.toString()}` : w.pathname;
516
534
  }
517
- function h(m = []) {
518
- if (!l) {
535
+ function m(v = []) {
536
+ if (!i) {
519
537
  r.value = { htmlAttrs: {}, link: [], meta: [] };
520
538
  return;
521
539
  }
522
- const b = o(), w = u(), S = w.find((f) => f.code === b);
523
- if (!S)
540
+ const b = o(), w = u(), P = w.find((f) => f.code === b);
541
+ if (!P)
524
542
  return;
525
- const j = S.iso || b, D = G(S), O = S.dir || "auto";
526
- let $ = l.getCurrentPath();
527
- $.startsWith("/") || ($ = `/${$}`);
528
- const z = $.split("/").filter(Boolean), V = w.find((f) => z[0] === f.code);
529
- let L = $, C, s;
530
- const y = typeof c == "function" ? c() : c;
543
+ const _ = P.iso || b, I = Z(P), O = P.dir || "auto";
544
+ let C = i.getCurrentPath();
545
+ C.startsWith("/") || (C = `/${C}`);
546
+ const q = C.split("/").filter(Boolean), V = w.find((f) => q[0] === f.code);
547
+ let F = C, T, p;
548
+ const U = typeof s == "function" ? s() : s;
531
549
  if (V) {
532
- L = $.slice(V.code.length + 1) || "/", C = i(L, m);
550
+ F = C.slice(V.code.length + 1) || "/", T = l(F, v);
533
551
  const f = `/${b}`;
534
- s = `${y}${f}${C.startsWith("/") ? "" : "/"}${C}`;
552
+ p = `${U}${f}${T.startsWith("/") ? "" : "/"}${T}`;
535
553
  } else
536
- C = i($, m), s = `${y}${C.startsWith("/") ? "" : "/"}${C}`;
537
- const v = {
538
- lang: j,
554
+ T = l(C, v), p = `${U}${T.startsWith("/") ? "" : "/"}${T}`;
555
+ const c = {
556
+ lang: _,
539
557
  ...e ? { dir: O } : {}
540
558
  };
541
559
  if (!a) {
542
- r.value = { htmlAttrs: v, link: [], meta: [] };
560
+ r.value = { htmlAttrs: c, link: [], meta: [] };
543
561
  return;
544
562
  }
545
- const g = w.filter((f) => !f.disabled && f.seo !== !1);
546
- D || X(S, { tag: "og:locale" });
547
- const T = D ? {
563
+ const y = w.filter((f) => !f.disabled && f.seo !== !1);
564
+ I || Y(P, { tag: "og:locale" });
565
+ const L = I ? {
548
566
  [n]: "i18n-og",
549
567
  property: "og:locale",
550
- content: D
551
- } : null, _ = {
568
+ content: I
569
+ } : null, h = {
552
570
  [n]: "i18n-og-url",
553
571
  property: "og:url",
554
- content: s
555
- }, U = g.filter((f) => f.code !== b).map((f) => {
556
- const x = G(f);
572
+ content: p
573
+ }, j = y.filter((f) => f.code !== b).map((f) => {
574
+ const x = Z(f);
557
575
  return x ? {
558
576
  [n]: `i18n-og-alt-${x}`,
559
577
  property: "og:locale:alternate",
560
578
  content: x
561
- } : (X(f, { tag: "og:locale:alternate" }), null);
562
- }).filter((f) => f !== null), W = {
579
+ } : (Y(f, { tag: "og:locale:alternate" }), null);
580
+ }).filter((f) => f !== null), M = {
563
581
  [n]: "i18n-can",
564
582
  rel: "canonical",
565
- href: s
566
- }, F = g.flatMap((f) => {
567
- if (!d || !l)
583
+ href: p
584
+ }, W = y.flatMap((f) => {
585
+ if (!d || !i)
568
586
  return [];
569
- const x = l.getCurrentPath(), P = d(x, f.code), R = typeof P == "string" ? P : P?.path || "/";
570
- if (!R)
587
+ const x = i.getCurrentPath(), R = d(x, f.code), $ = typeof R == "string" ? R : R?.path || "/";
588
+ if (!$)
571
589
  return [];
572
590
  let H;
573
- R.startsWith("http://") || R.startsWith("https://") ? H = R : H = `${typeof c == "function" ? c() : c}${R.startsWith("/") ? "" : "/"}${R}`;
574
- const Q = [
591
+ $.startsWith("http://") || $.startsWith("https://") ? H = $ : H = `${typeof s == "function" ? s() : s}${$.startsWith("/") ? "" : "/"}${$}`;
592
+ const X = [
575
593
  {
576
594
  [n]: `i18n-alternate-${f.code}`,
577
595
  rel: "alternate",
@@ -579,36 +597,36 @@ function pe(t = {}) {
579
597
  hreflang: f.code
580
598
  }
581
599
  ];
582
- return f.iso && f.iso !== f.code && Q.push({
600
+ return f.iso && f.iso !== f.code && X.push({
583
601
  [n]: `i18n-alternate-${f.iso}`,
584
602
  rel: "alternate",
585
603
  href: H,
586
604
  hreflang: f.iso
587
- }), Q;
588
- }), M = k(J, void 0);
605
+ }), X;
606
+ }), D = k(Q, void 0);
589
607
  let A = null;
590
- const Y = M ? w.find((f) => f.code === M) : void 0;
591
- if (d && l && M && Y?.seo !== !1) {
592
- const f = l.getCurrentPath(), x = d(f, M), P = typeof x == "string" ? x : x?.path || "/";
593
- if (P) {
594
- let R;
595
- P.startsWith("http://") || P.startsWith("https://") ? R = P : R = `${typeof c == "function" ? c() : c}${P.startsWith("/") ? "" : "/"}${P}`, A = {
608
+ const K = D ? w.find((f) => f.code === D) : void 0;
609
+ if (d && i && D && K?.seo !== !1) {
610
+ const f = i.getCurrentPath(), x = d(f, D), R = typeof x == "string" ? x : x?.path || "/";
611
+ if (R) {
612
+ let $;
613
+ R.startsWith("http://") || R.startsWith("https://") ? $ = R : $ = `${typeof s == "function" ? s() : s}${R.startsWith("/") ? "" : "/"}${R}`, A = {
596
614
  [n]: "i18n-xd",
597
615
  rel: "alternate",
598
- href: R,
616
+ href: $,
599
617
  hreflang: "x-default"
600
618
  };
601
619
  }
602
620
  }
603
621
  r.value = {
604
- htmlAttrs: v,
605
- meta: [...T ? [T] : [], _, ...U],
606
- link: [W, ...F, ...A ? [A] : []]
622
+ htmlAttrs: c,
623
+ meta: [...L ? [L] : [], h, ...j],
624
+ link: [M, ...W, ...A ? [A] : []]
607
625
  };
608
626
  }
609
627
  return {
610
628
  metaObject: r,
611
- updateMeta: h
629
+ updateMeta: m
612
630
  };
613
631
  }
614
632
  class ue extends ae {
@@ -621,9 +639,9 @@ class ue extends ae {
621
639
  plural: e.plural,
622
640
  missingWarn: e.missingWarn,
623
641
  missingHandler: e.missingHandler
624
- }), this.listeners = /* @__PURE__ */ new Set(), this.storage = n, this._locale = K(e.locale), this._fallbackLocale = K(e.fallbackLocale || e.locale), this._currentRoute = K("index"), this._revision = K(0), e.messages)
625
- for (const [a, c] of Object.entries(e.messages))
626
- this.helper.loadTranslations(a, c);
642
+ }), this.listeners = /* @__PURE__ */ new Set(), this.storage = n, this._locale = B(e.locale), this._fallbackLocale = B(e.fallbackLocale || e.locale), this._currentRoute = B("index"), this._revision = B(0), e.messages)
643
+ for (const [a, s] of Object.entries(e.messages))
644
+ this.helper.loadTranslations(a, s);
627
645
  }
628
646
  get locale() {
629
647
  return this._locale;
@@ -655,8 +673,8 @@ class ue extends ae {
655
673
  addTranslations(e, n, a = !0) {
656
674
  super.loadTranslationsCore(e, n, a), this._revision.value++, this.notifyListeners();
657
675
  }
658
- addRouteTranslations(e, n, a, c = !0) {
659
- super.loadRouteTranslationsCore(e, n, a, c), this._revision.value++, this.notifyListeners();
676
+ addRouteTranslations(e, n, a, s = !0) {
677
+ super.loadRouteTranslationsCore(e, n, a, s), this._revision.value++, this.notifyListeners();
660
678
  }
661
679
  mergeTranslations(e, n, a) {
662
680
  this.helper.mergeTranslation(e, n, a, !0), this._revision.value++, this.notifyListeners();
@@ -664,23 +682,15 @@ class ue extends ae {
664
682
  clearCache() {
665
683
  super.clearCache(), this._revision.value++, this.notifyListeners();
666
684
  }
685
+ onTranslationsChanged() {
686
+ this._revision.value++, this.notifyListeners();
687
+ }
667
688
  subscribeToChanges(e) {
668
689
  return this.listeners.add(e), () => this.listeners.delete(e);
669
690
  }
670
691
  notifyListeners() {
671
692
  this.listeners.forEach((e) => e());
672
693
  }
673
- getAllTranslations() {
674
- const e = {};
675
- for (const [n, a] of this.storage.translations)
676
- if (!n.includes(":"))
677
- e[n] = a;
678
- else {
679
- const c = n.split(":")[0];
680
- c && (e[c] || (e[c] = {}), Object.assign(e[c], a));
681
- }
682
- return e;
683
- }
684
694
  getStorage() {
685
695
  return this.storage;
686
696
  }
@@ -691,8 +701,8 @@ class ue extends ae {
691
701
  return e;
692
702
  }
693
703
  }
694
- function ye(t) {
695
- const { routingStrategy: e, locales: n, defaultLocale: a, ...c } = t, o = new ue(c);
704
+ function me(t) {
705
+ const { routingStrategy: e, locales: n, defaultLocale: a, ...s } = t, o = new ue(s);
696
706
  let u = null, d = e || null;
697
707
  return {
698
708
  global: o,
@@ -702,19 +712,19 @@ function ye(t) {
702
712
  },
703
713
  // Method for setting adapter after creation
704
714
  install(r) {
705
- u = r, r.provide(N, o), d && r.provide(E, d), n && r.provide(Z, n), a && r.provide(J, a), r.config.globalProperties.$t = (i, h, m, b) => o.t(i, h, m, b), r.config.globalProperties.$ts = (i, h, m, b) => o.ts(i, h, m, b), r.config.globalProperties.$tc = (i, h, m) => o.tc(i, h, m), r.config.globalProperties.$tn = (i, h) => o.tn(i, h), r.config.globalProperties.$td = (i, h) => o.td(i, h), r.config.globalProperties.$tdr = (i, h) => o.tdr(i, h), r.config.globalProperties.$has = (i, h) => o.has(i, h), r.config.globalProperties.$i18n = o, r.component("I18nT", ce), r.component("I18nLink", le), r.component("I18nGroup", oe), r.component("I18nSwitcher", ie);
715
+ u = r, r.provide(N, o), d && r.provide(E, d), n && r.provide(J, n), a && r.provide(Q, a), r.config.globalProperties.$t = (l, m, v, b) => o.t(l, m, v, b), r.config.globalProperties.$ts = (l, m, v, b) => o.ts(l, m, v, b), r.config.globalProperties.$tc = (l, m, v) => o.tc(l, m, v), r.config.globalProperties.$tn = o.tn.bind(o), r.config.globalProperties.$td = o.td.bind(o), r.config.globalProperties.$tdr = o.tdr.bind(o), r.config.globalProperties.$has = (l, m) => o.has(l, m), r.config.globalProperties.$i18n = o, r.component("I18nT", ce), r.component("I18nLink", le), r.component("I18nGroup", re), r.component("I18nSwitcher", ie);
706
716
  }
707
717
  };
708
718
  }
709
- function me(t, e, n) {
710
- const a = e.map((o) => o.code), c = (o, u) => {
711
- const l = (typeof o == "string" ? o : o.path || "/").split("/").filter(Boolean), r = l[0];
712
- r !== void 0 && a.includes(r) && l.shift();
713
- const i = `/${l.join("/")}`;
714
- return u === n ? i : `/${u}${i === "/" ? "" : i}`;
719
+ function ve(t, e, n) {
720
+ const a = e.map((o) => o.code), s = (o, u) => {
721
+ const i = (typeof o == "string" ? o : o.path || "/").split("/").filter(Boolean), r = i[0];
722
+ r !== void 0 && a.includes(r) && i.shift();
723
+ const l = `/${i.join("/")}`;
724
+ return u === n ? l : `/${u}${l === "/" ? "" : l}`;
715
725
  };
716
726
  return {
717
- linkComponent: re,
727
+ linkComponent: oe,
718
728
  getCurrentPath: () => t.currentRoute.value.path,
719
729
  push: (o) => {
720
730
  t.push(o.path).catch(() => {
@@ -724,7 +734,7 @@ function me(t, e, n) {
724
734
  t.replace(o.path).catch(() => {
725
735
  });
726
736
  },
727
- resolvePath: (o, u) => c(o, u),
737
+ resolvePath: (o, u) => s(o, u),
728
738
  getRoute: () => ({
729
739
  fullPath: t.currentRoute.value.fullPath,
730
740
  query: t.currentRoute.value.query
@@ -733,19 +743,19 @@ function me(t, e, n) {
733
743
  }
734
744
  export {
735
745
  Le as FormatService,
736
- J as I18nDefaultLocaleKey,
737
- oe as I18nGroup,
746
+ Q as I18nDefaultLocaleKey,
747
+ re as I18nGroup,
738
748
  N as I18nInjectionKey,
739
749
  le as I18nLink,
740
- Z as I18nLocalesKey,
750
+ J as I18nLocalesKey,
741
751
  ie as I18nSwitcher,
742
752
  ce as I18nT,
743
753
  ue as VueI18n,
744
- ye as createI18n,
745
- me as createVueRouterAdapter,
754
+ me as createI18n,
755
+ ve as createVueRouterAdapter,
746
756
  ke as defaultPlural,
747
- we as interpolate,
757
+ Se as interpolate,
748
758
  se as useI18n,
749
- pe as useLocaleHead
759
+ ye as useLocaleHead
750
760
  };
751
761
  //# sourceMappingURL=index.mjs.map