@nice2dev/i18n 1.1.9 → 1.1.10

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.
Files changed (94) hide show
  1. package/dist/calendar-systems.cjs +1 -0
  2. package/dist/calendar-systems.mjs +412 -0
  3. package/dist/dictionaries/ar.cjs +1 -0
  4. package/dist/dictionaries/ar.mjs +375 -0
  5. package/dist/dictionaries/bg.cjs +1 -0
  6. package/dist/dictionaries/bg.mjs +67 -0
  7. package/dist/dictionaries/bn.cjs +1 -0
  8. package/dist/dictionaries/bn.mjs +23 -0
  9. package/dist/dictionaries/cs.cjs +1 -0
  10. package/dist/dictionaries/cs.mjs +375 -0
  11. package/dist/dictionaries/da.cjs +1 -0
  12. package/dist/dictionaries/da.mjs +75 -0
  13. package/dist/dictionaries/de.cjs +1 -0
  14. package/dist/dictionaries/de.mjs +3398 -0
  15. package/dist/dictionaries/en.cjs +1 -0
  16. package/dist/dictionaries/en.mjs +3443 -0
  17. package/dist/dictionaries/es.cjs +1 -0
  18. package/dist/dictionaries/es.mjs +3396 -0
  19. package/dist/dictionaries/fi.cjs +1 -0
  20. package/dist/dictionaries/fi.mjs +75 -0
  21. package/dist/dictionaries/fil.cjs +1 -0
  22. package/dist/dictionaries/fil.mjs +19 -0
  23. package/dist/dictionaries/fr.cjs +1 -0
  24. package/dist/dictionaries/fr.mjs +3398 -0
  25. package/dist/dictionaries/hi.cjs +1 -0
  26. package/dist/dictionaries/hi.mjs +23 -0
  27. package/dist/dictionaries/hu.cjs +1 -0
  28. package/dist/dictionaries/hu.mjs +75 -0
  29. package/dist/dictionaries/id.cjs +1 -0
  30. package/dist/dictionaries/id.mjs +23 -0
  31. package/dist/dictionaries/index.cjs +1 -0
  32. package/dist/dictionaries/index.mjs +95 -0
  33. package/dist/dictionaries/it.cjs +1 -0
  34. package/dist/dictionaries/it.mjs +297 -0
  35. package/dist/dictionaries/ja.cjs +1 -0
  36. package/dist/dictionaries/ja.mjs +375 -0
  37. package/dist/dictionaries/ko.cjs +1 -0
  38. package/dist/dictionaries/ko.mjs +375 -0
  39. package/dist/dictionaries/ms.cjs +1 -0
  40. package/dist/dictionaries/ms.mjs +23 -0
  41. package/dist/dictionaries/nl.cjs +1 -0
  42. package/dist/dictionaries/nl.mjs +97 -0
  43. package/dist/dictionaries/no.cjs +1 -0
  44. package/dist/dictionaries/no.mjs +75 -0
  45. package/dist/dictionaries/pl.cjs +1 -0
  46. package/dist/dictionaries/pl.mjs +3404 -0
  47. package/dist/dictionaries/pt.cjs +1 -0
  48. package/dist/dictionaries/pt.mjs +375 -0
  49. package/dist/dictionaries/ro.cjs +1 -0
  50. package/dist/dictionaries/ro.mjs +67 -0
  51. package/dist/dictionaries/sk.cjs +1 -0
  52. package/dist/dictionaries/sk.mjs +75 -0
  53. package/dist/dictionaries/sv.cjs +1 -0
  54. package/dist/dictionaries/sv.mjs +82 -0
  55. package/dist/dictionaries/sw.cjs +1 -0
  56. package/dist/dictionaries/sw.mjs +23 -0
  57. package/dist/dictionaries/th.cjs +1 -0
  58. package/dist/dictionaries/th.mjs +23 -0
  59. package/dist/dictionaries/uk.cjs +1 -0
  60. package/dist/dictionaries/uk.mjs +3396 -0
  61. package/dist/dictionaries/vi.cjs +1 -0
  62. package/dist/dictionaries/vi.mjs +23 -0
  63. package/dist/dictionaries/zh.cjs +1 -0
  64. package/dist/dictionaries/zh.mjs +375 -0
  65. package/dist/dynamic-loading.cjs +1 -0
  66. package/dist/dynamic-loading.mjs +274 -0
  67. package/dist/i18n.cjs +1 -0
  68. package/dist/i18n.mjs +57 -0
  69. package/dist/i18nContext.cjs +1 -0
  70. package/dist/i18nContext.mjs +11 -0
  71. package/dist/i18nDictionaries.cjs +1 -0
  72. package/dist/i18nDictionaries.mjs +61 -0
  73. package/dist/icu.cjs +1 -0
  74. package/dist/icu.mjs +242 -0
  75. package/dist/index.cjs +1 -24
  76. package/dist/index.d.ts +59 -1
  77. package/dist/index.mjs +128 -25811
  78. package/dist/languages.cjs +1 -0
  79. package/dist/languages.mjs +44 -0
  80. package/dist/lazyDictionaries.cjs +1 -0
  81. package/dist/lazyDictionaries.mjs +95 -0
  82. package/dist/locale.cjs +1 -0
  83. package/dist/locale.mjs +94 -0
  84. package/dist/pseudo-localization.cjs +1 -0
  85. package/dist/pseudo-localization.mjs +272 -0
  86. package/dist/rtl.cjs +1 -0
  87. package/dist/rtl.mjs +155 -0
  88. package/dist/timezone.cjs +1 -0
  89. package/dist/timezone.mjs +195 -0
  90. package/dist/translate-pipeline.cjs +24 -0
  91. package/dist/translate-pipeline.mjs +79 -0
  92. package/dist/translationMemory.cjs +1 -0
  93. package/dist/translationMemory.mjs +207 -0
  94. package/package.json +1 -1
@@ -0,0 +1,274 @@
1
+ import { jsx as q } from "react/jsx-runtime";
2
+ import { useState as D, useEffect as E, useMemo as p, useCallback as x, useContext as R, createContext as G } from "react";
3
+ import { NICE_SUPPORTED_LANGS as I } from "./languages.mjs";
4
+ class V {
5
+ constructor(t = 0) {
6
+ this.cache = /* @__PURE__ */ new Map(), this.ttl = t;
7
+ }
8
+ getCacheKey(t, n) {
9
+ return n ? `${t}:${n}` : t;
10
+ }
11
+ get(t, n) {
12
+ const r = this.getCacheKey(t, n), o = this.cache.get(r);
13
+ return o ? this.ttl > 0 && Date.now() > o.expiresAt ? (this.cache.delete(r), null) : o.data : null;
14
+ }
15
+ set(t, n, r) {
16
+ const o = this.getCacheKey(t, r), i = Date.now();
17
+ this.cache.set(o, {
18
+ data: n,
19
+ loadedAt: i,
20
+ expiresAt: this.ttl > 0 ? i + this.ttl : 1 / 0
21
+ });
22
+ }
23
+ has(t, n) {
24
+ return this.get(t, n) !== null;
25
+ }
26
+ delete(t, n) {
27
+ if (n)
28
+ this.cache.delete(this.getCacheKey(t, n));
29
+ else
30
+ for (const r of this.cache.keys())
31
+ (r === t || r.startsWith(`${t}:`)) && this.cache.delete(r);
32
+ }
33
+ clear() {
34
+ this.cache.clear();
35
+ }
36
+ getStats() {
37
+ const t = /* @__PURE__ */ new Set();
38
+ for (const n of this.cache.keys())
39
+ t.add(n.split(":")[0]);
40
+ return {
41
+ size: this.cache.size,
42
+ languages: Array.from(t)
43
+ };
44
+ }
45
+ }
46
+ function P(s) {
47
+ const {
48
+ loadFn: t,
49
+ fallbackLang: n = "en",
50
+ cacheTtl: r = 0,
51
+ preloadLanguages: o = [],
52
+ namespaces: i = [],
53
+ defaultNamespace: L,
54
+ onLoadStart: u,
55
+ onLoadComplete: d,
56
+ onLoadError: f
57
+ } = s, c = new V(r), g = /* @__PURE__ */ new Set(), w = /* @__PURE__ */ new Map();
58
+ let S = n;
59
+ const m = /* @__PURE__ */ new Set();
60
+ function b() {
61
+ const e = $();
62
+ m.forEach((a) => a(e));
63
+ }
64
+ function K(e, a) {
65
+ return a ? `${e}:${a}` : e;
66
+ }
67
+ function $() {
68
+ const e = /* @__PURE__ */ new Set(), a = /* @__PURE__ */ new Set();
69
+ for (const l of I)
70
+ c.has(l) && e.add(l);
71
+ for (const l of g) {
72
+ const v = l.split(":")[0];
73
+ a.add(v);
74
+ }
75
+ return {
76
+ loadedLanguages: e,
77
+ loadingLanguages: a,
78
+ failedLanguages: new Map(w),
79
+ currentLanguage: S
80
+ };
81
+ }
82
+ async function y(e, a) {
83
+ const l = K(e, a), v = c.get(e, a);
84
+ if (v)
85
+ return v;
86
+ if (g.has(l))
87
+ return new Promise((h) => {
88
+ const k = setInterval(() => {
89
+ g.has(l) || (clearInterval(k), h(c.get(e, a)));
90
+ }, 50);
91
+ });
92
+ g.add(l), w.delete(e), u == null || u(e, a), b();
93
+ try {
94
+ const h = await t(e, a);
95
+ return c.set(e, h, a), d == null || d(e, a), h;
96
+ } catch (h) {
97
+ const k = h instanceof Error ? h : new Error(String(h));
98
+ return w.set(e, k), f == null || f(e, k, a), e !== n && !a ? (console.warn(`Failed to load ${e}, falling back to ${n}`), y(n, a)) : null;
99
+ } finally {
100
+ g.delete(l), b();
101
+ }
102
+ }
103
+ async function T(e) {
104
+ await Promise.all(e.map((a) => y(a)));
105
+ }
106
+ async function F() {
107
+ o.length !== 0 && await Promise.allSettled(
108
+ o.map((e) => i.length > 0 ? Promise.all(i.map((a) => y(e, a))) : y(e))
109
+ );
110
+ }
111
+ function j(e, a) {
112
+ return c.get(e, a);
113
+ }
114
+ function C(e, a) {
115
+ return c.has(e, a);
116
+ }
117
+ function M(e) {
118
+ for (const a of g)
119
+ if (a === e || a.startsWith(`${e}:`))
120
+ return !0;
121
+ return !1;
122
+ }
123
+ function N() {
124
+ return c.getStats().languages;
125
+ }
126
+ function O(e) {
127
+ e ? c.delete(e) : c.clear(), b();
128
+ }
129
+ async function z(e) {
130
+ C(e) || await y(e), S = e, b();
131
+ }
132
+ function W() {
133
+ return S;
134
+ }
135
+ function _(e) {
136
+ return m.add(e), () => m.delete(e);
137
+ }
138
+ return {
139
+ loadLanguage: y,
140
+ loadLanguages: T,
141
+ preloadLanguages: F,
142
+ getTranslations: j,
143
+ isLoaded: C,
144
+ isLoading: M,
145
+ getLoadedLanguages: N,
146
+ clearCache: O,
147
+ getState: $,
148
+ setLanguage: z,
149
+ getCurrentLanguage: W,
150
+ subscribe: _
151
+ };
152
+ }
153
+ function U(s, t) {
154
+ return P({
155
+ ...t,
156
+ loadFn: async (n, r) => {
157
+ const o = r ? `${s}/${n}/${r}.json` : `${s}/${n}.json`, i = await fetch(o);
158
+ if (!i.ok)
159
+ throw new Error(`Failed to load translations: ${i.status}`);
160
+ return i.json();
161
+ }
162
+ });
163
+ }
164
+ function X(s, t) {
165
+ return P({
166
+ ...t,
167
+ loadFn: async (n, r) => (await s(n, r)).default
168
+ });
169
+ }
170
+ const A = G(null);
171
+ function Y({
172
+ children: s,
173
+ loader: t,
174
+ initialLanguage: n,
175
+ namespace: r
176
+ }) {
177
+ const [o, i] = D(() => t.getState()), [L, u] = D(null);
178
+ E(() => t.subscribe(i), [t]), E(() => {
179
+ n && !t.isLoaded(n, r) && t.loadLanguage(n, r).catch(u);
180
+ }, [t, n, r]);
181
+ const d = p(() => t.getTranslations(o.currentLanguage, r) || {}, [t, o.currentLanguage, r]), f = x(
182
+ async (g) => {
183
+ u(null);
184
+ try {
185
+ await t.setLanguage(g);
186
+ } catch (w) {
187
+ u(w instanceof Error ? w : new Error(String(w)));
188
+ }
189
+ },
190
+ [t]
191
+ ), c = p(
192
+ () => ({
193
+ loader: t,
194
+ translations: d,
195
+ isLoading: o.loadingLanguages.size > 0,
196
+ error: L,
197
+ setLanguage: f,
198
+ currentLanguage: o.currentLanguage,
199
+ loadedLanguages: Array.from(o.loadedLanguages)
200
+ }),
201
+ [t, d, o, L, f]
202
+ );
203
+ return /* @__PURE__ */ q(A.Provider, { value: c, children: s });
204
+ }
205
+ function B() {
206
+ const s = R(A);
207
+ if (!s)
208
+ throw new Error("useDynamicI18n must be used within DynamicI18nProvider");
209
+ return s;
210
+ }
211
+ function Z(s) {
212
+ const { translations: t, currentLanguage: n, loader: r, isLoading: o } = B();
213
+ return E(() => {
214
+ s && !r.isLoaded(n, s) && r.loadLanguage(n, s);
215
+ }, [r, n, s]), { t: x(
216
+ (L, u) => {
217
+ let d = t[L] || L;
218
+ if (u)
219
+ for (const [f, c] of Object.entries(u))
220
+ d = d.replace(new RegExp(`\\{${f}\\}`, "g"), String(c));
221
+ return d;
222
+ },
223
+ [t]
224
+ ), isLoading: o, currentLanguage: n };
225
+ }
226
+ function tt(s, t, n) {
227
+ switch (n) {
228
+ case "immediate":
229
+ s.loadLanguages(t);
230
+ break;
231
+ case "idle":
232
+ "requestIdleCallback" in window ? window.requestIdleCallback(() => {
233
+ s.loadLanguages(t);
234
+ }) : setTimeout(() => s.loadLanguages(t), 1e3);
235
+ break;
236
+ case "visible":
237
+ if ("IntersectionObserver" in window) {
238
+ const r = new IntersectionObserver(
239
+ () => {
240
+ s.loadLanguages(t), r.disconnect();
241
+ },
242
+ { threshold: 0.1 }
243
+ );
244
+ r.observe(document.body);
245
+ } else
246
+ s.loadLanguages(t);
247
+ break;
248
+ case "interaction": {
249
+ const r = () => {
250
+ s.loadLanguages(t), window.removeEventListener("click", r), window.removeEventListener("keydown", r), window.removeEventListener("touchstart", r);
251
+ };
252
+ window.addEventListener("click", r, { once: !0 }), window.addEventListener("keydown", r, { once: !0 }), window.addEventListener("touchstart", r, { once: !0 });
253
+ break;
254
+ }
255
+ }
256
+ }
257
+ async function et(s, t) {
258
+ const { fallback: n = "en", preferredLanguages: r = [] } = t || {};
259
+ for (const i of r)
260
+ if (I.includes(i))
261
+ return await s.setLanguage(i), i;
262
+ const o = navigator.language.split("-")[0].toLowerCase();
263
+ return I.includes(o) ? (await s.setLanguage(o), o) : (await s.setLanguage(n), n);
264
+ }
265
+ export {
266
+ Y as DynamicI18nProvider,
267
+ P as createDynamicLoader,
268
+ U as createFetchLoader,
269
+ X as createImportLoader,
270
+ et as detectAndLoad,
271
+ tt as preloadWithStrategy,
272
+ B as useDynamicI18n,
273
+ Z as useDynamicTranslation
274
+ };
package/dist/i18n.cjs ADDED
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("react/jsx-runtime"),E=require("react"),c=require("./i18nContext.cjs"),N=require("./languages.cjs"),u=require("./dictionaries/index.cjs"),S=({t:e,lang:r="en",overrides:t,children:o})=>{const i=E.useMemo(()=>{if(e)return e;const n=u.NICE_I18N_DICTIONARIES[r]??u.NICE_I18N_DICTIONARIES.en,I=t?{...n,...t}:n;return(s,a)=>I[s]??a},[e,r,t]);return l.jsx(c.NiceI18nContextProvider,{t:i,lang:r,children:o})};function _(e="en",r){const t=u.NICE_I18N_DICTIONARIES[e]??u.NICE_I18N_DICTIONARIES.en,o=r?{...t,...r}:t;return(i,n)=>o[i]??n}function C(e,r={}){let t=e.replace(/\{(\w+)\}/g,(o,i)=>{const n=r[i];return n!==void 0?String(n):o});return t=t.replace(/\{(\w+),\s*plural,\s*one\{([^}]+)\}\s*other\{([^}]+)\}\}/g,(o,i,n,I)=>{const s=r[i];return typeof s!="number"?o:(s===1?n:I).replace(/#/g,String(s))}),t}function g(e){return N.NICE_SUPPORTED_LANGS.includes(e)}function d(){var r;if(typeof navigator>"u")return"en";const e=(r=navigator.language)==null?void 0:r.split("-")[0];return g(e)?e:"en"}exports.useNiceTranslation=c.useNiceTranslation;exports.NICE_SUPPORTED_LANGS=N.NICE_SUPPORTED_LANGS;exports.NICE_I18N_DICTIONARIES=u.NICE_I18N_DICTIONARIES;exports.NiceI18nProvider=S;exports.createTranslator=_;exports.detectBrowserLanguage=d;exports.formatMessage=C;exports.isSupported=g;
package/dist/i18n.mjs ADDED
@@ -0,0 +1,57 @@
1
+ import { jsx as f } from "react/jsx-runtime";
2
+ import { useMemo as m } from "react";
3
+ import { NiceI18nContextProvider as p } from "./i18nContext.mjs";
4
+ import { useNiceTranslation as L } from "./i18nContext.mjs";
5
+ import { NICE_SUPPORTED_LANGS as g } from "./languages.mjs";
6
+ import { NICE_I18N_DICTIONARIES as c } from "./dictionaries/index.mjs";
7
+ const x = ({
8
+ t: r,
9
+ lang: e = "en",
10
+ overrides: t,
11
+ children: o
12
+ }) => {
13
+ const i = m(() => {
14
+ if (r)
15
+ return r;
16
+ const n = c[e] ?? c.en, a = t ? { ...n, ...t } : n;
17
+ return (u, s) => a[u] ?? s;
18
+ }, [r, e, t]);
19
+ return /* @__PURE__ */ f(p, { t: i, lang: e, children: o });
20
+ };
21
+ function C(r = "en", e) {
22
+ const t = c[r] ?? c.en, o = e ? { ...t, ...e } : t;
23
+ return (i, n) => o[i] ?? n;
24
+ }
25
+ function E(r, e = {}) {
26
+ let t = r.replace(/\{(\w+)\}/g, (o, i) => {
27
+ const n = e[i];
28
+ return n !== void 0 ? String(n) : o;
29
+ });
30
+ return t = t.replace(
31
+ /\{(\w+),\s*plural,\s*one\{([^}]+)\}\s*other\{([^}]+)\}\}/g,
32
+ (o, i, n, a) => {
33
+ const u = e[i];
34
+ return typeof u != "number" ? o : (u === 1 ? n : a).replace(/#/g, String(u));
35
+ }
36
+ ), t;
37
+ }
38
+ function l(r) {
39
+ return g.includes(r);
40
+ }
41
+ function P() {
42
+ var e;
43
+ if (typeof navigator > "u")
44
+ return "en";
45
+ const r = (e = navigator.language) == null ? void 0 : e.split("-")[0];
46
+ return l(r) ? r : "en";
47
+ }
48
+ export {
49
+ c as NICE_I18N_DICTIONARIES,
50
+ g as NICE_SUPPORTED_LANGS,
51
+ x as NiceI18nProvider,
52
+ C as createTranslator,
53
+ P as detectBrowserLanguage,
54
+ E as formatMessage,
55
+ l as isSupported,
56
+ L as useNiceTranslation
57
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react/jsx-runtime"),n=require("react"),s=(t,e)=>e,r=n.createContext(s),c=n.createContext("en"),a=({t,lang:e,children:i})=>o.jsx(c.Provider,{value:e,children:o.jsx(r.Provider,{value:t,children:i})});function u(){const t=n.useContext(r),e=n.useContext(c);return{t,lang:e}}exports.NiceI18nContextProvider=a;exports.useNiceTranslation=u;
@@ -0,0 +1,11 @@
1
+ import { jsx as n } from "react/jsx-runtime";
2
+ import { createContext as r, useContext as o } from "react";
3
+ const a = (e, t) => t, c = r(a), i = r("en"), u = ({ t: e, lang: t, children: s }) => /* @__PURE__ */ n(i.Provider, { value: t, children: /* @__PURE__ */ n(c.Provider, { value: e, children: s }) });
4
+ function v() {
5
+ const e = o(c), t = o(i);
6
+ return { t: e, lang: t };
7
+ }
8
+ export {
9
+ u as NiceI18nContextProvider,
10
+ v as useNiceTranslation
11
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("./dictionaries/pl.cjs"),o={save:"Zapisz",cancel:"Anuluj",ok:"OK",delete:"Usuń",edit:"Edytuj",add:"Dodaj",remove:"Usuń",search:"Wyszukaj",loading:"Ładowanie…",confirm:"Proszę potwierdzić",back:"Wstecz",next:"Dalej",previous:"Poprzedni",finish:"Zakończ",submit:"Prześlij",reset:"Wyczyść",apply:"Zastosuj",yes:"Tak",no:"Nie","form.requiredField":"To pole jest wymagane.","form.invalidValue":"Proszę podać prawidłową wartość.","auth.signIn":"Proszę się zalogować","auth.signOut":"Proszę się wylogować"},a={save:"Zapisz",cancel:"Anuluj",ok:"OK",delete:"Skasuj",edit:"Zmień",add:"Dodaj",remove:"Wyrzuć",search:"Szukaj",loading:"Ładuję…",confirm:"Potwierdź",back:"Cofnij",next:"Dalej",previous:"Poprzedni",finish:"Skończ",submit:"Wyślij",reset:"Wyczyść",apply:"Zatwierdź",yes:"Tak",no:"Nie","form.requiredField":"Wypełnij to pole.","form.invalidValue":"Wpisz prawidłową wartość.","auth.signIn":"Zaloguj się","auth.signOut":"Wyloguj się"},i={"pl-PL":{formal:o,informal:a},pl:{formal:o,informal:a}};function s(r){var e;return{...l,...((e=i.pl)==null?void 0:e[r])??{}}}exports.NICE_I18N_VARIANTS=i;exports.resolvePlVariant=s;
@@ -0,0 +1,61 @@
1
+ import r from "./dictionaries/pl.mjs";
2
+ const a = {
3
+ save: "Zapisz",
4
+ cancel: "Anuluj",
5
+ ok: "OK",
6
+ delete: "Usuń",
7
+ edit: "Edytuj",
8
+ add: "Dodaj",
9
+ remove: "Usuń",
10
+ search: "Wyszukaj",
11
+ loading: "Ładowanie…",
12
+ confirm: "Proszę potwierdzić",
13
+ back: "Wstecz",
14
+ next: "Dalej",
15
+ previous: "Poprzedni",
16
+ finish: "Zakończ",
17
+ submit: "Prześlij",
18
+ reset: "Wyczyść",
19
+ apply: "Zastosuj",
20
+ yes: "Tak",
21
+ no: "Nie",
22
+ "form.requiredField": "To pole jest wymagane.",
23
+ "form.invalidValue": "Proszę podać prawidłową wartość.",
24
+ "auth.signIn": "Proszę się zalogować",
25
+ "auth.signOut": "Proszę się wylogować"
26
+ }, e = {
27
+ save: "Zapisz",
28
+ cancel: "Anuluj",
29
+ ok: "OK",
30
+ delete: "Skasuj",
31
+ edit: "Zmień",
32
+ add: "Dodaj",
33
+ remove: "Wyrzuć",
34
+ search: "Szukaj",
35
+ loading: "Ładuję…",
36
+ confirm: "Potwierdź",
37
+ back: "Cofnij",
38
+ next: "Dalej",
39
+ previous: "Poprzedni",
40
+ finish: "Skończ",
41
+ submit: "Wyślij",
42
+ reset: "Wyczyść",
43
+ apply: "Zatwierdź",
44
+ yes: "Tak",
45
+ no: "Nie",
46
+ "form.requiredField": "Wypełnij to pole.",
47
+ "form.invalidValue": "Wpisz prawidłową wartość.",
48
+ "auth.signIn": "Zaloguj się",
49
+ "auth.signOut": "Wyloguj się"
50
+ }, s = {
51
+ "pl-PL": { formal: a, informal: e },
52
+ pl: { formal: a, informal: e }
53
+ };
54
+ function n(i) {
55
+ var o;
56
+ return { ...r, ...((o = s.pl) == null ? void 0 : o[i]) ?? {} };
57
+ }
58
+ export {
59
+ s as NICE_I18N_VARIANTS,
60
+ n as resolvePlVariant
61
+ };
package/dist/icu.cjs ADDED
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function p(t,n){var i;const a=Math.abs(t),e=Math.floor(a),r=t.toString().includes(".")&&((i=t.toString().split(".")[1])==null?void 0:i.length)||0;switch(r>0&&parseInt(t.toString().split(".")[1]||"0",10),n){case"en":case"de":case"nl":case"sv":case"no":case"da":case"fi":case"it":case"es":case"pt":return e===1&&r===0?"one":"other";case"fr":return e===0||e===1?"one":a>=1e6?"many":"other";case"pl":return e===1&&r===0?"one":r===0&&e%10>=2&&e%10<=4&&!(e%100>=12&&e%100<=14)?"few":r===0&&e!==1&&(e%10===0||e%10===1)||r===0&&e%10>=5&&e%10<=9||r===0&&e%100>=12&&e%100<=14?"many":"other";case"uk":return r===0&&e%10===1&&e%100!==11?"one":r===0&&e%10>=2&&e%10<=4&&!(e%100>=12&&e%100<=14)?"few":r===0&&e%10===0||r===0&&e%10>=5&&e%10<=9||r===0&&e%100>=11&&e%100<=14?"many":"other";case"bg":return t===1?"one":"other";case"cs":case"sk":return e===1&&r===0?"one":e>=2&&e<=4&&r===0?"few":r!==0?"many":"other";case"hu":return t===1?"one":"other";case"ro":return e===1&&r===0?"one":r!==0||t===0||t%100>=2&&t%100<=19?"few":"other";case"ja":case"ko":case"zh":return"other";case"ar":{if(t===0)return"zero";if(t===1)return"one";if(t===2)return"two";const s=t%100;return s>=3&&s<=10?"few":s>=11&&s<=99?"many":"other"}default:if(typeof Intl<"u"&&typeof Intl.PluralRules=="function")try{return new Intl.PluralRules(n).select(t)}catch{}return e===1&&r===0?"one":"other"}}function y(t,n){switch(n){case"en":return t%10===1&&t%100!==11?"one":t%10===2&&t%100!==12?"two":t%10===3&&t%100!==13?"few":"other";case"de":case"fr":case"es":case"it":case"pt":case"nl":case"pl":case"uk":case"cs":case"sk":case"hu":case"ro":case"bg":case"ja":case"ko":case"sv":case"no":case"da":case"fi":default:if(typeof Intl<"u"&&typeof Intl.PluralRules=="function")try{return new Intl.PluralRules(n,{type:"ordinal"}).select(t)}catch{}return"other"}}function h(t){var r;if(t=t.trim(),!t.includes(","))return{type:"simple",name:t};const n=t.split(",").map(i=>i.trim()),a=n[0],e=(r=n[1])==null?void 0:r.toLowerCase();if(!e||!a)return null;if(e==="number")return{type:"number",name:a,style:n[2]};if(e==="date"||e==="time")return{type:e,name:a,style:n[2]||"medium"};if(e==="plural"||e==="select"||e==="selectordinal"){const i=n.slice(2).join(",").trim(),s={},l=/(=?\w+)\s*\{([^{}]*(?:\{[^{}]*\}[^{}]*)*)\}/g;let o;for(;(o=l.exec(i))!==null;)s[o[1]]=o[2];return{type:e,name:a,options:s}}return{type:"simple",name:a}}function b(t,n,a){const e={};switch(a){case"currency":e.style="currency",e.currency="USD";break;case"percent":e.style="percent";break;case"integer":e.maximumFractionDigits=0;break}return new Intl.NumberFormat(n,e).format(t)}function w(t,n,a){const e=t instanceof Date?t:new Date(t);let r;switch(a){case"short":r={dateStyle:"short"};break;case"long":r={dateStyle:"long"};break;case"full":r={dateStyle:"full"};break;case"medium":default:r={dateStyle:"medium"};break}return new Intl.DateTimeFormat(n,r).format(e)}function S(t,n,a){const e=t instanceof Date?t:new Date(t);let r;switch(a){case"short":r={timeStyle:"short"};break;case"long":r={timeStyle:"long"};break;case"full":r={timeStyle:"full"};break;case"medium":default:r={timeStyle:"medium"};break}return new Intl.DateTimeFormat(n,r).format(e)}function m(t,n,a){return t.replace(/#/g,String(a))}function g(t,n={},a={}){const e=a.lang||"en",r=a.locale||e,i=/\{([^{}]*(?:\{[^{}]*\}[^{}]*)*)\}/g;return t.replace(i,(s,l)=>{const o=h(l);if(!o)return s;const c=n[o.name];if(c===void 0)return s;switch(o.type){case"simple":return String(c);case"number":return typeof c!="number"?s:b(c,r,o.style);case"date":return w(c,r,o.style);case"time":return S(c,r,o.style);case"plural":{if(typeof c!="number"||!o.options)return s;const u=p(c,e),f=`=${c}`,d=o.options[f]??o.options[u]??o.options.other??"";return m(d,o.name,c)}case"selectordinal":{if(typeof c!="number"||!o.options)return s;const u=y(c,e),f=o.options[u]??o.options.other??"";return m(f,o.name,c)}case"select":{if(!o.options)return s;const u=o.options[String(c)]??o.options.other??"";return m(u,o.name,c)}default:return s}})}function k(t,n="en"){return function(e,r,i){const s=t[e]??r;return i?g(s,i,{lang:n}):s}}function I(t,n,a="en"){const e=p(t,a);return(n[e]??n.other).replace(/#/g,String(t))}function x(t,n,a="en"){const e=y(t,a);return(n[e]??n.other).replace(/#/g,String(t))}function C(t,n){return n[t]??n.other}exports.createICUTranslator=k;exports.formatICU=g;exports.getOrdinalCategory=y;exports.getPluralCategory=p;exports.ordinal=x;exports.plural=I;exports.select=C;
package/dist/icu.mjs ADDED
@@ -0,0 +1,242 @@
1
+ function p(t, n) {
2
+ var i;
3
+ const a = Math.abs(t), e = Math.floor(a), r = t.toString().includes(".") && ((i = t.toString().split(".")[1]) == null ? void 0 : i.length) || 0;
4
+ switch (r > 0 && parseInt(t.toString().split(".")[1] || "0", 10), n) {
5
+ // ── English-like (one/other) ───────────────────────────
6
+ case "en":
7
+ case "de":
8
+ case "nl":
9
+ case "sv":
10
+ case "no":
11
+ case "da":
12
+ case "fi":
13
+ case "it":
14
+ case "es":
15
+ case "pt":
16
+ return e === 1 && r === 0 ? "one" : "other";
17
+ // ── French (one/many/other) ────────────────────────────
18
+ case "fr":
19
+ return e === 0 || e === 1 ? "one" : a >= 1e6 ? "many" : "other";
20
+ // ── Polish (Slavic: one/few/many/other) ────────────────
21
+ case "pl":
22
+ return e === 1 && r === 0 ? "one" : r === 0 && e % 10 >= 2 && e % 10 <= 4 && !(e % 100 >= 12 && e % 100 <= 14) ? "few" : r === 0 && e !== 1 && (e % 10 === 0 || e % 10 === 1) || r === 0 && e % 10 >= 5 && e % 10 <= 9 || r === 0 && e % 100 >= 12 && e % 100 <= 14 ? "many" : "other";
23
+ // ── Ukrainian (Slavic: one/few/many/other) ─────────────
24
+ case "uk":
25
+ return r === 0 && e % 10 === 1 && e % 100 !== 11 ? "one" : r === 0 && e % 10 >= 2 && e % 10 <= 4 && !(e % 100 >= 12 && e % 100 <= 14) ? "few" : r === 0 && e % 10 === 0 || r === 0 && e % 10 >= 5 && e % 10 <= 9 || r === 0 && e % 100 >= 11 && e % 100 <= 14 ? "many" : "other";
26
+ // ── Bulgarian (one/other) ──────────────────────────────
27
+ case "bg":
28
+ return t === 1 ? "one" : "other";
29
+ // ── Czech/Slovak (Slavic: one/few/many/other) ──────────
30
+ case "cs":
31
+ case "sk":
32
+ return e === 1 && r === 0 ? "one" : e >= 2 && e <= 4 && r === 0 ? "few" : r !== 0 ? "many" : "other";
33
+ // ── Hungarian (one/other) ──────────────────────────────
34
+ case "hu":
35
+ return t === 1 ? "one" : "other";
36
+ // ── Romanian (one/few/other) ───────────────────────────
37
+ case "ro":
38
+ return e === 1 && r === 0 ? "one" : r !== 0 || t === 0 || t % 100 >= 2 && t % 100 <= 19 ? "few" : "other";
39
+ // ── Japanese/Korean/Chinese (other only) ─────────────────
40
+ case "ja":
41
+ case "ko":
42
+ case "zh":
43
+ return "other";
44
+ // ── Arabic (zero/one/two/few/many/other) ────────────────
45
+ case "ar": {
46
+ if (t === 0)
47
+ return "zero";
48
+ if (t === 1)
49
+ return "one";
50
+ if (t === 2)
51
+ return "two";
52
+ const s = t % 100;
53
+ return s >= 3 && s <= 10 ? "few" : s >= 11 && s <= 99 ? "many" : "other";
54
+ }
55
+ default:
56
+ if (typeof Intl < "u" && typeof Intl.PluralRules == "function")
57
+ try {
58
+ return new Intl.PluralRules(n).select(t);
59
+ } catch {
60
+ }
61
+ return e === 1 && r === 0 ? "one" : "other";
62
+ }
63
+ }
64
+ function y(t, n) {
65
+ switch (n) {
66
+ // ── English ────────────────────────────────────────────
67
+ case "en":
68
+ return t % 10 === 1 && t % 100 !== 11 ? "one" : t % 10 === 2 && t % 100 !== 12 ? "two" : t % 10 === 3 && t % 100 !== 13 ? "few" : "other";
69
+ // ── Most languages use just "other" for ordinals ───────
70
+ case "de":
71
+ case "fr":
72
+ case "es":
73
+ case "it":
74
+ case "pt":
75
+ case "nl":
76
+ case "pl":
77
+ case "uk":
78
+ case "cs":
79
+ case "sk":
80
+ case "hu":
81
+ case "ro":
82
+ case "bg":
83
+ case "ja":
84
+ case "ko":
85
+ case "sv":
86
+ case "no":
87
+ case "da":
88
+ case "fi":
89
+ default:
90
+ if (typeof Intl < "u" && typeof Intl.PluralRules == "function")
91
+ try {
92
+ return new Intl.PluralRules(n, { type: "ordinal" }).select(t);
93
+ } catch {
94
+ }
95
+ return "other";
96
+ }
97
+ }
98
+ function g(t) {
99
+ var r;
100
+ if (t = t.trim(), !t.includes(","))
101
+ return { type: "simple", name: t };
102
+ const n = t.split(",").map((i) => i.trim()), a = n[0], e = (r = n[1]) == null ? void 0 : r.toLowerCase();
103
+ if (!e || !a)
104
+ return null;
105
+ if (e === "number")
106
+ return { type: "number", name: a, style: n[2] };
107
+ if (e === "date" || e === "time")
108
+ return { type: e, name: a, style: n[2] || "medium" };
109
+ if (e === "plural" || e === "select" || e === "selectordinal") {
110
+ const i = n.slice(2).join(",").trim(), s = {}, l = /(=?\w+)\s*\{([^{}]*(?:\{[^{}]*\}[^{}]*)*)\}/g;
111
+ let o;
112
+ for (; (o = l.exec(i)) !== null; )
113
+ s[o[1]] = o[2];
114
+ return { type: e, name: a, options: s };
115
+ }
116
+ return { type: "simple", name: a };
117
+ }
118
+ function h(t, n, a) {
119
+ const e = {};
120
+ switch (a) {
121
+ case "currency":
122
+ e.style = "currency", e.currency = "USD";
123
+ break;
124
+ case "percent":
125
+ e.style = "percent";
126
+ break;
127
+ case "integer":
128
+ e.maximumFractionDigits = 0;
129
+ break;
130
+ }
131
+ return new Intl.NumberFormat(n, e).format(t);
132
+ }
133
+ function w(t, n, a) {
134
+ const e = t instanceof Date ? t : new Date(t);
135
+ let r;
136
+ switch (a) {
137
+ case "short":
138
+ r = { dateStyle: "short" };
139
+ break;
140
+ case "long":
141
+ r = { dateStyle: "long" };
142
+ break;
143
+ case "full":
144
+ r = { dateStyle: "full" };
145
+ break;
146
+ case "medium":
147
+ default:
148
+ r = { dateStyle: "medium" };
149
+ break;
150
+ }
151
+ return new Intl.DateTimeFormat(n, r).format(e);
152
+ }
153
+ function b(t, n, a) {
154
+ const e = t instanceof Date ? t : new Date(t);
155
+ let r;
156
+ switch (a) {
157
+ case "short":
158
+ r = { timeStyle: "short" };
159
+ break;
160
+ case "long":
161
+ r = { timeStyle: "long" };
162
+ break;
163
+ case "full":
164
+ r = { timeStyle: "full" };
165
+ break;
166
+ case "medium":
167
+ default:
168
+ r = { timeStyle: "medium" };
169
+ break;
170
+ }
171
+ return new Intl.DateTimeFormat(n, r).format(e);
172
+ }
173
+ function m(t, n, a) {
174
+ return t.replace(/#/g, String(a));
175
+ }
176
+ function S(t, n = {}, a = {}) {
177
+ const e = a.lang || "en", r = a.locale || e, i = /\{([^{}]*(?:\{[^{}]*\}[^{}]*)*)\}/g;
178
+ return t.replace(i, (s, l) => {
179
+ const o = g(l);
180
+ if (!o)
181
+ return s;
182
+ const c = n[o.name];
183
+ if (c === void 0)
184
+ return s;
185
+ switch (o.type) {
186
+ case "simple":
187
+ return String(c);
188
+ case "number":
189
+ return typeof c != "number" ? s : h(c, r, o.style);
190
+ case "date":
191
+ return w(c, r, o.style);
192
+ case "time":
193
+ return b(c, r, o.style);
194
+ case "plural": {
195
+ if (typeof c != "number" || !o.options)
196
+ return s;
197
+ const u = p(c, e), f = `=${c}`, d = o.options[f] ?? o.options[u] ?? o.options.other ?? "";
198
+ return m(d, o.name, c);
199
+ }
200
+ case "selectordinal": {
201
+ if (typeof c != "number" || !o.options)
202
+ return s;
203
+ const u = y(c, e), f = o.options[u] ?? o.options.other ?? "";
204
+ return m(f, o.name, c);
205
+ }
206
+ case "select": {
207
+ if (!o.options)
208
+ return s;
209
+ const u = o.options[String(c)] ?? o.options.other ?? "";
210
+ return m(u, o.name, c);
211
+ }
212
+ default:
213
+ return s;
214
+ }
215
+ });
216
+ }
217
+ function k(t, n = "en") {
218
+ return function(e, r, i) {
219
+ const s = t[e] ?? r;
220
+ return i ? S(s, i, { lang: n }) : s;
221
+ };
222
+ }
223
+ function x(t, n, a = "en") {
224
+ const e = p(t, a);
225
+ return (n[e] ?? n.other).replace(/#/g, String(t));
226
+ }
227
+ function I(t, n, a = "en") {
228
+ const e = y(t, a);
229
+ return (n[e] ?? n.other).replace(/#/g, String(t));
230
+ }
231
+ function D(t, n) {
232
+ return n[t] ?? n.other;
233
+ }
234
+ export {
235
+ k as createICUTranslator,
236
+ S as formatICU,
237
+ y as getOrdinalCategory,
238
+ p as getPluralCategory,
239
+ I as ordinal,
240
+ x as plural,
241
+ D as select
242
+ };