@i18n-micro/astro 1.3.13 → 1.3.18

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.
@@ -1,17 +1,6 @@
1
- import { h as s, t as o } from "../core-Bk6qZuDf.js";
2
- import { I18nProvider as a, useAstroI18n as n } from "./preact.js";
3
- import { I18nProvider as u, useAstroI18n as A } from "./react.js";
4
- import { createI18nStore as f, useAstroI18n as i } from "./svelte.js";
5
- import { provideI18n as v, useAstroI18n as x } from "./vue.js";
6
- export {
7
- u as I18nProvider,
8
- a as I18nProviderPreact,
9
- f as createI18nStore,
10
- s as hasTranslation,
11
- v as provideI18n,
12
- o as translate,
13
- n as useAstroI18nPreact,
14
- A as useAstroI18nReact,
15
- i as useAstroI18nSvelte,
16
- x as useAstroI18nVue
17
- };
1
+ import { n as e, t } from "../core-VSnkGRWR.js";
2
+ import { I18nProvider as n, useAstroI18n as r } from "./preact.js";
3
+ import { I18nProvider as i, useAstroI18n as a } from "./react.js";
4
+ import { createI18nStore as o, useAstroI18n as s } from "./svelte.js";
5
+ import { n as c, t as l } from "../vue-CyIbewNw.js";
6
+ export { i as I18nProvider, n as I18nProviderPreact, o as createI18nStore, t as hasTranslation, l as provideI18n, e as translate, r as useAstroI18nPreact, a as useAstroI18nReact, s as useAstroI18nSvelte, c as useAstroI18nVue };
@@ -1,66 +1,37 @@
1
- import { FormatService as g, defaultPlural as w } from "@i18n-micro/core";
2
- import { createContext as x, createElement as L } from "preact";
3
- import { useState as P, useContext as S, useMemo as a } from "preact/hooks";
4
- import { t as C, h as A } from "../core-Bk6qZuDf.js";
5
- const s = new g(), i = x(null), F = ({ children: t, value: o }) => {
6
- const [l] = P(() => ({
7
- locale: o.locale,
8
- fallbackLocale: o.fallbackLocale,
9
- translations: o.translations,
10
- currentRoute: o.currentRoute
11
- }));
12
- return L(i.Provider, { value: l }, t);
1
+ import { n as e, t } from "../core-VSnkGRWR.js";
2
+ import { FormatService as n, defaultPlural as r } from "@i18n-micro/core";
3
+ import { createContext as i, createElement as a } from "preact";
4
+ import { useContext as o, useMemo as s, useState as c } from "preact/hooks";
5
+ //#region src/client/preact.tsx
6
+ var l = new n(), u = i(null), d = ({ children: e, value: t }) => {
7
+ let [n] = c(() => ({
8
+ locale: t.locale,
9
+ fallbackLocale: t.fallbackLocale,
10
+ translations: t.translations,
11
+ currentRoute: t.currentRoute
12
+ }));
13
+ return a(u.Provider, { value: n }, e);
13
14
  };
14
- function M() {
15
- const t = S(i);
16
- if (!t)
17
- throw new Error("useAstroI18n must be used within an I18nProvider");
18
- const o = a(
19
- () => (r, e, n, c) => C(t, r, e, n, c),
20
- [t]
21
- ), l = a(
22
- () => (r, e, n, c) => o(r, e, n, c)?.toString() ?? n ?? r,
23
- [o]
24
- ), m = a(
25
- () => (r, e, n) => {
26
- const { count: c, ...u } = typeof e == "number" ? { count: e } : e;
27
- if (c === void 0)
28
- return n ?? r;
29
- const d = (v, I, h) => o(v, I, h);
30
- return w(r, Number.parseInt(c.toString(), 10), u, t.locale, d) ?? n ?? r;
31
- },
32
- [o, t]
33
- ), f = a(
34
- () => (r, e) => s.formatNumber(r, t.locale, e),
35
- [t.locale]
36
- ), b = a(
37
- () => (r, e) => s.formatDate(r, t.locale, e),
38
- [t.locale]
39
- ), p = a(
40
- () => (r, e) => s.formatRelativeTime(r, t.locale, e),
41
- [t.locale]
42
- ), R = a(
43
- () => (r, e) => A(t, r, e),
44
- [t]
45
- );
46
- return {
47
- // Translation methods
48
- t: o,
49
- ts: l,
50
- tc: m,
51
- tn: f,
52
- td: b,
53
- tdr: p,
54
- has: R,
55
- // Locale state
56
- locale: t.locale,
57
- fallbackLocale: t.fallbackLocale,
58
- currentRoute: t.currentRoute,
59
- // Route management (read-only в клиентских островах)
60
- getRoute: () => t.currentRoute
61
- };
15
+ function f() {
16
+ let n = o(u);
17
+ if (!n) throw Error("useAstroI18n must be used within an I18nProvider");
18
+ let i = s(() => (t, r, i, a) => e(n, t, r, i, a), [n]);
19
+ return {
20
+ t: i,
21
+ ts: s(() => (e, t, n, r) => i(e, t, n, r)?.toString() ?? n ?? e, [i]),
22
+ tc: s(() => (e, t, a) => {
23
+ let { count: o, ...s } = typeof t == "number" ? { count: t } : t;
24
+ return o === void 0 ? a ?? e : r(e, Number.parseInt(o.toString(), 10), s, n.locale, (e, t, n) => i(e, t, n)) ?? a ?? e;
25
+ }, [i, n]),
26
+ tn: s(() => (e, t) => l.formatNumber(e, n.locale, t), [n.locale]),
27
+ td: s(() => (e, t) => l.formatDate(e, n.locale, t), [n.locale]),
28
+ tdr: s(() => (e, t) => l.formatRelativeTime(e, n.locale, t), [n.locale]),
29
+ has: s(() => (e, r) => t(n, e, r), [n]),
30
+ locale: n.locale,
31
+ fallbackLocale: n.fallbackLocale,
32
+ currentRoute: n.currentRoute,
33
+ getRoute: () => n.currentRoute
34
+ };
62
35
  }
63
- export {
64
- F as I18nProvider,
65
- M as useAstroI18n
66
- };
36
+ //#endregion
37
+ export { d as I18nProvider, f as useAstroI18n };
@@ -1,66 +1,37 @@
1
- import { FormatService as g, defaultPlural as w } from "@i18n-micro/core";
2
- import x, { createContext as L, useState as P, useContext as S, useMemo as a } from "react";
3
- import { t as C, h as A } from "../core-Bk6qZuDf.js";
4
- const s = new g(), i = L(null);
5
- function D({ children: t, value: o }) {
6
- const [l] = P(() => ({
7
- locale: o.locale,
8
- fallbackLocale: o.fallbackLocale,
9
- translations: o.translations,
10
- currentRoute: o.currentRoute
11
- }));
12
- return x.createElement(i.Provider, { value: l }, t);
1
+ import { n as e, t } from "../core-VSnkGRWR.js";
2
+ import { FormatService as n, defaultPlural as r } from "@i18n-micro/core";
3
+ import i, { createContext as a, useContext as o, useMemo as s, useState as c } from "react";
4
+ //#region src/client/react.tsx
5
+ var l = new n(), u = a(null);
6
+ function d({ children: e, value: t }) {
7
+ let [n] = c(() => ({
8
+ locale: t.locale,
9
+ fallbackLocale: t.fallbackLocale,
10
+ translations: t.translations,
11
+ currentRoute: t.currentRoute
12
+ }));
13
+ return i.createElement(u.Provider, { value: n }, e);
13
14
  }
14
- function F() {
15
- const t = S(i);
16
- if (!t)
17
- throw new Error("useAstroI18n must be used within an I18nProvider");
18
- const o = a(
19
- () => (e, r, n, c) => C(t, e, r, n, c),
20
- [t]
21
- ), l = a(
22
- () => (e, r, n, c) => o(e, r, n, c)?.toString() ?? n ?? e,
23
- [o]
24
- ), m = a(
25
- () => (e, r, n) => {
26
- const { count: c, ...u } = typeof r == "number" ? { count: r } : r;
27
- if (c === void 0)
28
- return n ?? e;
29
- const d = (v, I, h) => o(v, I, h);
30
- return w(e, Number.parseInt(c.toString(), 10), u, t.locale, d) ?? n ?? e;
31
- },
32
- [o, t]
33
- ), f = a(
34
- () => (e, r) => s.formatNumber(e, t.locale, r),
35
- [t.locale]
36
- ), b = a(
37
- () => (e, r) => s.formatDate(e, t.locale, r),
38
- [t.locale]
39
- ), R = a(
40
- () => (e, r) => s.formatRelativeTime(e, t.locale, r),
41
- [t.locale]
42
- ), p = a(
43
- () => (e, r) => A(t, e, r),
44
- [t]
45
- );
46
- return {
47
- // Translation methods
48
- t: o,
49
- ts: l,
50
- tc: m,
51
- tn: f,
52
- td: b,
53
- tdr: R,
54
- has: p,
55
- // Locale state
56
- locale: t.locale,
57
- fallbackLocale: t.fallbackLocale,
58
- currentRoute: t.currentRoute,
59
- // Route management (read-only в клиентских островах)
60
- getRoute: () => t.currentRoute
61
- };
15
+ function f() {
16
+ let n = o(u);
17
+ if (!n) throw Error("useAstroI18n must be used within an I18nProvider");
18
+ let i = s(() => (t, r, i, a) => e(n, t, r, i, a), [n]);
19
+ return {
20
+ t: i,
21
+ ts: s(() => (e, t, n, r) => i(e, t, n, r)?.toString() ?? n ?? e, [i]),
22
+ tc: s(() => (e, t, a) => {
23
+ let { count: o, ...s } = typeof t == "number" ? { count: t } : t;
24
+ return o === void 0 ? a ?? e : r(e, Number.parseInt(o.toString(), 10), s, n.locale, (e, t, n) => i(e, t, n)) ?? a ?? e;
25
+ }, [i, n]),
26
+ tn: s(() => (e, t) => l.formatNumber(e, n.locale, t), [n.locale]),
27
+ td: s(() => (e, t) => l.formatDate(e, n.locale, t), [n.locale]),
28
+ tdr: s(() => (e, t) => l.formatRelativeTime(e, n.locale, t), [n.locale]),
29
+ has: s(() => (e, r) => t(n, e, r), [n]),
30
+ locale: n.locale,
31
+ fallbackLocale: n.fallbackLocale,
32
+ currentRoute: n.currentRoute,
33
+ getRoute: () => n.currentRoute
34
+ };
62
35
  }
63
- export {
64
- D as I18nProvider,
65
- F as useAstroI18n
66
- };
36
+ //#endregion
37
+ export { d as I18nProvider, f as useAstroI18n };
@@ -1,64 +1,62 @@
1
- import { FormatService as R, defaultPlural as b } from "@i18n-micro/core";
2
- import { writable as d, get as v } from "svelte/store";
3
- import { h as L, t as S } from "../core-Bk6qZuDf.js";
4
- const l = new R();
5
- function F(o) {
6
- return d({
7
- locale: o.locale,
8
- fallbackLocale: o.fallbackLocale,
9
- translations: o.translations,
10
- currentRoute: o.currentRoute
11
- });
1
+ import { n as e, t } from "../core-VSnkGRWR.js";
2
+ import { FormatService as n, defaultPlural as r } from "@i18n-micro/core";
3
+ import { get as i, writable as a } from "svelte/store";
4
+ //#region src/client/svelte.ts
5
+ var o = new n();
6
+ function s(e) {
7
+ return a({
8
+ locale: e.locale,
9
+ fallbackLocale: e.fallbackLocale,
10
+ translations: e.translations,
11
+ currentRoute: e.currentRoute
12
+ });
12
13
  }
13
- function P(o) {
14
- const n = () => v(o), c = (t, e, r, a) => S(n(), t, e, r, a);
15
- return {
16
- // Store for reactivity in templates (use $i18nStore in templates)
17
- store: o,
18
- // Translation methods
19
- t: c,
20
- ts: (t, e, r, a) => c(t, e, r, a)?.toString() ?? r ?? t,
21
- tc: (t, e, r) => {
22
- const a = n(), { count: u, ...s } = typeof e == "number" ? { count: e } : e;
23
- if (u === void 0)
24
- return r ?? t;
25
- const i = (m, f, g) => c(m, f, g);
26
- return b(t, Number.parseInt(u.toString(), 10), s, a.locale, i) ?? r ?? t;
27
- },
28
- tn: (t, e) => {
29
- const r = n();
30
- return l.formatNumber(t, r.locale, e);
31
- },
32
- td: (t, e) => {
33
- const r = n();
34
- return l.formatDate(t, r.locale, e);
35
- },
36
- tdr: (t, e) => {
37
- const r = n();
38
- return l.formatRelativeTime(t, r.locale, e);
39
- },
40
- has: (t, e) => L(n(), t, e),
41
- // Getters for current state (for use in scripts)
42
- get locale() {
43
- return n().locale;
44
- },
45
- get fallbackLocale() {
46
- return n().fallbackLocale;
47
- },
48
- get currentRoute() {
49
- return n().currentRoute;
50
- },
51
- // Route management
52
- setLocale: (t) => {
53
- o.update((e) => ({ ...e, locale: t }));
54
- },
55
- setRoute: (t) => {
56
- o.update((e) => ({ ...e, currentRoute: t }));
57
- },
58
- getRoute: () => n().currentRoute
59
- };
14
+ function c(n) {
15
+ let a = () => i(n), s = (t, n, r, i) => e(a(), t, n, r, i);
16
+ return {
17
+ store: n,
18
+ t: s,
19
+ ts: (e, t, n, r) => s(e, t, n, r)?.toString() ?? n ?? e,
20
+ tc: (e, t, n) => {
21
+ let i = a(), { count: o, ...c } = typeof t == "number" ? { count: t } : t;
22
+ return o === void 0 ? n ?? e : r(e, Number.parseInt(o.toString(), 10), c, i.locale, (e, t, n) => s(e, t, n)) ?? n ?? e;
23
+ },
24
+ tn: (e, t) => {
25
+ let n = a();
26
+ return o.formatNumber(e, n.locale, t);
27
+ },
28
+ td: (e, t) => {
29
+ let n = a();
30
+ return o.formatDate(e, n.locale, t);
31
+ },
32
+ tdr: (e, t) => {
33
+ let n = a();
34
+ return o.formatRelativeTime(e, n.locale, t);
35
+ },
36
+ has: (e, n) => t(a(), e, n),
37
+ get locale() {
38
+ return a().locale;
39
+ },
40
+ get fallbackLocale() {
41
+ return a().fallbackLocale;
42
+ },
43
+ get currentRoute() {
44
+ return a().currentRoute;
45
+ },
46
+ setLocale: (e) => {
47
+ n.update((t) => ({
48
+ ...t,
49
+ locale: e
50
+ }));
51
+ },
52
+ setRoute: (e) => {
53
+ n.update((t) => ({
54
+ ...t,
55
+ currentRoute: e
56
+ }));
57
+ },
58
+ getRoute: () => a().currentRoute
59
+ };
60
60
  }
61
- export {
62
- F as createI18nStore,
63
- P as useAstroI18n
64
- };
61
+ //#endregion
62
+ export { s as createI18nStore, c as useAstroI18n };