@voltro/i18n 0.86.0 → 0.88.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/CHANGELOG.md +5484 -0
- package/THIRD-PARTY-NOTICES.md +1 -1
- package/dist/catalog.js +1 -2
- package/dist/components.js +1 -2
- package/dist/cookieNames.js +1 -2
- package/dist/format.js +1 -2
- package/dist/formatterCache.js +1 -2
- package/dist/hooks.js +1 -2
- package/dist/instanceRegistry.js +1 -2
- package/dist/lazyCatalog.js +1 -2
- package/dist/lazyProvider.js +1 -2
- package/dist/localeSwitcher.js +1 -2
- package/dist/provider.js +1 -2
- package/dist/renderClock.js +1 -2
- package/dist/server.d.ts +8 -1
- package/dist/server.js +16 -14
- package/dist/ssgWrap.js +1 -2
- package/dist/timeZone.js +1 -2
- package/dist/typed.js +1 -2
- package/package.json +1 -1
package/THIRD-PARTY-NOTICES.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Third-Party Notices — @voltro/i18n
|
|
2
2
|
|
|
3
|
-
This package uses the
|
|
3
|
+
This package uses the third-party software listed below. Each is the
|
|
4
4
|
property of its respective copyright holders and is used under the terms of
|
|
5
5
|
its license. This file is provided for attribution; it grants no rights in
|
|
6
6
|
@voltro/i18n itself, which is proprietary (see LICENSE).
|
package/dist/catalog.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/catalog.ts
|
|
2
2
|
var e = (e) => e, t = () => (e) => e, n = (e, t, n) => e[t ?? n] ?? e[n], r = (e) => {
|
|
3
3
|
let t = /* @__PURE__ */ new Set();
|
|
4
4
|
if (!e.includes("{")) return t;
|
|
@@ -90,5 +90,4 @@ var e = (e) => e, t = () => (e) => e, n = (e, t, n) => e[t ?? n] ?? e[n], r = (e
|
|
|
90
90
|
if (t?.onMismatch === "warn") console.warn(l);
|
|
91
91
|
else throw Error(l);
|
|
92
92
|
};
|
|
93
|
-
//#endregion
|
|
94
93
|
export { o as assertCatalogParity, e as defineCatalog, t as defineLocale, n as pickCatalog, r as placeholdersOf };
|
package/dist/components.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { FormattedMessage as e } from "react-intl";
|
|
2
2
|
import { jsx as t } from "react/jsx-runtime";
|
|
3
|
-
|
|
3
|
+
// src/components.tsx
|
|
4
4
|
var n = ({ id: n, ...r }) => /* @__PURE__ */ t(e, {
|
|
5
5
|
id: n,
|
|
6
6
|
...r
|
|
7
7
|
});
|
|
8
|
-
//#endregion
|
|
9
8
|
export { n as T };
|
package/dist/cookieNames.js
CHANGED
package/dist/format.js
CHANGED
|
@@ -3,7 +3,7 @@ import { useLocale as t } from "./hooks.js";
|
|
|
3
3
|
import { dateTimeFormat as n, numberFormat as r, pluralRules as i, relativeTimeFormat as a } from "./formatterCache.js";
|
|
4
4
|
import { useCallback as o, useMemo as s } from "react";
|
|
5
5
|
import { useIntl as c } from "react-intl";
|
|
6
|
-
|
|
6
|
+
// src/format.ts
|
|
7
7
|
var l = (e, t, n, r) => {
|
|
8
8
|
if (t === 0 && n.zero !== void 0) return n.zero.replace(/\{count\}/g, String(t));
|
|
9
9
|
let a = "other";
|
|
@@ -91,5 +91,4 @@ var l = (e, t, n, r) => {
|
|
|
91
91
|
o
|
|
92
92
|
]);
|
|
93
93
|
};
|
|
94
|
-
//#endregion
|
|
95
94
|
export { m as formatDateValue, l as plural, y as useFormatCurrency, h as useFormatDate, v as useFormatNumber, b as useFormatters, u as usePlural, _ as useRelativeTime, p as useTimeZone };
|
package/dist/formatterCache.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/formatterCache.ts
|
|
2
2
|
var e = (e, t, n = () => !0) => {
|
|
3
3
|
let r = /* @__PURE__ */ new Map(), i = new Set(e), a = t();
|
|
4
4
|
return (o, s) => {
|
|
@@ -77,5 +77,4 @@ var e = (e, t, n = () => !0) => {
|
|
|
77
77
|
"numeric",
|
|
78
78
|
"style"
|
|
79
79
|
], () => Intl.RelativeTimeFormat);
|
|
80
|
-
//#endregion
|
|
81
80
|
export { r as dateTimeFormat, i as numberFormat, n as pluralRules, a as relativeTimeFormat };
|
package/dist/hooks.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { useCallback as e } from "react";
|
|
2
2
|
import { useIntl as t } from "react-intl";
|
|
3
|
-
|
|
3
|
+
// src/hooks.ts
|
|
4
4
|
var n = (e, n) => t().formatMessage({ id: e }, n), r = () => t().locale, i = () => t().messages, a = () => {
|
|
5
5
|
let n = t();
|
|
6
6
|
return e((e, t) => n.formatMessage({ id: e }, t), [n]);
|
|
7
7
|
};
|
|
8
|
-
//#endregion
|
|
9
8
|
export { r as useLocale, i as useMessages, n as useT, a as useTFn };
|
package/dist/instanceRegistry.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/instanceRegistry.ts
|
|
2
2
|
var e = "__voltro_i18n_instances__", t = () => {
|
|
3
3
|
let t = globalThis, n = t[e];
|
|
4
4
|
if (n !== void 0) return n;
|
|
@@ -26,5 +26,4 @@ var e = "__voltro_i18n_instances__", t = () => {
|
|
|
26
26
|
files: [...new Set(t.map((e) => e.file))]
|
|
27
27
|
};
|
|
28
28
|
};
|
|
29
|
-
//#endregion
|
|
30
29
|
export { i as i18nInstanceReport, r as registerI18nInstance };
|
package/dist/lazyCatalog.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/lazyCatalog.ts
|
|
2
2
|
var e = (e) => "default" in e && typeof e.default == "object" ? e.default : e, t = (t, n) => {
|
|
3
3
|
let r = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map(), a = (e) => e && e in t ? e : n, o = (n) => {
|
|
4
4
|
let o = a(n), s = r.get(o);
|
|
@@ -23,5 +23,4 @@ var e = (e) => "default" in e && typeof e.default == "object" ? e.default : e, t
|
|
|
23
23
|
}
|
|
24
24
|
};
|
|
25
25
|
};
|
|
26
|
-
//#endregion
|
|
27
26
|
export { t as defineCatalogs };
|
package/dist/lazyProvider.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { I18nProvider as e } from "./provider.js";
|
|
2
2
|
import { useEffect as t, useState as n } from "react";
|
|
3
3
|
import { jsx as r } from "react/jsx-runtime";
|
|
4
|
-
|
|
4
|
+
// src/lazyProvider.tsx
|
|
5
5
|
var i = ({ catalogs: i, locale: a, fallback: o = null, silenceMissingTranslations: s, children: c }) => {
|
|
6
6
|
let [l, u] = n(() => i.peek(a));
|
|
7
7
|
return t(() => {
|
|
@@ -24,5 +24,4 @@ var i = ({ catalogs: i, locale: a, fallback: o = null, silenceMissingTranslation
|
|
|
24
24
|
children: c
|
|
25
25
|
}) : o;
|
|
26
26
|
};
|
|
27
|
-
//#endregion
|
|
28
27
|
export { i as LazyI18nProvider };
|
package/dist/localeSwitcher.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { LOCALE_COOKIE as e } from "./cookieNames.js";
|
|
2
2
|
import { useEffect as t, useState as n } from "react";
|
|
3
3
|
import { jsx as r } from "react/jsx-runtime";
|
|
4
|
-
|
|
4
|
+
// src/localeSwitcher.tsx
|
|
5
5
|
var i = 3456e4, a = (e) => {
|
|
6
6
|
if (typeof document < "u") for (let t of document.cookie.split(";")) {
|
|
7
7
|
let n = t.indexOf("=");
|
|
@@ -33,5 +33,4 @@ var i = 3456e4, a = (e) => {
|
|
|
33
33
|
}, e.code))
|
|
34
34
|
});
|
|
35
35
|
};
|
|
36
|
-
//#endregion
|
|
37
36
|
export { s as LocaleSwitcher };
|
package/dist/provider.js
CHANGED
|
@@ -4,7 +4,7 @@ import { isSupportedTimeZone as n } from "./timeZone.js";
|
|
|
4
4
|
import { useEffect as r, useState as i } from "react";
|
|
5
5
|
import { IntlProvider as a } from "react-intl";
|
|
6
6
|
import { jsx as o } from "react/jsx-runtime";
|
|
7
|
-
|
|
7
|
+
// src/provider.tsx
|
|
8
8
|
e(a);
|
|
9
9
|
var s = (e) => {
|
|
10
10
|
e.code !== "MISSING_TRANSLATION" && console.error(e);
|
|
@@ -27,5 +27,4 @@ var s = (e) => {
|
|
|
27
27
|
})
|
|
28
28
|
});
|
|
29
29
|
};
|
|
30
|
-
//#endregion
|
|
31
30
|
export { c as I18nProvider };
|
package/dist/renderClock.js
CHANGED
package/dist/server.d.ts
CHANGED
|
@@ -29,13 +29,15 @@ export declare const LOCALE_COOKIE = "voltro:locale";
|
|
|
29
29
|
* spread the result and omit `outerWrap` entirely rather than passing an
|
|
30
30
|
* identity wrap — an app without locales must render exactly as before.
|
|
31
31
|
*/
|
|
32
|
-
export declare const makeSsrI18nResolver: (args: SsrI18nResolverArgs) => ((cookieHeader?: string | null, acceptLanguageHeader?: string | null, routeLocale?: string | null) => ResolvedSsrI18n | undefined);
|
|
32
|
+
export declare const makeSsrI18nResolver: (args: SsrI18nResolverArgs) => ((cookieHeader?: string | null, acceptLanguageHeader?: string | null, routeLocale?: string | null, request?: SsrI18nRenderRequest) => ResolvedSsrI18n | undefined);
|
|
33
33
|
|
|
34
34
|
declare type MessageCatalog = Readonly<Record<string, string>>;
|
|
35
35
|
|
|
36
36
|
/** What a renderer needs to render one request in the right locale. */
|
|
37
37
|
export declare interface ResolvedSsrI18n {
|
|
38
38
|
readonly locale: string;
|
|
39
|
+
/** The exact instant bound to this request's provider. */
|
|
40
|
+
readonly renderedAt: number;
|
|
39
41
|
/**
|
|
40
42
|
* The IANA zone this request renders in, or `undefined` when the app pins
|
|
41
43
|
* none. The renderer PUBLISHES it (`<html data-voltro-tz>`) so the client's
|
|
@@ -103,6 +105,11 @@ export declare interface ResolveTimeZoneArgs {
|
|
|
103
105
|
readonly defaultTimeZone?: string | null;
|
|
104
106
|
}
|
|
105
107
|
|
|
108
|
+
export declare interface SsrI18nRenderRequest {
|
|
109
|
+
/** Use a retained render instant without replacing the host's real clock. */
|
|
110
|
+
readonly renderedAt?: number;
|
|
111
|
+
}
|
|
112
|
+
|
|
106
113
|
export declare interface SsrI18nResolverArgs {
|
|
107
114
|
/**
|
|
108
115
|
* Per-locale `<I18nProvider>` wrappers, built by the caller with
|
package/dist/server.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DEFAULT_TIME_ZONE as e, VIEWER_TIME_ZONE as t, isSupportedTimeZone as n } from "./timeZone.js";
|
|
2
2
|
import { LOCALE_COOKIE as r, THEME_COOKIE as i, TIMEZONE_COOKIE as a } from "./cookieNames.js";
|
|
3
|
-
|
|
3
|
+
// src/server.ts
|
|
4
4
|
var o = r, s = (e) => RegExp(`(?:^|;\\s*)${e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}=([^;]*)`), c = s(o), l = s(a), u = (e, t) => {
|
|
5
5
|
if (!e) return;
|
|
6
6
|
let n = e.match(t);
|
|
@@ -55,30 +55,32 @@ var o = r, s = (e) => RegExp(`(?:^|;\\s*)${e.replace(/[.*+?^${}()|[\]\\]/g, "\\$
|
|
|
55
55
|
return n(a) ? a : n(i) ? i : "UTC";
|
|
56
56
|
}, h = (e) => {
|
|
57
57
|
let { wraps: t, supported: n, defaultLocale: r } = e;
|
|
58
|
-
return Object.keys(t).length === 0 ? () => void 0 : (i, a, o) => {
|
|
59
|
-
let
|
|
58
|
+
return Object.keys(t).length === 0 ? () => void 0 : (i, a, o, s) => {
|
|
59
|
+
let c = p({
|
|
60
60
|
routeLocale: o ?? null,
|
|
61
61
|
cookieHeader: i ?? null,
|
|
62
62
|
acceptLanguageHeader: a ?? null,
|
|
63
63
|
supported: n,
|
|
64
64
|
defaultLocale: r
|
|
65
|
-
}),
|
|
65
|
+
}), l = m({
|
|
66
66
|
cookieHeader: i ?? null,
|
|
67
67
|
configured: e.timeZone ?? null,
|
|
68
68
|
defaultTimeZone: e.defaultTimeZone ?? null
|
|
69
|
-
}),
|
|
70
|
-
if (u
|
|
71
|
-
let d =
|
|
69
|
+
}), u = s?.renderedAt ?? (e.now ?? Date.now)();
|
|
70
|
+
if (!Number.isSafeInteger(u) || !Number.isFinite(new Date(u).getTime())) throw RangeError("Invalid render instant");
|
|
71
|
+
let d = t[c] ?? t[r];
|
|
72
|
+
if (d === void 0) return;
|
|
73
|
+
let f = e.catalogs?.[c] ?? e.catalogs?.[r];
|
|
72
74
|
return {
|
|
73
|
-
locale:
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
75
|
+
locale: c,
|
|
76
|
+
renderedAt: u,
|
|
77
|
+
timeZone: l,
|
|
78
|
+
outerWrap: (e) => d(e, {
|
|
79
|
+
timeZone: l,
|
|
80
|
+
renderedAt: u
|
|
78
81
|
}),
|
|
79
|
-
...
|
|
82
|
+
...f === void 0 ? {} : { messages: f }
|
|
80
83
|
};
|
|
81
84
|
};
|
|
82
85
|
};
|
|
83
|
-
//#endregion
|
|
84
86
|
export { e as DEFAULT_TIME_ZONE, r as LOCALE_COOKIE, i as THEME_COOKIE, a as TIMEZONE_COOKIE, t as VIEWER_TIME_ZONE, n as isSupportedTimeZone, h as makeSsrI18nResolver, p as resolveLocale, m as resolveTimeZone };
|
package/dist/ssgWrap.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { I18nProvider as e } from "./provider.js";
|
|
2
2
|
import { createElement as t } from "react";
|
|
3
|
-
|
|
3
|
+
// src/ssgWrap.tsx
|
|
4
4
|
var n = (n, r, i) => (a, o) => t(e, {
|
|
5
5
|
locale: n,
|
|
6
6
|
messages: r,
|
|
@@ -10,5 +10,4 @@ var n = (n, r, i) => (a, o) => t(e, {
|
|
|
10
10
|
...o?.renderedAt === void 0 ? {} : { renderedAt: o.renderedAt },
|
|
11
11
|
children: a
|
|
12
12
|
});
|
|
13
|
-
//#endregion
|
|
14
13
|
export { n as makeSsgWrap };
|
package/dist/timeZone.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/timeZone.ts
|
|
2
2
|
var e = "viewer", t = "UTC", n = (e) => {
|
|
3
3
|
if (!e) return !1;
|
|
4
4
|
try {
|
|
@@ -7,5 +7,4 @@ var e = "viewer", t = "UTC", n = (e) => {
|
|
|
7
7
|
return !1;
|
|
8
8
|
}
|
|
9
9
|
};
|
|
10
|
-
//#endregion
|
|
11
10
|
export { t as DEFAULT_TIME_ZONE, e as VIEWER_TIME_ZONE, n as isSupportedTimeZone };
|
package/dist/typed.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { T as e } from "./components.js";
|
|
2
2
|
import { useT as t, useTFn as n } from "./hooks.js";
|
|
3
|
-
|
|
3
|
+
// src/typed.ts
|
|
4
4
|
var r = (e) => {
|
|
5
5
|
let t = e;
|
|
6
6
|
return t.dynamic === void 0 && (t.dynamic = (t, n) => e(t, n)), t;
|
|
@@ -9,5 +9,4 @@ var r = (e) => {
|
|
|
9
9
|
useTFn: (() => r(n())),
|
|
10
10
|
T: e
|
|
11
11
|
});
|
|
12
|
-
//#endregion
|
|
13
12
|
export { i as createTypedMessages };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@voltro/i18n",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.88.0",
|
|
4
4
|
"description": "Voltro's i18n layer — thin opinionated wrap over react-intl. Provides the framework's locale-resolution conventions (voltro:locale cookie + Accept-Language fallback), a typed message-catalog helper, and a slim provider component. Power users can import directly from react-intl for advanced APIs.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"voltro",
|