@cascivo/i18n 0.1.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/LICENSE +21 -0
- package/README.md +19 -0
- package/dist/index.d.mts +272 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +468 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +58 -0
- package/readme.body.md +1 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 urbanisierung
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<!-- generated by scripts/readme/generate.ts — edit readme.body.md, not this file -->
|
|
2
|
+
|
|
3
|
+
# @cascivo/i18n
|
|
4
|
+
|
|
5
|
+
> Signal-driven locale store, typed message catalogs, and Intl-based formatting for cascade
|
|
6
|
+
|
|
7
|
+
[cascivo.com](https://cascivo.com) · [Docs](https://docs.cascivo.com) · [Storybook](https://storybook.cascivo.com) · [GitHub](https://github.com/urbanisierung/cascivo)
|
|
8
|
+
|
|
9
|
+
Signal-driven internationalisation layer for cascade — locale store, typed string catalogs, and `Intl` formatting helpers. Components read from the built-in catalog by default; pass a `labels` prop to override per-instance.
|
|
10
|
+
|
|
11
|
+
## Install
|
|
12
|
+
|
|
13
|
+
```sh
|
|
14
|
+
pnpm add @cascivo/i18n
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
[cascivo.com](https://cascivo.com) · [Docs](https://docs.cascivo.com) · [Storybook](https://storybook.cascivo.com) · [GitHub](https://github.com/urbanisierung/cascivo) · AI agents: use [`@cascivo/mcp`](https://github.com/urbanisierung/cascivo/tree/main/packages/mcp) and [`registry.json`](https://github.com/urbanisierung/cascivo/blob/main/registry.json) · MIT
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
import { ReadonlySignal } from "@cascivo/core";
|
|
2
|
+
|
|
3
|
+
//#region src/locale.d.ts
|
|
4
|
+
declare function currentLocale(): string;
|
|
5
|
+
interface LocaleStore<L extends string> {
|
|
6
|
+
locale: ReadonlySignal<L>;
|
|
7
|
+
supported: readonly L[];
|
|
8
|
+
set(locale: L): Promise<void>;
|
|
9
|
+
/** Lazy catalog: `store.registerCatalog('de', () => import('./de'))`. */
|
|
10
|
+
registerCatalog(locale: L, load: () => Promise<unknown>): void;
|
|
11
|
+
}
|
|
12
|
+
declare function createLocale<const L extends string>(options: {
|
|
13
|
+
default: L;
|
|
14
|
+
supported: readonly L[];
|
|
15
|
+
}): LocaleStore<L>;
|
|
16
|
+
//#endregion
|
|
17
|
+
//#region src/types.d.ts
|
|
18
|
+
/** CLDR plural-form branches (subset actually selected by Intl.PluralRules). */
|
|
19
|
+
interface PluralForms {
|
|
20
|
+
zero?: string;
|
|
21
|
+
one?: string;
|
|
22
|
+
two?: string;
|
|
23
|
+
few?: string;
|
|
24
|
+
many?: string;
|
|
25
|
+
other: string;
|
|
26
|
+
}
|
|
27
|
+
type MessageValue = string | PluralForms;
|
|
28
|
+
interface Message<V extends MessageValue = MessageValue> {
|
|
29
|
+
/** Stable catalog key, e.g. 'cascade.pagination.itemsPerPage'. */
|
|
30
|
+
key: string;
|
|
31
|
+
/** Default-locale value — the zero-config fallback. */
|
|
32
|
+
value: V;
|
|
33
|
+
}
|
|
34
|
+
/** Extracts '{name}' placeholders from a template-literal string type. */
|
|
35
|
+
type ParamKeys<S extends string> = S extends `${string}{${infer P}}${infer R}` ? P | ParamKeys<R> : never;
|
|
36
|
+
type BranchParams<P extends PluralForms> = ParamKeys<Extract<P[keyof P], string>>;
|
|
37
|
+
type MessageParams<V extends MessageValue> = V extends string ? ParamKeys<V> : V extends PluralForms ? BranchParams<V> | 'count' : string;
|
|
38
|
+
/** No-placeholder messages need no params argument; others require a typed record. */
|
|
39
|
+
type TArgs<V extends MessageValue> = [MessageParams<V>] extends [never] ? [] : [params: { [K in MessageParams<V>]: string | number }];
|
|
40
|
+
//#endregion
|
|
41
|
+
//#region src/messages.d.ts
|
|
42
|
+
declare function defineMessages<const T extends Record<string, MessageValue>>(namespace: string, messages: T): { [K in keyof T]: Message<T[K]> };
|
|
43
|
+
declare function defineCatalog<T extends Record<string, Message>>(messages: T, locale: string, dict: { [K in keyof T]: T[K]['value'] extends PluralForms ? PluralForms : string }): void;
|
|
44
|
+
/** Key-string lookup for serialized references (JSON configs). Untyped by design. */
|
|
45
|
+
declare function translateKey(key: string, params?: Record<string, string | number>): string;
|
|
46
|
+
declare function t<V extends MessageValue>(message: Message<V>, ...args: TArgs<V>): string;
|
|
47
|
+
//#endregion
|
|
48
|
+
//#region src/format.d.ts
|
|
49
|
+
declare function formatNumber(value: number, options?: Intl.NumberFormatOptions): string;
|
|
50
|
+
declare function formatDate(value: Date | number, options?: Intl.DateTimeFormatOptions): string;
|
|
51
|
+
declare function formatRelativeTime(value: number, unit: Intl.RelativeTimeFormatUnit, options?: Intl.RelativeTimeFormatOptions): string;
|
|
52
|
+
declare function formatList(items: string[], options?: Intl.ListFormatOptions): string;
|
|
53
|
+
//#endregion
|
|
54
|
+
//#region src/builtin.d.ts
|
|
55
|
+
/**
|
|
56
|
+
* Built-in strings for cascade components. Components call
|
|
57
|
+
* `t(builtin.<component>.<key>)` as the default and accept a `labels` prop
|
|
58
|
+
* override. en values are the message defaults; de ships first-party.
|
|
59
|
+
*/
|
|
60
|
+
declare const builtin: {
|
|
61
|
+
pagination: {
|
|
62
|
+
readonly itemsPerPage: Message<"Items per page">;
|
|
63
|
+
readonly pageOf: Message<"Page {page} of {total}">;
|
|
64
|
+
readonly range: Message<"{start}–{end} of {total} items">;
|
|
65
|
+
readonly previous: Message<"Previous page">;
|
|
66
|
+
readonly next: Message<"Next page">;
|
|
67
|
+
readonly nav: Message<"Pagination">;
|
|
68
|
+
};
|
|
69
|
+
toast: {
|
|
70
|
+
readonly dismiss: Message<"Dismiss notification">;
|
|
71
|
+
readonly region: Message<"Notifications">;
|
|
72
|
+
};
|
|
73
|
+
modal: {
|
|
74
|
+
readonly close: Message<"Close modal">;
|
|
75
|
+
};
|
|
76
|
+
alert: {
|
|
77
|
+
readonly dismiss: Message<"Dismiss">;
|
|
78
|
+
};
|
|
79
|
+
header: {
|
|
80
|
+
readonly nav: Message<"Main">;
|
|
81
|
+
};
|
|
82
|
+
search: {
|
|
83
|
+
readonly label: Message<"Search">;
|
|
84
|
+
readonly placeholder: Message<"Search">;
|
|
85
|
+
readonly clear: Message<"Clear search">;
|
|
86
|
+
};
|
|
87
|
+
commandMenu: {
|
|
88
|
+
readonly label: Message<"Command menu">;
|
|
89
|
+
readonly placeholder: Message<"Type a command or search…">;
|
|
90
|
+
readonly empty: Message<"No results found">;
|
|
91
|
+
readonly back: Message<"Back">;
|
|
92
|
+
readonly loading: Message<"Loading…">;
|
|
93
|
+
};
|
|
94
|
+
breadcrumb: {
|
|
95
|
+
readonly nav: Message<"Breadcrumb">;
|
|
96
|
+
};
|
|
97
|
+
datePicker: {
|
|
98
|
+
readonly placeholder: Message<"Select a date">;
|
|
99
|
+
readonly previousMonth: Message<"Previous month">;
|
|
100
|
+
readonly nextMonth: Message<"Next month">;
|
|
101
|
+
readonly clear: Message<"Clear date">;
|
|
102
|
+
};
|
|
103
|
+
combobox: {
|
|
104
|
+
readonly placeholder: Message<"Select an option">;
|
|
105
|
+
readonly empty: Message<"No options found">;
|
|
106
|
+
readonly clear: Message<"Clear selection">;
|
|
107
|
+
};
|
|
108
|
+
dataTable: {
|
|
109
|
+
readonly search: Message<"Search">;
|
|
110
|
+
readonly empty: Message<"No data">;
|
|
111
|
+
readonly selectAll: Message<"Select all rows">;
|
|
112
|
+
readonly selectRow: Message<"Select row">;
|
|
113
|
+
readonly itemsSelected: Message<"{count} selected">;
|
|
114
|
+
readonly expandRow: Message<"Expand row">;
|
|
115
|
+
};
|
|
116
|
+
overflowMenu: {
|
|
117
|
+
readonly trigger: Message<"More actions">;
|
|
118
|
+
};
|
|
119
|
+
sideNav: {
|
|
120
|
+
readonly nav: Message<"Side navigation">;
|
|
121
|
+
readonly collapse: Message<"Collapse navigation">;
|
|
122
|
+
readonly expand: Message<"Expand navigation">;
|
|
123
|
+
};
|
|
124
|
+
spinner: {
|
|
125
|
+
readonly label: Message<"Loading">;
|
|
126
|
+
};
|
|
127
|
+
numberInput: {
|
|
128
|
+
readonly increment: Message<"Increment">;
|
|
129
|
+
readonly decrement: Message<"Decrement">;
|
|
130
|
+
};
|
|
131
|
+
tag: {
|
|
132
|
+
readonly dismiss: Message<"Remove">;
|
|
133
|
+
};
|
|
134
|
+
appShell: {
|
|
135
|
+
readonly collapse: Message<"Collapse navigation">;
|
|
136
|
+
readonly expand: Message<"Expand navigation">;
|
|
137
|
+
readonly dismissError: Message<"Dismiss error">;
|
|
138
|
+
};
|
|
139
|
+
charts: {
|
|
140
|
+
readonly legendToggle: Message<"Toggle series {name}">;
|
|
141
|
+
};
|
|
142
|
+
alertDialog: {
|
|
143
|
+
readonly confirm: Message<"Confirm">;
|
|
144
|
+
readonly cancel: Message<"Cancel">;
|
|
145
|
+
};
|
|
146
|
+
sheet: {
|
|
147
|
+
readonly close: Message<"Close panel">;
|
|
148
|
+
};
|
|
149
|
+
fileUploader: {
|
|
150
|
+
readonly label: Message<"Upload files">;
|
|
151
|
+
readonly drop: Message<"Drag and drop files here or click to upload">;
|
|
152
|
+
readonly remove: Message<"Remove {name}">;
|
|
153
|
+
readonly uploading: Message<"Uploading">;
|
|
154
|
+
readonly complete: Message<"Upload complete">;
|
|
155
|
+
readonly error: Message<"Upload failed">;
|
|
156
|
+
};
|
|
157
|
+
passwordInput: {
|
|
158
|
+
readonly reveal: Message<"Show password">;
|
|
159
|
+
readonly hide: Message<"Hide password">;
|
|
160
|
+
readonly strengthWeak: Message<"weak">;
|
|
161
|
+
readonly strengthFair: Message<"fair">;
|
|
162
|
+
readonly strengthGood: Message<"good">;
|
|
163
|
+
readonly strengthStrong: Message<"strong">;
|
|
164
|
+
readonly strengthLabel: Message<"Password strength: {level}">;
|
|
165
|
+
};
|
|
166
|
+
multiSelect: {
|
|
167
|
+
readonly placeholder: Message<"Select options">;
|
|
168
|
+
readonly selected: Message<"{count} selected">;
|
|
169
|
+
readonly search: Message<"Search options">;
|
|
170
|
+
readonly noResults: Message<"No options found">;
|
|
171
|
+
};
|
|
172
|
+
tagsInput: {
|
|
173
|
+
readonly remove: Message<"Remove {tag}">;
|
|
174
|
+
readonly placeholder: Message<"Add tag…">;
|
|
175
|
+
};
|
|
176
|
+
otpInput: {
|
|
177
|
+
readonly label: Message<"One-time code">;
|
|
178
|
+
readonly digit: Message<"Digit {n}">;
|
|
179
|
+
};
|
|
180
|
+
ai: {
|
|
181
|
+
readonly generating: Message<"Generating…">;
|
|
182
|
+
readonly done: Message<"Done">;
|
|
183
|
+
readonly error: Message<"Error">;
|
|
184
|
+
readonly send: Message<"Send">;
|
|
185
|
+
readonly placeholder: Message<"Type a message…">;
|
|
186
|
+
readonly you: Message<"You">;
|
|
187
|
+
readonly assistant: Message<"Assistant">;
|
|
188
|
+
};
|
|
189
|
+
shellHeader: {
|
|
190
|
+
readonly skipToContent: Message<"Skip to main content">;
|
|
191
|
+
readonly nav: Message<"Main">;
|
|
192
|
+
readonly openMenu: Message<"Open navigation">;
|
|
193
|
+
readonly closeMenu: Message<"Close navigation">;
|
|
194
|
+
};
|
|
195
|
+
headerPanel: {
|
|
196
|
+
readonly close: Message<"Close panel">;
|
|
197
|
+
};
|
|
198
|
+
switcher: {
|
|
199
|
+
readonly label: Message<"Switch application">;
|
|
200
|
+
};
|
|
201
|
+
copyButton: {
|
|
202
|
+
readonly copy: Message<"Copy">;
|
|
203
|
+
readonly copied: Message<"Copied">;
|
|
204
|
+
};
|
|
205
|
+
skipNav: {
|
|
206
|
+
readonly label: Message<"Skip to content">;
|
|
207
|
+
};
|
|
208
|
+
form: {
|
|
209
|
+
readonly required: Message<"Required">;
|
|
210
|
+
readonly invalid: Message<"Invalid value">;
|
|
211
|
+
};
|
|
212
|
+
label: {
|
|
213
|
+
readonly required: Message<"Required">;
|
|
214
|
+
};
|
|
215
|
+
inlineLoading: {
|
|
216
|
+
readonly active: Message<"Loading">;
|
|
217
|
+
readonly finished: Message<"Loaded">;
|
|
218
|
+
readonly error: Message<"Error">;
|
|
219
|
+
};
|
|
220
|
+
notification: {
|
|
221
|
+
readonly dismiss: Message<"Dismiss">;
|
|
222
|
+
};
|
|
223
|
+
treeView: {
|
|
224
|
+
readonly loading: Message<"Loading…">;
|
|
225
|
+
readonly expand: Message<"Expand">;
|
|
226
|
+
readonly collapse: Message<"Collapse">;
|
|
227
|
+
};
|
|
228
|
+
carousel: {
|
|
229
|
+
readonly region: Message<"Carousel">;
|
|
230
|
+
readonly previous: Message<"Previous slide">;
|
|
231
|
+
readonly next: Message<"Next slide">;
|
|
232
|
+
readonly slide: Message<"{n} of {total}">;
|
|
233
|
+
readonly goTo: Message<"Go to slide {n}">;
|
|
234
|
+
};
|
|
235
|
+
calendar: {
|
|
236
|
+
readonly previousMonth: Message<"Previous month">;
|
|
237
|
+
readonly nextMonth: Message<"Next month">;
|
|
238
|
+
readonly today: Message<"Today">;
|
|
239
|
+
};
|
|
240
|
+
colorPicker: {
|
|
241
|
+
readonly hue: Message<"Hue">;
|
|
242
|
+
readonly alpha: Message<"Alpha">;
|
|
243
|
+
readonly colorArea: Message<"Saturation and lightness">;
|
|
244
|
+
readonly eyedropper: Message<"Pick a color from the screen">;
|
|
245
|
+
};
|
|
246
|
+
drawer: {
|
|
247
|
+
readonly close: Message<"Close">;
|
|
248
|
+
};
|
|
249
|
+
menuButton: {
|
|
250
|
+
readonly open: Message<"Open menu">;
|
|
251
|
+
};
|
|
252
|
+
resizable: {
|
|
253
|
+
readonly handle: Message<"Resize panels">;
|
|
254
|
+
};
|
|
255
|
+
codeSnippet: {
|
|
256
|
+
readonly copy: Message<"Copy code">;
|
|
257
|
+
readonly copied: Message<"Copied">;
|
|
258
|
+
};
|
|
259
|
+
dateRangePicker: {
|
|
260
|
+
readonly placeholder: Message<"Select a date range">;
|
|
261
|
+
readonly start: Message<"Start date">;
|
|
262
|
+
readonly end: Message<"End date">;
|
|
263
|
+
readonly apply: Message<"Apply">;
|
|
264
|
+
readonly clear: Message<"Clear">;
|
|
265
|
+
};
|
|
266
|
+
toggletip: {
|
|
267
|
+
readonly label: Message<"More information">;
|
|
268
|
+
};
|
|
269
|
+
};
|
|
270
|
+
//#endregion
|
|
271
|
+
export { type LocaleStore, type Message, type MessageValue, type PluralForms, builtin, createLocale, currentLocale, defineCatalog, defineMessages, formatDate, formatList, formatNumber, formatRelativeTime, t, translateKey };
|
|
272
|
+
//# sourceMappingURL=index.d.mts.map
|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U,CAAA,EACV,MAAA,UACA,IAAA,gBAAoB,CAAA,GAAI,CAAA,CAAE,CAAA,mBAAoB,WAAA,GAAc,WAAA;AFpBjC;AAAA,iBE2Cb,YAAA,CAAa,GAAA,UAAa,MAAA,GAAS,MAAM;AAAA,iBAUzC,CAAA,WAAY,YAAA,EAAc,OAAA,EAAS,OAAA,CAAQ,CAAA,MAAO,IAAA,EAAM,KAAA,CAAM,CAAA;;;iBC9B9D,YAAA,CAAa,KAAA,UAAe,OAAA,GAAU,IAAA,CAAK,mBAAmB;AAAA,iBAI9D,UAAA,CAAW,KAAA,EAAO,IAAA,WAAe,OAAA,GAAU,IAAA,CAAK,qBAAqB;AAAA,iBAIrE,kBAAA,CACd,KAAA,UACA,IAAA,EAAM,IAAA,CAAK,sBAAA,EACX,OAAA,GAAU,IAAA,CAAK,yBAAyB;AAAA,iBAK1B,UAAA,CAAW,KAAA,YAAiB,OAAA,GAAU,IAAA,CAAK,iBAAiB;;;;;;AHvC5E;;cIAa,OAAA;;2BAiNZ,OAAA;IAAA"}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,468 @@
|
|
|
1
|
+
import { signal } from "@cascivo/core";
|
|
2
|
+
//#region src/locale.ts
|
|
3
|
+
const activeLocale = signal("en");
|
|
4
|
+
function currentLocale() {
|
|
5
|
+
return activeLocale.value;
|
|
6
|
+
}
|
|
7
|
+
function createLocale(options) {
|
|
8
|
+
const loaders = /* @__PURE__ */ new Map();
|
|
9
|
+
const loaded = new Set([options.default]);
|
|
10
|
+
activeLocale.value = options.default;
|
|
11
|
+
return {
|
|
12
|
+
locale: activeLocale,
|
|
13
|
+
supported: options.supported,
|
|
14
|
+
registerCatalog(locale, load) {
|
|
15
|
+
loaders.set(locale, load);
|
|
16
|
+
},
|
|
17
|
+
async set(locale) {
|
|
18
|
+
if (!options.supported.includes(locale)) throw new Error(`Unsupported locale "${locale}" (supported: ${options.supported.join(", ")})`);
|
|
19
|
+
const load = loaders.get(locale);
|
|
20
|
+
if (load && !loaded.has(locale)) {
|
|
21
|
+
await load();
|
|
22
|
+
loaded.add(locale);
|
|
23
|
+
}
|
|
24
|
+
activeLocale.value = locale;
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
//#endregion
|
|
29
|
+
//#region src/messages.ts
|
|
30
|
+
const catalogs = /* @__PURE__ */ new Map();
|
|
31
|
+
const catalogVersion = signal(0);
|
|
32
|
+
const defaults = /* @__PURE__ */ new Map();
|
|
33
|
+
function defineMessages(namespace, messages) {
|
|
34
|
+
return Object.fromEntries(Object.entries(messages).map(([name, value]) => {
|
|
35
|
+
const key = `${namespace}.${name}`;
|
|
36
|
+
defaults.set(key, value);
|
|
37
|
+
return [name, {
|
|
38
|
+
key,
|
|
39
|
+
value
|
|
40
|
+
}];
|
|
41
|
+
}));
|
|
42
|
+
}
|
|
43
|
+
function defineCatalog(messages, locale, dict) {
|
|
44
|
+
let catalog = catalogs.get(locale);
|
|
45
|
+
if (!catalog) {
|
|
46
|
+
catalog = /* @__PURE__ */ new Map();
|
|
47
|
+
catalogs.set(locale, catalog);
|
|
48
|
+
}
|
|
49
|
+
for (const [name, message] of Object.entries(messages)) catalog.set(message.key, dict[name]);
|
|
50
|
+
catalogVersion.value++;
|
|
51
|
+
}
|
|
52
|
+
const pluralRules = /* @__PURE__ */ new Map();
|
|
53
|
+
function interpolate(template, params) {
|
|
54
|
+
if (!params) return template;
|
|
55
|
+
return template.replace(/\{(\w+)\}/g, (match, name) => name in params ? String(params[name]) : match);
|
|
56
|
+
}
|
|
57
|
+
/** Key-string lookup for serialized references (JSON configs). Untyped by design. */
|
|
58
|
+
function translateKey(key, params) {
|
|
59
|
+
catalogVersion.value;
|
|
60
|
+
const locale = currentLocale();
|
|
61
|
+
const value = catalogs.get(locale)?.get(key) ?? defaults.get(key);
|
|
62
|
+
if (value === void 0) return key;
|
|
63
|
+
return t({
|
|
64
|
+
key,
|
|
65
|
+
value
|
|
66
|
+
}, params);
|
|
67
|
+
}
|
|
68
|
+
function t(message, ...args) {
|
|
69
|
+
catalogVersion.value;
|
|
70
|
+
const locale = currentLocale();
|
|
71
|
+
const value = catalogs.get(locale)?.get(message.key) ?? message.value;
|
|
72
|
+
const params = args[0];
|
|
73
|
+
if (typeof value === "string") return interpolate(value, params);
|
|
74
|
+
let rules = pluralRules.get(locale);
|
|
75
|
+
if (!rules) {
|
|
76
|
+
rules = new Intl.PluralRules(locale);
|
|
77
|
+
pluralRules.set(locale, rules);
|
|
78
|
+
}
|
|
79
|
+
return interpolate(value[rules.select(Number(params?.["count"] ?? 0))] ?? value.other, params);
|
|
80
|
+
}
|
|
81
|
+
//#endregion
|
|
82
|
+
//#region src/format.ts
|
|
83
|
+
function memo(create) {
|
|
84
|
+
const cache = /* @__PURE__ */ new Map();
|
|
85
|
+
return (options) => {
|
|
86
|
+
const locale = currentLocale();
|
|
87
|
+
const key = `${locale}|${JSON.stringify(options ?? {})}`;
|
|
88
|
+
let formatter = cache.get(key);
|
|
89
|
+
if (!formatter) {
|
|
90
|
+
formatter = create(locale, options);
|
|
91
|
+
cache.set(key, formatter);
|
|
92
|
+
}
|
|
93
|
+
return formatter;
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
const numberFormat = memo((locale, options) => new Intl.NumberFormat(locale, options));
|
|
97
|
+
const dateFormat = memo((locale, options) => new Intl.DateTimeFormat(locale, options));
|
|
98
|
+
const relativeFormat = memo((locale, options) => new Intl.RelativeTimeFormat(locale, options));
|
|
99
|
+
const listFormat = memo((locale, options) => new Intl.ListFormat(locale, options));
|
|
100
|
+
function formatNumber(value, options) {
|
|
101
|
+
return numberFormat(options).format(value);
|
|
102
|
+
}
|
|
103
|
+
function formatDate(value, options) {
|
|
104
|
+
return dateFormat(options).format(value);
|
|
105
|
+
}
|
|
106
|
+
function formatRelativeTime(value, unit, options) {
|
|
107
|
+
return relativeFormat(options).format(value, unit);
|
|
108
|
+
}
|
|
109
|
+
function formatList(items, options) {
|
|
110
|
+
return listFormat(options).format(items);
|
|
111
|
+
}
|
|
112
|
+
//#endregion
|
|
113
|
+
//#region src/builtin.ts
|
|
114
|
+
/**
|
|
115
|
+
* Built-in strings for cascade components. Components call
|
|
116
|
+
* `t(builtin.<component>.<key>)` as the default and accept a `labels` prop
|
|
117
|
+
* override. en values are the message defaults; de ships first-party.
|
|
118
|
+
*/
|
|
119
|
+
const builtin = {
|
|
120
|
+
pagination: defineMessages("cascade.pagination", {
|
|
121
|
+
itemsPerPage: "Items per page",
|
|
122
|
+
pageOf: "Page {page} of {total}",
|
|
123
|
+
range: "{start}–{end} of {total} items",
|
|
124
|
+
previous: "Previous page",
|
|
125
|
+
next: "Next page",
|
|
126
|
+
nav: "Pagination"
|
|
127
|
+
}),
|
|
128
|
+
toast: defineMessages("cascade.toast", {
|
|
129
|
+
dismiss: "Dismiss notification",
|
|
130
|
+
region: "Notifications"
|
|
131
|
+
}),
|
|
132
|
+
modal: defineMessages("cascade.modal", { close: "Close modal" }),
|
|
133
|
+
alert: defineMessages("cascade.alert", { dismiss: "Dismiss" }),
|
|
134
|
+
header: defineMessages("cascade.header", { nav: "Main" }),
|
|
135
|
+
search: defineMessages("cascade.search", {
|
|
136
|
+
label: "Search",
|
|
137
|
+
placeholder: "Search",
|
|
138
|
+
clear: "Clear search"
|
|
139
|
+
}),
|
|
140
|
+
commandMenu: defineMessages("cascade.commandMenu", {
|
|
141
|
+
label: "Command menu",
|
|
142
|
+
placeholder: "Type a command or search…",
|
|
143
|
+
empty: "No results found",
|
|
144
|
+
back: "Back",
|
|
145
|
+
loading: "Loading…"
|
|
146
|
+
}),
|
|
147
|
+
breadcrumb: defineMessages("cascade.breadcrumb", { nav: "Breadcrumb" }),
|
|
148
|
+
datePicker: defineMessages("cascade.datePicker", {
|
|
149
|
+
placeholder: "Select a date",
|
|
150
|
+
previousMonth: "Previous month",
|
|
151
|
+
nextMonth: "Next month",
|
|
152
|
+
clear: "Clear date"
|
|
153
|
+
}),
|
|
154
|
+
combobox: defineMessages("cascade.combobox", {
|
|
155
|
+
placeholder: "Select an option",
|
|
156
|
+
empty: "No options found",
|
|
157
|
+
clear: "Clear selection"
|
|
158
|
+
}),
|
|
159
|
+
dataTable: defineMessages("cascade.dataTable", {
|
|
160
|
+
search: "Search",
|
|
161
|
+
empty: "No data",
|
|
162
|
+
selectAll: "Select all rows",
|
|
163
|
+
selectRow: "Select row",
|
|
164
|
+
itemsSelected: "{count} selected",
|
|
165
|
+
expandRow: "Expand row"
|
|
166
|
+
}),
|
|
167
|
+
overflowMenu: defineMessages("cascade.overflowMenu", { trigger: "More actions" }),
|
|
168
|
+
sideNav: defineMessages("cascade.sideNav", {
|
|
169
|
+
nav: "Side navigation",
|
|
170
|
+
collapse: "Collapse navigation",
|
|
171
|
+
expand: "Expand navigation"
|
|
172
|
+
}),
|
|
173
|
+
spinner: defineMessages("cascade.spinner", { label: "Loading" }),
|
|
174
|
+
numberInput: defineMessages("cascade.numberInput", {
|
|
175
|
+
increment: "Increment",
|
|
176
|
+
decrement: "Decrement"
|
|
177
|
+
}),
|
|
178
|
+
tag: defineMessages("cascade.tag", { dismiss: "Remove" }),
|
|
179
|
+
appShell: defineMessages("cascade.appShell", {
|
|
180
|
+
collapse: "Collapse navigation",
|
|
181
|
+
expand: "Expand navigation",
|
|
182
|
+
dismissError: "Dismiss error"
|
|
183
|
+
}),
|
|
184
|
+
charts: defineMessages("cascade.charts", { legendToggle: "Toggle series {name}" }),
|
|
185
|
+
alertDialog: defineMessages("cascade.alertDialog", {
|
|
186
|
+
confirm: "Confirm",
|
|
187
|
+
cancel: "Cancel"
|
|
188
|
+
}),
|
|
189
|
+
sheet: defineMessages("cascade.sheet", { close: "Close panel" }),
|
|
190
|
+
fileUploader: defineMessages("cascade.fileUploader", {
|
|
191
|
+
label: "Upload files",
|
|
192
|
+
drop: "Drag and drop files here or click to upload",
|
|
193
|
+
remove: "Remove {name}",
|
|
194
|
+
uploading: "Uploading",
|
|
195
|
+
complete: "Upload complete",
|
|
196
|
+
error: "Upload failed"
|
|
197
|
+
}),
|
|
198
|
+
passwordInput: defineMessages("cascade.passwordInput", {
|
|
199
|
+
reveal: "Show password",
|
|
200
|
+
hide: "Hide password",
|
|
201
|
+
strengthWeak: "weak",
|
|
202
|
+
strengthFair: "fair",
|
|
203
|
+
strengthGood: "good",
|
|
204
|
+
strengthStrong: "strong",
|
|
205
|
+
strengthLabel: "Password strength: {level}"
|
|
206
|
+
}),
|
|
207
|
+
multiSelect: defineMessages("cascade.multiSelect", {
|
|
208
|
+
placeholder: "Select options",
|
|
209
|
+
selected: "{count} selected",
|
|
210
|
+
search: "Search options",
|
|
211
|
+
noResults: "No options found"
|
|
212
|
+
}),
|
|
213
|
+
tagsInput: defineMessages("cascade.tagsInput", {
|
|
214
|
+
remove: "Remove {tag}",
|
|
215
|
+
placeholder: "Add tag…"
|
|
216
|
+
}),
|
|
217
|
+
otpInput: defineMessages("cascade.otpInput", {
|
|
218
|
+
label: "One-time code",
|
|
219
|
+
digit: "Digit {n}"
|
|
220
|
+
}),
|
|
221
|
+
ai: defineMessages("cascade.ai", {
|
|
222
|
+
generating: "Generating…",
|
|
223
|
+
done: "Done",
|
|
224
|
+
error: "Error",
|
|
225
|
+
send: "Send",
|
|
226
|
+
placeholder: "Type a message…",
|
|
227
|
+
you: "You",
|
|
228
|
+
assistant: "Assistant"
|
|
229
|
+
}),
|
|
230
|
+
shellHeader: defineMessages("cascade.shellHeader", {
|
|
231
|
+
skipToContent: "Skip to main content",
|
|
232
|
+
nav: "Main",
|
|
233
|
+
openMenu: "Open navigation",
|
|
234
|
+
closeMenu: "Close navigation"
|
|
235
|
+
}),
|
|
236
|
+
headerPanel: defineMessages("cascade.headerPanel", { close: "Close panel" }),
|
|
237
|
+
switcher: defineMessages("cascade.switcher", { label: "Switch application" }),
|
|
238
|
+
copyButton: defineMessages("cascade.copyButton", {
|
|
239
|
+
copy: "Copy",
|
|
240
|
+
copied: "Copied"
|
|
241
|
+
}),
|
|
242
|
+
skipNav: defineMessages("cascade.skipNav", { label: "Skip to content" }),
|
|
243
|
+
form: defineMessages("cascade.form", {
|
|
244
|
+
required: "Required",
|
|
245
|
+
invalid: "Invalid value"
|
|
246
|
+
}),
|
|
247
|
+
label: defineMessages("cascade.label", { required: "Required" }),
|
|
248
|
+
inlineLoading: defineMessages("cascade.inlineLoading", {
|
|
249
|
+
active: "Loading",
|
|
250
|
+
finished: "Loaded",
|
|
251
|
+
error: "Error"
|
|
252
|
+
}),
|
|
253
|
+
notification: defineMessages("cascade.notification", { dismiss: "Dismiss" }),
|
|
254
|
+
treeView: defineMessages("cascade.treeView", {
|
|
255
|
+
loading: "Loading…",
|
|
256
|
+
expand: "Expand",
|
|
257
|
+
collapse: "Collapse"
|
|
258
|
+
}),
|
|
259
|
+
carousel: defineMessages("cascade.carousel", {
|
|
260
|
+
region: "Carousel",
|
|
261
|
+
previous: "Previous slide",
|
|
262
|
+
next: "Next slide",
|
|
263
|
+
slide: "{n} of {total}",
|
|
264
|
+
goTo: "Go to slide {n}"
|
|
265
|
+
}),
|
|
266
|
+
calendar: defineMessages("cascade.calendar", {
|
|
267
|
+
previousMonth: "Previous month",
|
|
268
|
+
nextMonth: "Next month",
|
|
269
|
+
today: "Today"
|
|
270
|
+
}),
|
|
271
|
+
colorPicker: defineMessages("cascade.colorPicker", {
|
|
272
|
+
hue: "Hue",
|
|
273
|
+
alpha: "Alpha",
|
|
274
|
+
colorArea: "Saturation and lightness",
|
|
275
|
+
eyedropper: "Pick a color from the screen"
|
|
276
|
+
}),
|
|
277
|
+
drawer: defineMessages("cascade.drawer", { close: "Close" }),
|
|
278
|
+
menuButton: defineMessages("cascade.menuButton", { open: "Open menu" }),
|
|
279
|
+
resizable: defineMessages("cascade.resizable", { handle: "Resize panels" }),
|
|
280
|
+
codeSnippet: defineMessages("cascade.codeSnippet", {
|
|
281
|
+
copy: "Copy code",
|
|
282
|
+
copied: "Copied"
|
|
283
|
+
}),
|
|
284
|
+
dateRangePicker: defineMessages("cascade.dateRangePicker", {
|
|
285
|
+
placeholder: "Select a date range",
|
|
286
|
+
start: "Start date",
|
|
287
|
+
end: "End date",
|
|
288
|
+
apply: "Apply",
|
|
289
|
+
clear: "Clear"
|
|
290
|
+
}),
|
|
291
|
+
toggletip: defineMessages("cascade.toggletip", { label: "More information" })
|
|
292
|
+
};
|
|
293
|
+
defineCatalog(builtin.pagination, "de", {
|
|
294
|
+
itemsPerPage: "Einträge pro Seite",
|
|
295
|
+
pageOf: "Seite {page} von {total}",
|
|
296
|
+
range: "{start}–{end} von {total} Einträgen",
|
|
297
|
+
previous: "Vorherige Seite",
|
|
298
|
+
next: "Nächste Seite",
|
|
299
|
+
nav: "Seitennummerierung"
|
|
300
|
+
});
|
|
301
|
+
defineCatalog(builtin.toast, "de", {
|
|
302
|
+
dismiss: "Benachrichtigung schließen",
|
|
303
|
+
region: "Benachrichtigungen"
|
|
304
|
+
});
|
|
305
|
+
defineCatalog(builtin.modal, "de", { close: "Dialog schließen" });
|
|
306
|
+
defineCatalog(builtin.alert, "de", { dismiss: "Schließen" });
|
|
307
|
+
defineCatalog(builtin.header, "de", { nav: "Hauptnavigation" });
|
|
308
|
+
defineCatalog(builtin.search, "de", {
|
|
309
|
+
label: "Suche",
|
|
310
|
+
placeholder: "Suchen",
|
|
311
|
+
clear: "Suche löschen"
|
|
312
|
+
});
|
|
313
|
+
defineCatalog(builtin.commandMenu, "de", {
|
|
314
|
+
label: "Befehlsmenü",
|
|
315
|
+
placeholder: "Befehl oder Suche eingeben…",
|
|
316
|
+
empty: "Keine Ergebnisse",
|
|
317
|
+
back: "Zurück",
|
|
318
|
+
loading: "Wird geladen…"
|
|
319
|
+
});
|
|
320
|
+
defineCatalog(builtin.breadcrumb, "de", { nav: "Navigationspfad" });
|
|
321
|
+
defineCatalog(builtin.datePicker, "de", {
|
|
322
|
+
placeholder: "Datum auswählen",
|
|
323
|
+
previousMonth: "Vorheriger Monat",
|
|
324
|
+
nextMonth: "Nächster Monat",
|
|
325
|
+
clear: "Datum löschen"
|
|
326
|
+
});
|
|
327
|
+
defineCatalog(builtin.combobox, "de", {
|
|
328
|
+
placeholder: "Option auswählen",
|
|
329
|
+
empty: "Keine Optionen gefunden",
|
|
330
|
+
clear: "Auswahl löschen"
|
|
331
|
+
});
|
|
332
|
+
defineCatalog(builtin.dataTable, "de", {
|
|
333
|
+
search: "Suchen",
|
|
334
|
+
empty: "Keine Daten",
|
|
335
|
+
selectAll: "Alle Zeilen auswählen",
|
|
336
|
+
selectRow: "Zeile auswählen",
|
|
337
|
+
itemsSelected: "{count} ausgewählt",
|
|
338
|
+
expandRow: "Zeile aufklappen"
|
|
339
|
+
});
|
|
340
|
+
defineCatalog(builtin.overflowMenu, "de", { trigger: "Weitere Aktionen" });
|
|
341
|
+
defineCatalog(builtin.sideNav, "de", {
|
|
342
|
+
nav: "Seitennavigation",
|
|
343
|
+
collapse: "Navigation einklappen",
|
|
344
|
+
expand: "Navigation ausklappen"
|
|
345
|
+
});
|
|
346
|
+
defineCatalog(builtin.spinner, "de", { label: "Wird geladen" });
|
|
347
|
+
defineCatalog(builtin.numberInput, "de", {
|
|
348
|
+
increment: "Erhöhen",
|
|
349
|
+
decrement: "Verringern"
|
|
350
|
+
});
|
|
351
|
+
defineCatalog(builtin.tag, "de", { dismiss: "Entfernen" });
|
|
352
|
+
defineCatalog(builtin.appShell, "de", {
|
|
353
|
+
collapse: "Navigation einklappen",
|
|
354
|
+
expand: "Navigation ausklappen",
|
|
355
|
+
dismissError: "Fehler schließen"
|
|
356
|
+
});
|
|
357
|
+
defineCatalog(builtin.charts, "de", { legendToggle: "Reihe {name} umschalten" });
|
|
358
|
+
defineCatalog(builtin.alertDialog, "de", {
|
|
359
|
+
confirm: "Bestätigen",
|
|
360
|
+
cancel: "Abbrechen"
|
|
361
|
+
});
|
|
362
|
+
defineCatalog(builtin.sheet, "de", { close: "Bereich schließen" });
|
|
363
|
+
defineCatalog(builtin.fileUploader, "de", {
|
|
364
|
+
label: "Dateien hochladen",
|
|
365
|
+
drop: "Dateien hier ablegen oder klicken zum Hochladen",
|
|
366
|
+
remove: "{name} entfernen",
|
|
367
|
+
uploading: "Wird hochgeladen",
|
|
368
|
+
complete: "Hochladen abgeschlossen",
|
|
369
|
+
error: "Hochladen fehlgeschlagen"
|
|
370
|
+
});
|
|
371
|
+
defineCatalog(builtin.passwordInput, "de", {
|
|
372
|
+
reveal: "Passwort anzeigen",
|
|
373
|
+
hide: "Passwort verbergen",
|
|
374
|
+
strengthWeak: "schwach",
|
|
375
|
+
strengthFair: "mäßig",
|
|
376
|
+
strengthGood: "gut",
|
|
377
|
+
strengthStrong: "stark",
|
|
378
|
+
strengthLabel: "Passwortstärke: {level}"
|
|
379
|
+
});
|
|
380
|
+
defineCatalog(builtin.multiSelect, "de", {
|
|
381
|
+
placeholder: "Optionen auswählen",
|
|
382
|
+
selected: "{count} ausgewählt",
|
|
383
|
+
search: "Optionen durchsuchen",
|
|
384
|
+
noResults: "Keine Optionen gefunden"
|
|
385
|
+
});
|
|
386
|
+
defineCatalog(builtin.tagsInput, "de", {
|
|
387
|
+
remove: "{tag} entfernen",
|
|
388
|
+
placeholder: "Tag hinzufügen…"
|
|
389
|
+
});
|
|
390
|
+
defineCatalog(builtin.otpInput, "de", {
|
|
391
|
+
label: "Einmalcode",
|
|
392
|
+
digit: "Ziffer {n}"
|
|
393
|
+
});
|
|
394
|
+
defineCatalog(builtin.ai, "de", {
|
|
395
|
+
generating: "Wird generiert…",
|
|
396
|
+
done: "Fertig",
|
|
397
|
+
error: "Fehler",
|
|
398
|
+
send: "Senden",
|
|
399
|
+
placeholder: "Nachricht eingeben…",
|
|
400
|
+
you: "Du",
|
|
401
|
+
assistant: "Assistent"
|
|
402
|
+
});
|
|
403
|
+
defineCatalog(builtin.shellHeader, "de", {
|
|
404
|
+
skipToContent: "Zum Hauptinhalt springen",
|
|
405
|
+
nav: "Hauptnavigation",
|
|
406
|
+
openMenu: "Navigation öffnen",
|
|
407
|
+
closeMenu: "Navigation schließen"
|
|
408
|
+
});
|
|
409
|
+
defineCatalog(builtin.headerPanel, "de", { close: "Panel schließen" });
|
|
410
|
+
defineCatalog(builtin.switcher, "de", { label: "Anwendung wechseln" });
|
|
411
|
+
defineCatalog(builtin.copyButton, "de", {
|
|
412
|
+
copy: "Kopieren",
|
|
413
|
+
copied: "Kopiert"
|
|
414
|
+
});
|
|
415
|
+
defineCatalog(builtin.skipNav, "de", { label: "Zum Inhalt springen" });
|
|
416
|
+
defineCatalog(builtin.form, "de", {
|
|
417
|
+
required: "Pflichtfeld",
|
|
418
|
+
invalid: "Ungültiger Wert"
|
|
419
|
+
});
|
|
420
|
+
defineCatalog(builtin.label, "de", { required: "Erforderlich" });
|
|
421
|
+
defineCatalog(builtin.inlineLoading, "de", {
|
|
422
|
+
active: "Wird geladen",
|
|
423
|
+
finished: "Geladen",
|
|
424
|
+
error: "Fehler"
|
|
425
|
+
});
|
|
426
|
+
defineCatalog(builtin.notification, "de", { dismiss: "Schließen" });
|
|
427
|
+
defineCatalog(builtin.treeView, "de", {
|
|
428
|
+
loading: "Wird geladen…",
|
|
429
|
+
expand: "Aufklappen",
|
|
430
|
+
collapse: "Zuklappen"
|
|
431
|
+
});
|
|
432
|
+
defineCatalog(builtin.carousel, "de", {
|
|
433
|
+
region: "Karussell",
|
|
434
|
+
previous: "Vorherige Folie",
|
|
435
|
+
next: "Nächste Folie",
|
|
436
|
+
slide: "{n} von {total}",
|
|
437
|
+
goTo: "Zu Folie {n}"
|
|
438
|
+
});
|
|
439
|
+
defineCatalog(builtin.calendar, "de", {
|
|
440
|
+
previousMonth: "Vorheriger Monat",
|
|
441
|
+
nextMonth: "Nächster Monat",
|
|
442
|
+
today: "Heute"
|
|
443
|
+
});
|
|
444
|
+
defineCatalog(builtin.colorPicker, "de", {
|
|
445
|
+
hue: "Farbton",
|
|
446
|
+
alpha: "Alpha",
|
|
447
|
+
colorArea: "Sättigung und Helligkeit",
|
|
448
|
+
eyedropper: "Farbe vom Bildschirm wählen"
|
|
449
|
+
});
|
|
450
|
+
defineCatalog(builtin.drawer, "de", { close: "Schließen" });
|
|
451
|
+
defineCatalog(builtin.menuButton, "de", { open: "Menü öffnen" });
|
|
452
|
+
defineCatalog(builtin.resizable, "de", { handle: "Bereiche anpassen" });
|
|
453
|
+
defineCatalog(builtin.codeSnippet, "de", {
|
|
454
|
+
copy: "Code kopieren",
|
|
455
|
+
copied: "Kopiert"
|
|
456
|
+
});
|
|
457
|
+
defineCatalog(builtin.dateRangePicker, "de", {
|
|
458
|
+
placeholder: "Zeitraum auswählen",
|
|
459
|
+
start: "Startdatum",
|
|
460
|
+
end: "Enddatum",
|
|
461
|
+
apply: "Anwenden",
|
|
462
|
+
clear: "Löschen"
|
|
463
|
+
});
|
|
464
|
+
defineCatalog(builtin.toggletip, "de", { label: "Weitere Informationen" });
|
|
465
|
+
//#endregion
|
|
466
|
+
export { builtin, createLocale, currentLocale, defineCatalog, defineMessages, formatDate, formatList, formatNumber, formatRelativeTime, t, translateKey };
|
|
467
|
+
|
|
468
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../src/locale.ts","../src/messages.ts","../src/format.ts","../src/builtin.ts"],"sourcesContent":["import { signal } from '@cascivo/core'\nimport type { ReadonlySignal } from '@cascivo/core'\n\n// Module-global active locale: t() and the formatters resolve against this,\n// so components need no provider — zero-config means default locale ('en').\nconst activeLocale = signal('en')\n\nexport function currentLocale(): string {\n return activeLocale.value\n}\n\nexport interface LocaleStore<L extends string> {\n locale: ReadonlySignal<L>\n supported: readonly L[]\n set(locale: L): Promise<void>\n /** Lazy catalog: `store.registerCatalog('de', () => import('./de'))`. */\n registerCatalog(locale: L, load: () => Promise<unknown>): void\n}\n\nexport function createLocale<const L extends string>(options: {\n default: L\n supported: readonly L[]\n}): LocaleStore<L> {\n const loaders = new Map<L, () => Promise<unknown>>()\n const loaded = new Set<L>([options.default])\n activeLocale.value = options.default\n\n return {\n locale: activeLocale as ReadonlySignal<L>,\n supported: options.supported,\n registerCatalog(locale, load) {\n loaders.set(locale, load)\n },\n async set(locale) {\n if (!options.supported.includes(locale)) {\n throw new Error(\n `Unsupported locale \"${locale}\" (supported: ${options.supported.join(', ')})`,\n )\n }\n const load = loaders.get(locale)\n if (load && !loaded.has(locale)) {\n await load()\n loaded.add(locale)\n }\n activeLocale.value = locale\n },\n }\n}\n","import { signal } from '@cascivo/core'\nimport { currentLocale } from './locale'\nimport type { Message, MessageValue, PluralForms, TArgs } from './types'\n\n// locale → message key → translated value\nconst catalogs = new Map<string, Map<string, MessageValue>>()\n// Bumped on registration so signal-tracked t() output re-resolves.\nconst catalogVersion = signal(0)\n// module-global defaults for key-based lookup (used by translateKey)\nconst defaults = new Map<string, MessageValue>()\n\nexport function defineMessages<const T extends Record<string, MessageValue>>(\n namespace: string,\n messages: T,\n): { [K in keyof T]: Message<T[K]> } {\n return Object.fromEntries(\n Object.entries(messages).map(([name, value]) => {\n const key = `${namespace}.${name}`\n defaults.set(key, value)\n return [name, { key, value }]\n }),\n ) as { [K in keyof T]: Message<T[K]> }\n}\n\nexport function defineCatalog<T extends Record<string, Message>>(\n messages: T,\n locale: string,\n dict: { [K in keyof T]: T[K]['value'] extends PluralForms ? PluralForms : string },\n): void {\n let catalog = catalogs.get(locale)\n if (!catalog) {\n catalog = new Map()\n catalogs.set(locale, catalog)\n }\n for (const [name, message] of Object.entries(messages)) {\n catalog.set(message.key, dict[name as keyof T] as MessageValue)\n }\n catalogVersion.value++\n}\n\nconst pluralRules = new Map<string, Intl.PluralRules>()\n\nfunction interpolate(template: string, params?: Record<string, string | number>): string {\n if (!params) return template\n return template.replace(/\\{(\\w+)\\}/g, (match, name: string) =>\n name in params ? String(params[name]) : match,\n )\n}\n\n/** Key-string lookup for serialized references (JSON configs). Untyped by design. */\nexport function translateKey(key: string, params?: Record<string, string | number>): string {\n void catalogVersion.value // subscribe signal-tracked callers to catalog updates\n const locale = currentLocale()\n const value = catalogs.get(locale)?.get(key) ?? defaults.get(key)\n if (value === undefined) return key\n // Reuse t's resolution by constructing a transient Message; untyped by design\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return (t as (...a: any[]) => string)({ key, value }, params)\n}\n\nexport function t<V extends MessageValue>(message: Message<V>, ...args: TArgs<V>): string {\n void catalogVersion.value // subscribe signal-tracked callers to catalog updates\n const locale = currentLocale()\n const value = catalogs.get(locale)?.get(message.key) ?? message.value\n const params = args[0] as Record<string, string | number> | undefined\n if (typeof value === 'string') return interpolate(value, params)\n let rules = pluralRules.get(locale)\n if (!rules) {\n rules = new Intl.PluralRules(locale)\n pluralRules.set(locale, rules)\n }\n const branch = value[rules.select(Number(params?.['count'] ?? 0))] ?? value.other\n return interpolate(branch, params)\n}\n","import { currentLocale } from './locale'\n\nfunction memo<O, F>(create: (locale: string, options?: O) => F): (options?: O) => F {\n const cache = new Map<string, F>()\n return (options?: O) => {\n const locale = currentLocale()\n const key = `${locale}|${JSON.stringify(options ?? {})}`\n let formatter = cache.get(key)\n if (!formatter) {\n formatter = create(locale, options)\n cache.set(key, formatter)\n }\n return formatter\n }\n}\n\nconst numberFormat = memo(\n (locale, options?: Intl.NumberFormatOptions) => new Intl.NumberFormat(locale, options),\n)\nconst dateFormat = memo(\n (locale, options?: Intl.DateTimeFormatOptions) => new Intl.DateTimeFormat(locale, options),\n)\nconst relativeFormat = memo(\n (locale, options?: Intl.RelativeTimeFormatOptions) =>\n new Intl.RelativeTimeFormat(locale, options),\n)\nconst listFormat = memo(\n (locale, options?: Intl.ListFormatOptions) => new Intl.ListFormat(locale, options),\n)\n\nexport function formatNumber(value: number, options?: Intl.NumberFormatOptions): string {\n return numberFormat(options).format(value)\n}\n\nexport function formatDate(value: Date | number, options?: Intl.DateTimeFormatOptions): string {\n return dateFormat(options).format(value)\n}\n\nexport function formatRelativeTime(\n value: number,\n unit: Intl.RelativeTimeFormatUnit,\n options?: Intl.RelativeTimeFormatOptions,\n): string {\n return relativeFormat(options).format(value, unit)\n}\n\nexport function formatList(items: string[], options?: Intl.ListFormatOptions): string {\n return listFormat(options).format(items)\n}\n","import { defineCatalog, defineMessages } from './messages'\n\n/**\n * Built-in strings for cascade components. Components call\n * `t(builtin.<component>.<key>)` as the default and accept a `labels` prop\n * override. en values are the message defaults; de ships first-party.\n */\nexport const builtin = {\n pagination: defineMessages('cascade.pagination', {\n itemsPerPage: 'Items per page',\n pageOf: 'Page {page} of {total}',\n range: '{start}–{end} of {total} items',\n previous: 'Previous page',\n next: 'Next page',\n nav: 'Pagination',\n }),\n toast: defineMessages('cascade.toast', {\n dismiss: 'Dismiss notification',\n region: 'Notifications',\n }),\n modal: defineMessages('cascade.modal', {\n close: 'Close modal',\n }),\n alert: defineMessages('cascade.alert', {\n dismiss: 'Dismiss',\n }),\n header: defineMessages('cascade.header', {\n nav: 'Main',\n }),\n search: defineMessages('cascade.search', {\n label: 'Search',\n placeholder: 'Search',\n clear: 'Clear search',\n }),\n commandMenu: defineMessages('cascade.commandMenu', {\n label: 'Command menu',\n placeholder: 'Type a command or search…',\n empty: 'No results found',\n back: 'Back',\n loading: 'Loading…',\n }),\n breadcrumb: defineMessages('cascade.breadcrumb', {\n nav: 'Breadcrumb',\n }),\n datePicker: defineMessages('cascade.datePicker', {\n placeholder: 'Select a date',\n previousMonth: 'Previous month',\n nextMonth: 'Next month',\n clear: 'Clear date',\n }),\n combobox: defineMessages('cascade.combobox', {\n placeholder: 'Select an option',\n empty: 'No options found',\n clear: 'Clear selection',\n }),\n dataTable: defineMessages('cascade.dataTable', {\n search: 'Search',\n empty: 'No data',\n selectAll: 'Select all rows',\n selectRow: 'Select row',\n itemsSelected: '{count} selected',\n expandRow: 'Expand row',\n }),\n overflowMenu: defineMessages('cascade.overflowMenu', {\n trigger: 'More actions',\n }),\n sideNav: defineMessages('cascade.sideNav', {\n nav: 'Side navigation',\n collapse: 'Collapse navigation',\n expand: 'Expand navigation',\n }),\n spinner: defineMessages('cascade.spinner', {\n label: 'Loading',\n }),\n numberInput: defineMessages('cascade.numberInput', {\n increment: 'Increment',\n decrement: 'Decrement',\n }),\n tag: defineMessages('cascade.tag', {\n dismiss: 'Remove',\n }),\n appShell: defineMessages('cascade.appShell', {\n collapse: 'Collapse navigation',\n expand: 'Expand navigation',\n dismissError: 'Dismiss error',\n }),\n charts: defineMessages('cascade.charts', {\n legendToggle: 'Toggle series {name}',\n }),\n alertDialog: defineMessages('cascade.alertDialog', {\n confirm: 'Confirm',\n cancel: 'Cancel',\n }),\n sheet: defineMessages('cascade.sheet', {\n close: 'Close panel',\n }),\n fileUploader: defineMessages('cascade.fileUploader', {\n label: 'Upload files',\n drop: 'Drag and drop files here or click to upload',\n remove: 'Remove {name}',\n uploading: 'Uploading',\n complete: 'Upload complete',\n error: 'Upload failed',\n }),\n passwordInput: defineMessages('cascade.passwordInput', {\n reveal: 'Show password',\n hide: 'Hide password',\n strengthWeak: 'weak',\n strengthFair: 'fair',\n strengthGood: 'good',\n strengthStrong: 'strong',\n strengthLabel: 'Password strength: {level}',\n }),\n multiSelect: defineMessages('cascade.multiSelect', {\n placeholder: 'Select options',\n selected: '{count} selected',\n search: 'Search options',\n noResults: 'No options found',\n }),\n tagsInput: defineMessages('cascade.tagsInput', {\n remove: 'Remove {tag}',\n placeholder: 'Add tag…',\n }),\n otpInput: defineMessages('cascade.otpInput', {\n label: 'One-time code',\n digit: 'Digit {n}',\n }),\n ai: defineMessages('cascade.ai', {\n generating: 'Generating…',\n done: 'Done',\n error: 'Error',\n send: 'Send',\n placeholder: 'Type a message…',\n you: 'You',\n assistant: 'Assistant',\n }),\n shellHeader: defineMessages('cascade.shellHeader', {\n skipToContent: 'Skip to main content',\n nav: 'Main',\n openMenu: 'Open navigation',\n closeMenu: 'Close navigation',\n }),\n headerPanel: defineMessages('cascade.headerPanel', {\n close: 'Close panel',\n }),\n switcher: defineMessages('cascade.switcher', {\n label: 'Switch application',\n }),\n copyButton: defineMessages('cascade.copyButton', {\n copy: 'Copy',\n copied: 'Copied',\n }),\n skipNav: defineMessages('cascade.skipNav', {\n label: 'Skip to content',\n }),\n form: defineMessages('cascade.form', {\n required: 'Required',\n invalid: 'Invalid value',\n }),\n label: defineMessages('cascade.label', {\n required: 'Required',\n }),\n inlineLoading: defineMessages('cascade.inlineLoading', {\n active: 'Loading',\n finished: 'Loaded',\n error: 'Error',\n }),\n notification: defineMessages('cascade.notification', {\n dismiss: 'Dismiss',\n }),\n treeView: defineMessages('cascade.treeView', {\n loading: 'Loading…',\n expand: 'Expand',\n collapse: 'Collapse',\n }),\n carousel: defineMessages('cascade.carousel', {\n region: 'Carousel',\n previous: 'Previous slide',\n next: 'Next slide',\n slide: '{n} of {total}',\n goTo: 'Go to slide {n}',\n }),\n calendar: defineMessages('cascade.calendar', {\n previousMonth: 'Previous month',\n nextMonth: 'Next month',\n today: 'Today',\n }),\n colorPicker: defineMessages('cascade.colorPicker', {\n hue: 'Hue',\n alpha: 'Alpha',\n colorArea: 'Saturation and lightness',\n eyedropper: 'Pick a color from the screen',\n }),\n drawer: defineMessages('cascade.drawer', {\n close: 'Close',\n }),\n menuButton: defineMessages('cascade.menuButton', {\n open: 'Open menu',\n }),\n resizable: defineMessages('cascade.resizable', {\n handle: 'Resize panels',\n }),\n codeSnippet: defineMessages('cascade.codeSnippet', {\n copy: 'Copy code',\n copied: 'Copied',\n }),\n dateRangePicker: defineMessages('cascade.dateRangePicker', {\n placeholder: 'Select a date range',\n start: 'Start date',\n end: 'End date',\n apply: 'Apply',\n clear: 'Clear',\n }),\n toggletip: defineMessages('cascade.toggletip', {\n label: 'More information',\n }),\n}\n\ndefineCatalog(builtin.pagination, 'de', {\n itemsPerPage: 'Einträge pro Seite',\n pageOf: 'Seite {page} von {total}',\n range: '{start}–{end} von {total} Einträgen',\n previous: 'Vorherige Seite',\n next: 'Nächste Seite',\n nav: 'Seitennummerierung',\n})\ndefineCatalog(builtin.toast, 'de', {\n dismiss: 'Benachrichtigung schließen',\n region: 'Benachrichtigungen',\n})\ndefineCatalog(builtin.modal, 'de', {\n close: 'Dialog schließen',\n})\ndefineCatalog(builtin.alert, 'de', {\n dismiss: 'Schließen',\n})\ndefineCatalog(builtin.header, 'de', {\n nav: 'Hauptnavigation',\n})\ndefineCatalog(builtin.search, 'de', {\n label: 'Suche',\n placeholder: 'Suchen',\n clear: 'Suche löschen',\n})\ndefineCatalog(builtin.commandMenu, 'de', {\n label: 'Befehlsmenü',\n placeholder: 'Befehl oder Suche eingeben…',\n empty: 'Keine Ergebnisse',\n back: 'Zurück',\n loading: 'Wird geladen…',\n})\ndefineCatalog(builtin.breadcrumb, 'de', {\n nav: 'Navigationspfad',\n})\ndefineCatalog(builtin.datePicker, 'de', {\n placeholder: 'Datum auswählen',\n previousMonth: 'Vorheriger Monat',\n nextMonth: 'Nächster Monat',\n clear: 'Datum löschen',\n})\ndefineCatalog(builtin.combobox, 'de', {\n placeholder: 'Option auswählen',\n empty: 'Keine Optionen gefunden',\n clear: 'Auswahl löschen',\n})\ndefineCatalog(builtin.dataTable, 'de', {\n search: 'Suchen',\n empty: 'Keine Daten',\n selectAll: 'Alle Zeilen auswählen',\n selectRow: 'Zeile auswählen',\n itemsSelected: '{count} ausgewählt',\n expandRow: 'Zeile aufklappen',\n})\ndefineCatalog(builtin.overflowMenu, 'de', {\n trigger: 'Weitere Aktionen',\n})\ndefineCatalog(builtin.sideNav, 'de', {\n nav: 'Seitennavigation',\n collapse: 'Navigation einklappen',\n expand: 'Navigation ausklappen',\n})\ndefineCatalog(builtin.spinner, 'de', {\n label: 'Wird geladen',\n})\ndefineCatalog(builtin.numberInput, 'de', {\n increment: 'Erhöhen',\n decrement: 'Verringern',\n})\ndefineCatalog(builtin.tag, 'de', {\n dismiss: 'Entfernen',\n})\ndefineCatalog(builtin.appShell, 'de', {\n collapse: 'Navigation einklappen',\n expand: 'Navigation ausklappen',\n dismissError: 'Fehler schließen',\n})\ndefineCatalog(builtin.charts, 'de', {\n legendToggle: 'Reihe {name} umschalten',\n})\ndefineCatalog(builtin.alertDialog, 'de', {\n confirm: 'Bestätigen',\n cancel: 'Abbrechen',\n})\ndefineCatalog(builtin.sheet, 'de', {\n close: 'Bereich schließen',\n})\ndefineCatalog(builtin.fileUploader, 'de', {\n label: 'Dateien hochladen',\n drop: 'Dateien hier ablegen oder klicken zum Hochladen',\n remove: '{name} entfernen',\n uploading: 'Wird hochgeladen',\n complete: 'Hochladen abgeschlossen',\n error: 'Hochladen fehlgeschlagen',\n})\ndefineCatalog(builtin.passwordInput, 'de', {\n reveal: 'Passwort anzeigen',\n hide: 'Passwort verbergen',\n strengthWeak: 'schwach',\n strengthFair: 'mäßig',\n strengthGood: 'gut',\n strengthStrong: 'stark',\n strengthLabel: 'Passwortstärke: {level}',\n})\ndefineCatalog(builtin.multiSelect, 'de', {\n placeholder: 'Optionen auswählen',\n selected: '{count} ausgewählt',\n search: 'Optionen durchsuchen',\n noResults: 'Keine Optionen gefunden',\n})\ndefineCatalog(builtin.tagsInput, 'de', {\n remove: '{tag} entfernen',\n placeholder: 'Tag hinzufügen…',\n})\ndefineCatalog(builtin.otpInput, 'de', {\n label: 'Einmalcode',\n digit: 'Ziffer {n}',\n})\ndefineCatalog(builtin.ai, 'de', {\n generating: 'Wird generiert…',\n done: 'Fertig',\n error: 'Fehler',\n send: 'Senden',\n placeholder: 'Nachricht eingeben…',\n you: 'Du',\n assistant: 'Assistent',\n})\ndefineCatalog(builtin.shellHeader, 'de', {\n skipToContent: 'Zum Hauptinhalt springen',\n nav: 'Hauptnavigation',\n openMenu: 'Navigation öffnen',\n closeMenu: 'Navigation schließen',\n})\ndefineCatalog(builtin.headerPanel, 'de', {\n close: 'Panel schließen',\n})\ndefineCatalog(builtin.switcher, 'de', {\n label: 'Anwendung wechseln',\n})\ndefineCatalog(builtin.copyButton, 'de', {\n copy: 'Kopieren',\n copied: 'Kopiert',\n})\ndefineCatalog(builtin.skipNav, 'de', {\n label: 'Zum Inhalt springen',\n})\ndefineCatalog(builtin.form, 'de', {\n required: 'Pflichtfeld',\n invalid: 'Ungültiger Wert',\n})\ndefineCatalog(builtin.label, 'de', {\n required: 'Erforderlich',\n})\ndefineCatalog(builtin.inlineLoading, 'de', {\n active: 'Wird geladen',\n finished: 'Geladen',\n error: 'Fehler',\n})\ndefineCatalog(builtin.notification, 'de', {\n dismiss: 'Schließen',\n})\ndefineCatalog(builtin.treeView, 'de', {\n loading: 'Wird geladen…',\n expand: 'Aufklappen',\n collapse: 'Zuklappen',\n})\ndefineCatalog(builtin.carousel, 'de', {\n region: 'Karussell',\n previous: 'Vorherige Folie',\n next: 'Nächste Folie',\n slide: '{n} von {total}',\n goTo: 'Zu Folie {n}',\n})\ndefineCatalog(builtin.calendar, 'de', {\n previousMonth: 'Vorheriger Monat',\n nextMonth: 'Nächster Monat',\n today: 'Heute',\n})\ndefineCatalog(builtin.colorPicker, 'de', {\n hue: 'Farbton',\n alpha: 'Alpha',\n colorArea: 'Sättigung und Helligkeit',\n eyedropper: 'Farbe vom Bildschirm wählen',\n})\ndefineCatalog(builtin.drawer, 'de', {\n close: 'Schließen',\n})\ndefineCatalog(builtin.menuButton, 'de', {\n open: 'Menü öffnen',\n})\ndefineCatalog(builtin.resizable, 'de', {\n handle: 'Bereiche anpassen',\n})\ndefineCatalog(builtin.codeSnippet, 'de', {\n copy: 'Code kopieren',\n copied: 'Kopiert',\n})\ndefineCatalog(builtin.dateRangePicker, 'de', {\n placeholder: 'Zeitraum auswählen',\n start: 'Startdatum',\n end: 'Enddatum',\n apply: 'Anwenden',\n clear: 'Löschen',\n})\ndefineCatalog(builtin.toggletip, 'de', {\n label: 'Weitere Informationen',\n})\n"],"mappings":";;AAKA,MAAM,eAAe,OAAO,IAAI;AAEhC,SAAgB,gBAAwB;CACtC,OAAO,aAAa;AACtB;AAUA,SAAgB,aAAqC,SAGlC;CACjB,MAAM,0BAAU,IAAI,IAA+B;CACnD,MAAM,SAAS,IAAI,IAAO,CAAC,QAAQ,OAAO,CAAC;CAC3C,aAAa,QAAQ,QAAQ;CAE7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N,OAAO;CACP,MAAM;AACR,CAAC;AACD,cAAc,QAAQ,UAAU,MAAM;CACpC,eAAe;CACf,WAAW;CACX,OAAO;AACT,CAAC;AACD,cAAc,QAAQ,aAAa,MAAM;CACvC,KAAK;CACL,OAAO;CACP,WAAW;CACX,YAAY;AACd,CAAC;AACD,cAAc,QAAQ,QAAQ,MAAM,EAClC,OAAO,YACT,CAAC;AACD,cAAc,QAAQ,YAAY,MAAM,EACtC,MAAM,cACR,CAAC;AACD,cAAc,QAAQ,WAAW,MAAM,EACrC,QAAQ,oBACV,CAAC;AACD,cAAc,QAAQ,aAAa,MAAM;CACvC,MAAM;CACN,QAAQ;AACV,CAAC;AACD,cAAc,QAAQ,iBAAiB,MAAM;CAC3C,aAAa;CACb,OAAO;CACP,KAAK;CACL,OAAO;CACP,OAAO;AACT,CAAC;AACD,cAAc,QAAQ,WAAW,MAAM,EACrC,OAAO,wBACT,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@cascivo/i18n",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"private": false,
|
|
5
|
+
"description": "Signal-driven locale store, typed message catalogs, and Intl-based formatting for cascade",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"cascivo",
|
|
8
|
+
"css",
|
|
9
|
+
"design-system",
|
|
10
|
+
"i18n",
|
|
11
|
+
"internationalization",
|
|
12
|
+
"intl",
|
|
13
|
+
"react",
|
|
14
|
+
"signals"
|
|
15
|
+
],
|
|
16
|
+
"homepage": "https://github.com/urbanisierung/cascivo/tree/main/packages/i18n#readme",
|
|
17
|
+
"bugs": "https://github.com/urbanisierung/cascivo/issues",
|
|
18
|
+
"license": "MIT",
|
|
19
|
+
"author": "urbanisierung",
|
|
20
|
+
"repository": {
|
|
21
|
+
"type": "git",
|
|
22
|
+
"url": "git+https://github.com/urbanisierung/cascivo.git",
|
|
23
|
+
"directory": "packages/i18n"
|
|
24
|
+
},
|
|
25
|
+
"files": [
|
|
26
|
+
"dist"
|
|
27
|
+
],
|
|
28
|
+
"type": "module",
|
|
29
|
+
"types": "./dist/index.d.mts",
|
|
30
|
+
"exports": {
|
|
31
|
+
".": {
|
|
32
|
+
"import": "./dist/index.mjs",
|
|
33
|
+
"types": "./dist/index.d.mts",
|
|
34
|
+
"default": "./dist/index.mjs"
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
"publishConfig": {
|
|
38
|
+
"access": "public",
|
|
39
|
+
"provenance": true
|
|
40
|
+
},
|
|
41
|
+
"dependencies": {
|
|
42
|
+
"@cascivo/core": "^0.1.0"
|
|
43
|
+
},
|
|
44
|
+
"devDependencies": {
|
|
45
|
+
"@preact/signals-react": "^3",
|
|
46
|
+
"typescript": "^5",
|
|
47
|
+
"vite-plus": "^0.1.24"
|
|
48
|
+
},
|
|
49
|
+
"peerDependencies": {
|
|
50
|
+
"@preact/signals-react": ">=2.0.0"
|
|
51
|
+
},
|
|
52
|
+
"scripts": {
|
|
53
|
+
"build": "vp pack",
|
|
54
|
+
"check": "tsc --noEmit",
|
|
55
|
+
"test": "vp test",
|
|
56
|
+
"dev": "vp pack --watch"
|
|
57
|
+
}
|
|
58
|
+
}
|
package/readme.body.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Signal-driven internationalisation layer for cascade — locale store, typed string catalogs, and `Intl` formatting helpers. Components read from the built-in catalog by default; pass a `labels` prop to override per-instance.
|