@fluenti/solid 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 +317 -0
- package/dist/compile-time-t.d.ts +3 -0
- package/dist/compile-time-t.d.ts.map +1 -0
- package/dist/components/DateTime.d.ts +16 -0
- package/dist/components/DateTime.d.ts.map +1 -0
- package/dist/components/NumberFormat.d.ts +16 -0
- package/dist/components/NumberFormat.d.ts.map +1 -0
- package/dist/context.d.ts +69 -0
- package/dist/context.d.ts.map +1 -0
- package/dist/hooks/__useI18n.d.ts +12 -0
- package/dist/hooks/__useI18n.d.ts.map +1 -0
- package/dist/index.cjs +2 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +446 -0
- package/dist/index.js.map +1 -0
- package/dist/msg.d.ts +2 -0
- package/dist/msg.d.ts.map +1 -0
- package/dist/plural.d.ts +55 -0
- package/dist/plural.d.ts.map +1 -0
- package/dist/provider.d.ts +10 -0
- package/dist/provider.d.ts.map +1 -0
- package/dist/rich-dom.d.ts +17 -0
- package/dist/rich-dom.d.ts.map +1 -0
- package/dist/select.d.ts +49 -0
- package/dist/select.d.ts.map +1 -0
- package/dist/server.d.ts +77 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/trans.d.ts +46 -0
- package/dist/trans.d.ts.map +1 -0
- package/dist/types.d.ts +45 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/use-i18n.d.ts +12 -0
- package/dist/use-i18n.d.ts.map +1 -0
- package/package.json +75 -0
- package/src/compile-time-t.ts +9 -0
- package/src/components/DateTime.tsx +21 -0
- package/src/components/NumberFormat.tsx +21 -0
- package/src/context.ts +337 -0
- package/src/hooks/__useI18n.ts +15 -0
- package/src/index.ts +14 -0
- package/src/msg.ts +4 -0
- package/src/plural.tsx +136 -0
- package/src/provider.tsx +16 -0
- package/src/rich-dom.tsx +170 -0
- package/src/select.tsx +90 -0
- package/src/server.ts +153 -0
- package/src/trans.tsx +243 -0
- package/src/types.ts +55 -0
- package/src/use-i18n.ts +30 -0
- package/src/vite-runtime.d.ts +4 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Fluenti Contributors
|
|
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 all
|
|
13
|
+
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,317 @@
|
|
|
1
|
+
# @fluenti/solid
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@fluenti/solid)
|
|
4
|
+
[](https://bundlephobia.com/package/@fluenti/solid)
|
|
5
|
+
[](https://github.com/usefluenti/fluenti/blob/main/LICENSE)
|
|
6
|
+
|
|
7
|
+
**Compile-time i18n for SolidJS** -- reactive by design, zero runtime overhead.
|
|
8
|
+
|
|
9
|
+
Fluenti compiles your messages at build time and pairs them with Solid's fine-grained reactivity. When the locale changes, only the text nodes that depend on it re-render. No virtual DOM diffing, no wasted work.
|
|
10
|
+
|
|
11
|
+
## Features
|
|
12
|
+
|
|
13
|
+
- **Compile-time transforms** -- messages are resolved during the build; the runtime ships precompiled functions, not an ICU parser.
|
|
14
|
+
- **Signal-driven locale** -- `locale()` is a Solid signal; any computation that reads it re-runs automatically.
|
|
15
|
+
- **`<Trans>`, `<Plural>`, `<Select>`, `<DateTime>`, `<NumberFormat>`** -- declarative components that map directly to ICU MessageFormat.
|
|
16
|
+
- **`t()` / `d()` / `n()` / `msg()`** -- imperative API for strings, dates, numbers, and lazy message definitions.
|
|
17
|
+
- **Code splitting** -- load locale chunks on demand with a single `chunkLoader` option.
|
|
18
|
+
- **SSR-ready** -- first-class SolidStart support with per-request isolation.
|
|
19
|
+
|
|
20
|
+
## Quick Start
|
|
21
|
+
|
|
22
|
+
### 1. Install
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
pnpm add @fluenti/core @fluenti/solid
|
|
26
|
+
pnpm add -D @fluenti/cli @fluenti/vite-plugin
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
### 2. Configure Vite
|
|
30
|
+
|
|
31
|
+
```ts
|
|
32
|
+
// vite.config.ts
|
|
33
|
+
import solidPlugin from 'vite-plugin-solid'
|
|
34
|
+
import fluenti from '@fluenti/vite-plugin'
|
|
35
|
+
|
|
36
|
+
export default {
|
|
37
|
+
plugins: [solidPlugin(), fluenti({ framework: 'solid' })],
|
|
38
|
+
}
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### 3. Wrap your app
|
|
42
|
+
|
|
43
|
+
```tsx
|
|
44
|
+
// index.tsx
|
|
45
|
+
import { render } from 'solid-js/web'
|
|
46
|
+
import { I18nProvider } from '@fluenti/solid'
|
|
47
|
+
import en from './locales/compiled/en'
|
|
48
|
+
import ja from './locales/compiled/ja'
|
|
49
|
+
import App from './App'
|
|
50
|
+
|
|
51
|
+
render(
|
|
52
|
+
() => (
|
|
53
|
+
<I18nProvider locale="en" fallbackLocale="en" messages={{ en, ja }}>
|
|
54
|
+
<App />
|
|
55
|
+
</I18nProvider>
|
|
56
|
+
),
|
|
57
|
+
document.getElementById('root')!,
|
|
58
|
+
)
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### 4. Translate
|
|
62
|
+
|
|
63
|
+
```tsx
|
|
64
|
+
import { useI18n, Trans, Plural, Select } from '@fluenti/solid'
|
|
65
|
+
|
|
66
|
+
function Demo(props) {
|
|
67
|
+
const { t, d, n, locale, setLocale } = useI18n()
|
|
68
|
+
|
|
69
|
+
return (
|
|
70
|
+
<div>
|
|
71
|
+
{/* Function call with catalog lookup */}
|
|
72
|
+
<h1>{t('Hello, {name}!', { name: 'World' })}</h1>
|
|
73
|
+
|
|
74
|
+
{/* Tagged template literal */}
|
|
75
|
+
<h1>{t`Hello, ${name}!`}</h1>
|
|
76
|
+
|
|
77
|
+
<Trans>Read the <a href="/docs">documentation</a></Trans>
|
|
78
|
+
|
|
79
|
+
<Plural value={props.count} one="# item" other="# items" />
|
|
80
|
+
|
|
81
|
+
<Select value={props.gender} male="He" female="She" other="They" />
|
|
82
|
+
|
|
83
|
+
<p>{d(new Date(), 'long')}</p>
|
|
84
|
+
<p>{n(1234.5, 'currency')}</p>
|
|
85
|
+
|
|
86
|
+
<button onClick={() => setLocale('ja')}>日本語</button>
|
|
87
|
+
</div>
|
|
88
|
+
)
|
|
89
|
+
}
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## What the compiler does
|
|
93
|
+
|
|
94
|
+
Write natural-language JSX. The Vite plugin extracts messages, generates deterministic IDs, and replaces the source with precompiled lookups -- all at build time.
|
|
95
|
+
|
|
96
|
+
```tsx
|
|
97
|
+
// You write:
|
|
98
|
+
<Plural value={count} one="# item" other="# items" />
|
|
99
|
+
|
|
100
|
+
// The compiler emits (conceptually):
|
|
101
|
+
t('abc123', { count }) // hash-based lookup, no ICU parsing at runtime
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
## API Reference
|
|
105
|
+
|
|
106
|
+
### `useI18n()`
|
|
107
|
+
|
|
108
|
+
Returns the reactive i18n context. Works inside any component that is a descendant of `<I18nProvider>`, or after a top-level `createI18n()` call.
|
|
109
|
+
|
|
110
|
+
```tsx
|
|
111
|
+
const { t, d, n, format, locale, setLocale, isLoading } = useI18n()
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
| Method | Signature | Description |
|
|
115
|
+
|--------|-----------|-------------|
|
|
116
|
+
| `t` | `(id: string \| MessageDescriptor, values?) => string` or `` t`Hello ${name}` `` | Dual-mode: function call for catalog lookup, or tagged template literal |
|
|
117
|
+
| `d` | `(value: Date \| number, style?) => string` | Format a date using named presets or Intl defaults |
|
|
118
|
+
| `n` | `(value: number, style?) => string` | Format a number using named presets or Intl defaults |
|
|
119
|
+
| `format` | `(message: string, values?) => string` | Format an ICU message string directly (no catalog lookup) |
|
|
120
|
+
| `locale` | `Accessor<string>` | Reactive signal for the current locale |
|
|
121
|
+
| `setLocale` | `(locale: string) => Promise<void>` | Change locale (async when lazy locale loading is enabled) |
|
|
122
|
+
| `loadMessages` | `(locale: string, messages) => void` | Merge additional messages into a locale catalog at runtime |
|
|
123
|
+
| `getLocales` | `() => string[]` | List all locales that have loaded messages |
|
|
124
|
+
| `preloadLocale` | `(locale: string) => void` | Preload a locale chunk in the background without switching |
|
|
125
|
+
| `isLoading` | `Accessor<boolean>` | Whether a locale chunk is currently being loaded |
|
|
126
|
+
| `loadedLocales` | `Accessor<Set<string>>` | Set of locales whose messages have been loaded |
|
|
127
|
+
|
|
128
|
+
### `createI18n(config)`
|
|
129
|
+
|
|
130
|
+
Module-level singleton alternative to `<I18nProvider>`. Call once at startup; `useI18n()` will find it automatically.
|
|
131
|
+
|
|
132
|
+
```tsx
|
|
133
|
+
import { createI18n } from '@fluenti/solid'
|
|
134
|
+
|
|
135
|
+
const i18n = createI18n({
|
|
136
|
+
locale: 'en',
|
|
137
|
+
fallbackLocale: 'en',
|
|
138
|
+
messages: { en, ja },
|
|
139
|
+
|
|
140
|
+
// Optional: post-translation transform, locale change callback, custom formatters
|
|
141
|
+
transform: (result, id, locale) => result,
|
|
142
|
+
onLocaleChange: (newLocale, prevLocale) => { /* ... */ },
|
|
143
|
+
formatters: { /* custom ICU function formatters */ },
|
|
144
|
+
})
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
The config accepts all `FluentConfigExtended` options from `@fluenti/core`, including `transform`, `onLocaleChange`, and `formatters`. See the [core README](https://github.com/usefluenti/fluenti/tree/main/packages/core#advanced-configuration) for details.
|
|
148
|
+
|
|
149
|
+
### Components
|
|
150
|
+
|
|
151
|
+
#### `<Trans>` -- Rich text
|
|
152
|
+
|
|
153
|
+
Render translated content containing inline JSX elements:
|
|
154
|
+
|
|
155
|
+
```tsx
|
|
156
|
+
<Trans>Click <a href="/next">here</a> to continue</Trans>
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
| Prop | Type | Default | Description |
|
|
160
|
+
|------|------|---------|-------------|
|
|
161
|
+
| `tag` | `string` | `'span'` | Wrapper element for multiple children |
|
|
162
|
+
|
|
163
|
+
#### `<Plural>` -- Plural forms
|
|
164
|
+
|
|
165
|
+
ICU plural rules as a component. Supports string props or rich-text JSX element props:
|
|
166
|
+
|
|
167
|
+
```tsx
|
|
168
|
+
{/* String props */}
|
|
169
|
+
<Plural value={count} zero="No items" one="1 item" other="{count} items" />
|
|
170
|
+
|
|
171
|
+
{/* Rich text via JSX element props */}
|
|
172
|
+
<Plural
|
|
173
|
+
value={count}
|
|
174
|
+
zero={<>No <strong>items</strong> left</>}
|
|
175
|
+
one={<><em>1</em> item remaining</>}
|
|
176
|
+
other={<><strong>{count}</strong> items remaining</>}
|
|
177
|
+
/>
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
| Prop | Type | Default | Description |
|
|
181
|
+
|------|------|---------|-------------|
|
|
182
|
+
| `value` | `number` | -- | The count to pluralize on (required) |
|
|
183
|
+
| `zero` | `string \| JSX.Element` | -- | Text for zero items |
|
|
184
|
+
| `one` | `string \| JSX.Element` | -- | Singular form |
|
|
185
|
+
| `two` | `string \| JSX.Element` | -- | Dual form |
|
|
186
|
+
| `few` | `string \| JSX.Element` | -- | Few form |
|
|
187
|
+
| `many` | `string \| JSX.Element` | -- | Many form |
|
|
188
|
+
| `other` | `string \| JSX.Element` | `''` | Default/fallback form |
|
|
189
|
+
|
|
190
|
+
#### `<Select>` -- Option selection
|
|
191
|
+
|
|
192
|
+
ICU select patterns as a component:
|
|
193
|
+
|
|
194
|
+
```tsx
|
|
195
|
+
{/* String props */}
|
|
196
|
+
<Select value={gender} male="He" female="She" other="They" />
|
|
197
|
+
|
|
198
|
+
{/* Rich text via options + other */}
|
|
199
|
+
<Select
|
|
200
|
+
value={gender}
|
|
201
|
+
options={{
|
|
202
|
+
male: <><strong>He</strong> liked this</>,
|
|
203
|
+
female: <><strong>She</strong> liked this</>,
|
|
204
|
+
}}
|
|
205
|
+
other={<><em>They</em> liked this</>}
|
|
206
|
+
/>
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
| Prop | Type | Default | Description |
|
|
210
|
+
|------|------|---------|-------------|
|
|
211
|
+
| `value` | `string` | -- | The value to match (required) |
|
|
212
|
+
| `options` | `Record<string, string \| JSX.Element>` | -- | Named options map |
|
|
213
|
+
| `other` | `string \| JSX.Element` | `''` | Fallback when no option matches |
|
|
214
|
+
|
|
215
|
+
#### `<DateTime>` -- Date formatting
|
|
216
|
+
|
|
217
|
+
```tsx
|
|
218
|
+
import { DateTime } from '@fluenti/solid'
|
|
219
|
+
|
|
220
|
+
<DateTime value={new Date()} style="long" />
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
| Prop | Type | Default | Description |
|
|
224
|
+
|------|------|---------|-------------|
|
|
225
|
+
| `value` | `Date \| number` | -- | The date value to format (required) |
|
|
226
|
+
| `style` | `string` | -- | Named date format style |
|
|
227
|
+
|
|
228
|
+
#### `<NumberFormat>` -- Number formatting
|
|
229
|
+
|
|
230
|
+
```tsx
|
|
231
|
+
import { NumberFormat } from '@fluenti/solid'
|
|
232
|
+
|
|
233
|
+
<NumberFormat value={1234.56} style="currency" />
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
| Prop | Type | Default | Description |
|
|
237
|
+
|------|------|---------|-------------|
|
|
238
|
+
| `value` | `number` | -- | The number to format (required) |
|
|
239
|
+
| `style` | `string` | -- | Named number format style |
|
|
240
|
+
|
|
241
|
+
### Utilities
|
|
242
|
+
|
|
243
|
+
| Export | Description |
|
|
244
|
+
|--------|-------------|
|
|
245
|
+
| `msg` | Tag for lazy message definitions outside the component tree |
|
|
246
|
+
|
|
247
|
+
## Code Splitting
|
|
248
|
+
|
|
249
|
+
Load locale messages on demand instead of bundling everything upfront:
|
|
250
|
+
|
|
251
|
+
```tsx
|
|
252
|
+
<I18nProvider
|
|
253
|
+
locale="en"
|
|
254
|
+
messages={{ en }}
|
|
255
|
+
lazyLocaleLoading
|
|
256
|
+
chunkLoader={(locale) => import(`./locales/compiled/${locale}.js`)}
|
|
257
|
+
>
|
|
258
|
+
<App />
|
|
259
|
+
</I18nProvider>
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
```tsx
|
|
263
|
+
const { setLocale, isLoading, preloadLocale } = useI18n()
|
|
264
|
+
|
|
265
|
+
// Preload on hover
|
|
266
|
+
onMount(() => preloadLocale('ja'))
|
|
267
|
+
|
|
268
|
+
// Switch locale -- instant if preloaded, async otherwise
|
|
269
|
+
await setLocale('ja')
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
## SSR with SolidStart
|
|
273
|
+
|
|
274
|
+
### Server-side i18n
|
|
275
|
+
|
|
276
|
+
Create a server-side i18n instance with per-request locale resolution:
|
|
277
|
+
|
|
278
|
+
```ts
|
|
279
|
+
// lib/i18n.server.ts
|
|
280
|
+
import { createServerI18n } from '@fluenti/solid/server'
|
|
281
|
+
|
|
282
|
+
export const { setLocale, getI18n } = createServerI18n({
|
|
283
|
+
loadMessages: (locale) => import(`../locales/compiled/${locale}.js`),
|
|
284
|
+
fallbackLocale: 'en',
|
|
285
|
+
resolveLocale: () => {
|
|
286
|
+
// Read locale from cookie, header, or URL
|
|
287
|
+
const event = getRequestEvent()
|
|
288
|
+
return event?.request.headers.get('accept-language')?.split(',')[0] ?? 'en'
|
|
289
|
+
},
|
|
290
|
+
})
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
### Hydration helper
|
|
294
|
+
|
|
295
|
+
The `getSSRLocaleScript` utility injects a tiny inline script that makes the server-detected locale available to the client before hydration, preventing a locale flash:
|
|
296
|
+
|
|
297
|
+
```tsx
|
|
298
|
+
import { getSSRLocaleScript } from '@fluenti/solid/server'
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
### SSR utilities re-exported from `@fluenti/solid/server`
|
|
302
|
+
|
|
303
|
+
| Export | Description |
|
|
304
|
+
|--------|-------------|
|
|
305
|
+
| `createServerI18n` | Create server-side i18n with lazy message loading |
|
|
306
|
+
| `detectLocale` | Detect locale from headers, cookies, URL path, or query |
|
|
307
|
+
| `getSSRLocaleScript` | Inline script for hydrating the locale on the client |
|
|
308
|
+
| `getHydratedLocale` | Read the locale set by the SSR script on the client |
|
|
309
|
+
| `isRTL` / `getDirection` | RTL detection helpers |
|
|
310
|
+
|
|
311
|
+
## Documentation
|
|
312
|
+
|
|
313
|
+
Full docs at [fluenti.dev](https://fluenti.dev).
|
|
314
|
+
|
|
315
|
+
## License
|
|
316
|
+
|
|
317
|
+
[MIT](https://github.com/usefluenti/fluenti/blob/main/LICENSE)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compile-time-t.d.ts","sourceRoot":"","sources":["../src/compile-time-t.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAEjD,eAAO,MAAM,CAAC,EAAE,YAME,CAAA"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export interface DateTimeProps {
|
|
2
|
+
/** Date value to format */
|
|
3
|
+
value: Date | number;
|
|
4
|
+
/** Named format style */
|
|
5
|
+
style?: string;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* `<DateTime>` — date formatting component using Intl APIs.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```tsx
|
|
12
|
+
* <DateTime value={new Date()} style="long" />
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
export declare function DateTime(props: DateTimeProps): import("solid-js").JSX.Element;
|
|
16
|
+
//# sourceMappingURL=DateTime.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DateTime.d.ts","sourceRoot":"","sources":["../../src/components/DateTime.tsx"],"names":[],"mappings":"AAEA,MAAM,WAAW,aAAa;IAC5B,2BAA2B;IAC3B,KAAK,EAAE,IAAI,GAAG,MAAM,CAAA;IACpB,yBAAyB;IACzB,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAED;;;;;;;GAOG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,aAAa,kCAG5C"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export interface NumberProps {
|
|
2
|
+
/** Number value to format */
|
|
3
|
+
value: number;
|
|
4
|
+
/** Named format style */
|
|
5
|
+
style?: string;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* `<NumberFormat>` — number formatting component using Intl APIs.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```tsx
|
|
12
|
+
* <NumberFormat value={1234.56} style="currency" />
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
export declare function NumberFormat(props: NumberProps): import("solid-js").JSX.Element;
|
|
16
|
+
//# sourceMappingURL=NumberFormat.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NumberFormat.d.ts","sourceRoot":"","sources":["../../src/components/NumberFormat.tsx"],"names":[],"mappings":"AAEA,MAAM,WAAW,WAAW;IAC1B,6BAA6B;IAC7B,KAAK,EAAE,MAAM,CAAA;IACb,yBAAyB;IACzB,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAED;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,WAAW,kCAG9C"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { Accessor } from 'solid-js';
|
|
2
|
+
import { FluentConfig, Locale, Messages, CompiledMessage, MessageDescriptor, DateFormatOptions, NumberFormatOptions } from '@fluenti/core';
|
|
3
|
+
/** Chunk loader for lazy locale loading */
|
|
4
|
+
export type ChunkLoader = (locale: string) => Promise<Record<string, CompiledMessage> | {
|
|
5
|
+
default: Record<string, CompiledMessage>;
|
|
6
|
+
}>;
|
|
7
|
+
/** Extended config with lazy locale loading support */
|
|
8
|
+
export interface I18nConfig extends FluentConfig {
|
|
9
|
+
/** Async chunk loader for lazy locale loading */
|
|
10
|
+
chunkLoader?: ChunkLoader;
|
|
11
|
+
/** Enable lazy locale loading through chunkLoader */
|
|
12
|
+
lazyLocaleLoading?: boolean;
|
|
13
|
+
/** Locale-specific fallback chains */
|
|
14
|
+
fallbackChain?: Record<string, Locale[]>;
|
|
15
|
+
/** Named date format styles */
|
|
16
|
+
dateFormats?: DateFormatOptions;
|
|
17
|
+
/** Named number format styles */
|
|
18
|
+
numberFormats?: NumberFormatOptions;
|
|
19
|
+
}
|
|
20
|
+
/** Reactive i18n context holding locale signal and translation utilities */
|
|
21
|
+
export interface I18nContext {
|
|
22
|
+
/** Reactive accessor for the current locale */
|
|
23
|
+
locale(): Locale;
|
|
24
|
+
/** Set the active locale (async when lazy locale loading is enabled) */
|
|
25
|
+
setLocale(locale: Locale): Promise<void>;
|
|
26
|
+
/** Translate a message by id with optional interpolation values */
|
|
27
|
+
t(id: string | MessageDescriptor, values?: Record<string, unknown>): string;
|
|
28
|
+
/** Tagged template form: t`Hello ${name}` */
|
|
29
|
+
t(strings: TemplateStringsArray, ...exprs: unknown[]): string;
|
|
30
|
+
/** Merge additional messages into a locale catalog at runtime */
|
|
31
|
+
loadMessages(locale: Locale, messages: Messages): void;
|
|
32
|
+
/** Return all locale codes that have loaded messages */
|
|
33
|
+
getLocales(): Locale[];
|
|
34
|
+
/** Format a date value for the current locale */
|
|
35
|
+
d(value: Date | number, style?: string): string;
|
|
36
|
+
/** Format a number value for the current locale */
|
|
37
|
+
n(value: number, style?: string): string;
|
|
38
|
+
/** Format an ICU message string directly (no catalog lookup) */
|
|
39
|
+
format(message: string, values?: Record<string, unknown>): string;
|
|
40
|
+
/** Whether a locale chunk is currently being loaded */
|
|
41
|
+
isLoading: Accessor<boolean>;
|
|
42
|
+
/** Set of locales whose messages have been loaded */
|
|
43
|
+
loadedLocales: Accessor<Set<string>>;
|
|
44
|
+
/** Preload a locale in the background without switching to it */
|
|
45
|
+
preloadLocale(locale: string): void;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Create a reactive i18n context backed by Solid signals.
|
|
49
|
+
*
|
|
50
|
+
* The returned `t()` reads the internal `locale()` signal, so any
|
|
51
|
+
* Solid computation that calls `t()` will re-run when the locale changes.
|
|
52
|
+
*/
|
|
53
|
+
export declare function createI18nContext(config: FluentConfig | I18nConfig): I18nContext;
|
|
54
|
+
/**
|
|
55
|
+
* Initialize the global i18n singleton.
|
|
56
|
+
*
|
|
57
|
+
* Call once at app startup (e.g. in your entry file) before any `useI18n()`.
|
|
58
|
+
* Signals are created inside a `createRoot` so they outlive any component scope.
|
|
59
|
+
*
|
|
60
|
+
* Returns the context for convenience, but `useI18n()` will also find it.
|
|
61
|
+
*/
|
|
62
|
+
export declare function createI18n(config: FluentConfig | I18nConfig): I18nContext;
|
|
63
|
+
/** @internal — used by useI18n and I18nProvider */
|
|
64
|
+
export declare function getGlobalI18nContext(): I18nContext | undefined;
|
|
65
|
+
/** @internal — used by I18nProvider to set context without createRoot wrapper */
|
|
66
|
+
export declare function setGlobalI18nContext(ctx: I18nContext): void;
|
|
67
|
+
/** @internal — reset the global singleton (for testing only) */
|
|
68
|
+
export declare function resetGlobalI18nContext(): void;
|
|
69
|
+
//# sourceMappingURL=context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAAA,OAAO,EAA4B,KAAK,QAAQ,EAAE,MAAM,UAAU,CAAA;AAElE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,EAAE,QAAQ,EAAE,eAAe,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAA;AAE/I,2CAA2C;AAC3C,MAAM,MAAM,WAAW,GAAG,CACxB,MAAM,EAAE,MAAM,KACX,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,GAAG;IAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAA;CAAE,CAAC,CAAA;AAwB5F,uDAAuD;AACvD,MAAM,WAAW,UAAW,SAAQ,YAAY;IAC9C,iDAAiD;IACjD,WAAW,CAAC,EAAE,WAAW,CAAA;IACzB,qDAAqD;IACrD,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAC3B,sCAAsC;IACtC,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAA;IACxC,+BAA+B;IAC/B,WAAW,CAAC,EAAE,iBAAiB,CAAA;IAC/B,iCAAiC;IACjC,aAAa,CAAC,EAAE,mBAAmB,CAAA;CACpC;AAED,4EAA4E;AAC5E,MAAM,WAAW,WAAW;IAC1B,+CAA+C;IAC/C,MAAM,IAAI,MAAM,CAAA;IAChB,wEAAwE;IACxE,SAAS,CAAC,MAAM,EAA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AI,WAAW,GAAG,SAAS,CAE9D;AAED,iFAAiF;AACjF,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,WAAW,GAAG,IAAI,CAE3D;AAED,gEAAgE;AAChE,wBAAgB,sBAAsB,IAAI,IAAI,CAE7C"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { I18nContext } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Internal hook used by the Vite plugin's compiled output.
|
|
4
|
+
* Returns the i18n context for direct t() calls.
|
|
5
|
+
*
|
|
6
|
+
* **Not part of the public API.** Users never write this — the Vite plugin
|
|
7
|
+
* generates imports of this hook automatically.
|
|
8
|
+
*
|
|
9
|
+
* @internal
|
|
10
|
+
*/
|
|
11
|
+
export declare function __useI18n(): I18nContext;
|
|
12
|
+
//# sourceMappingURL=__useI18n.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"__useI18n.d.ts","sourceRoot":"","sources":["../../src/hooks/__useI18n.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AAE3C;;;;;;;;GAQG;AACH,wBAAgB,SAAS,IAAI,WAAW,CAEvC"}
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require(`solid-js`),t=require(`@fluenti/core`),n=require(`solid-js/web`);var r=Symbol.for(`fluenti.runtime.solid`);function i(){let e=globalThis[r];return typeof e==`object`&&e?e:null}function a(e){return typeof e==`object`&&e&&`default`in e?e.default:e}function o(n){let[r,o]=(0,e.createSignal)(n.locale),[s,c]=(0,e.createSignal)(!1),l=new Set([n.locale]),[u,d]=(0,e.createSignal)(new Set(l)),f={...n.messages},p=n,m=p.lazyLocaleLoading??n.splitting??!1;function h(e,n,r){let i=f[n];if(!i)return;let a=i[e];if(a!==void 0)return typeof a==`function`?a(r):typeof a==`string`&&r?(0,t.interpolate)(a,r,n):String(a)}function g(e,t,r){let i=[t],a=new Set(i);n.fallbackLocale&&!a.has(n.fallbackLocale)&&(i.push(n.fallbackLocale),a.add(n.fallbackLocale));let o=p.fallbackChain?.[t]??p.fallbackChain?.[`*`];if(o)for(let e of o)a.has(e)||(i.push(e),a.add(e));for(let t of i){let n=h(e,t,r);if(n!==void 0)return n}}function _(e,t){if(!n.missing)return;let r=n.missing(t,e);if(r!==void 0)return r}function v(e,n,r){let i=g(e,n,r);if(i!==void 0)return i;let a=_(e,n);return a===void 0?e.includes(`{`)?(0,t.interpolate)(e,r,n):e:a}function y(e,...n){if(Array.isArray(e)&&`raw`in e)return y((0,t.buildICUMessage)(e,n),Object.fromEntries(n.map((e,t)=>[String(t),e])));let i=e,a=n[0],o=r();if(typeof i==`object`&&i){let e=(0,t.resolveDescriptorId)(i);if(e){let t=g(e,o,a);if(t!==void 0)return t;let n=_(e,o);if(n!==void 0)return n}return i.message===void 0?e??``:(0,t.interpolate)(i.message,a,o)}return v(i,o,a)}return{locale:r,setLocale:async e=>{if(!m||!p.chunkLoader){o(e);return}let t=i();if(l.has(e)){t?.__switchLocale&&await t.__switchLocale(e),o(e);return}c(!0);try{let n=a(await p.chunkLoader(e));f[e]={...f[e],...n},l.add(e),d(new Set(l)),t?.__switchLocale&&await t.__switchLocale(e),o(e)}finally{c(!1)}},t:y,loadMessages:(e,t)=>{f[e]={...f[e],...t},l.add(e),d(new Set(l))},getLocales:()=>Object.keys(f),d:(e,n)=>(0,t.formatDate)(e,r(),n,p.dateFormats),n:(e,n)=>(0,t.formatNumber)(e,r(),n,p.numberFormats),format:(e,n)=>(0,t.interpolate)(e,n,r()),isLoading:s,loadedLocales:u,preloadLocale:e=>{if(!m||l.has(e)||!p.chunkLoader)return;let t=i();p.chunkLoader(e).then(async n=>{let r=a(n);f[e]={...f[e],...r},l.add(e),d(new Set(l)),t?.__preloadLocale&&await t.__preloadLocale(e)}).catch(()=>{})}}}var s;function c(t){let n=(0,e.createRoot)(()=>o(t));return typeof window<`u`||console.warn(`[fluenti] createI18n() detected SSR environment. Use <I18nProvider> for per-request isolation in SSR.`),s=n,n}function l(){return s}var u=(0,e.createContext)(),d=e=>{let t=o(e);return(0,n.createComponent)(u.Provider,{value:t,get children(){return e.children}})};function f(){let t=(0,e.useContext)(u);if(t)return t;let n=l();if(n)return n;throw Error(`useI18n requires either createI18n() to be called at startup, or the component to be inside an <I18nProvider>.`)}var p=((...e)=>{throw Error("[fluenti] `t` imported from '@fluenti/solid' is a compile-time API. Use it only with the Fluenti build transform inside a component or custom hook. For runtime lookups, use useI18n().t(...).")});function m(e){return typeof Node<`u`&&e instanceof Node}function h(e){return typeof e==`function`&&!e.length?e():e}function g(e,t){return t===0?e:e.replace(/<(\d+)(\/?>)/g,(e,n,r)=>`<${Number(n)+t}${r}`).replace(/<\/(\d+)>/g,(e,n)=>`</${Number(n)+t}>`)}function _(e){let t=[],n=``;function r(e){let i=h(e);if(i==null||typeof i==`boolean`)return;if(Array.isArray(i)){for(let e of i)r(e);return}if(typeof i==`string`||typeof i==`number`){n+=String(i);return}if(!m(i))return;if(i.nodeType===Node.TEXT_NODE){n+=i.textContent??``;return}if(i.nodeType===Node.DOCUMENT_FRAGMENT_NODE){r(Array.from(i.childNodes));return}let a=t.length,o=_(Array.from(i.childNodes));t.push(i.cloneNode(!1)),t.push(...o.components),n+=`<${a}>${g(o.message,a+1)}</${a}>`}return r(e),{message:n,components:t}}function v(e,t){let n=h(t);if(!(n==null||typeof n==`boolean`)){if(Array.isArray(n)){for(let t of n)v(e,t);return}if(typeof n==`string`||typeof n==`number`){e.appendChild(document.createTextNode(String(n)));return}m(n)&&e.appendChild(n)}}function y(e,t){let n=/<(\d+)>([\s\S]*?)<\/\1>/g,r=[],i=0,a;for(n.lastIndex=0,a=n.exec(e);a!==null;){a.index>i&&r.push(e.slice(i,a.index));let o=t[Number(a[1])],s=y(a[2],t);if(o){let e=o.cloneNode(!1);v(e,s),r.push(e)}else r.push(a[2]);i=n.lastIndex,a=n.exec(e)}return i<e.length&&r.push(e.slice(i)),r.length<=1?r[0]??``:r}function b(e,t){let n={},r=[];for(let i of e){let e=t[i];if(e===void 0)continue;let a=_(e);n[i]=g(a.message,r.length),r.push(...a.components)}for(let[i,a]of Object.entries(t)){if(e.includes(i)||a===void 0)continue;let t=_(a);n[i]=g(t.message,r.length),r.push(...t.components)}return{messages:n,components:r}}function x(e){return`{value, select, ${Object.entries(e).map(([e,t])=>`${e} {${t}}`).join(` `)}}`}function S(e){let t={},n={},r=0;for(let[i,a]of Object.entries(e)){if(i===`other`){t.other=a;continue}let e=/^[A-Za-z0-9_]+$/.test(i)?i:`case_${r++}`;t[e]=a,n[i]=e}return t.other===void 0&&(t.other=``),{forms:t,valueMap:n}}function C(e){let t=[],n=0;for(;n<e.length;){let r=e.indexOf(`<`,n);if(r===-1){t.push({type:`text`,value:e.slice(n)});break}r>n&&t.push({type:`text`,value:e.slice(n,r)});let i=e.slice(r).match(/^<(\w+)\s*\/>/);if(i){t.push({type:`tag`,name:i[1],children:[]}),n=r+i[0].length;continue}let a=e.slice(r).match(/^<(\w+)>/);if(!a){t.push({type:`text`,value:`<`}),n=r+1;continue}let o=a[1],s=r+a[0].length,c=w(e,o,s);if(c===-1){t.push({type:`text`,value:e.slice(r,s)}),n=s;continue}let l=e.slice(s,c),u=`</${o}>`;t.push({type:`tag`,name:o,children:C(l)}),n=c+u.length}return t}function w(e,t,n){let r=`<${t}>`,i=`</${t}>`,a=1,o=n;for(;o<e.length&&a>0;){let t=e.indexOf(r,o),n=e.indexOf(i,o);if(n===-1)return-1;if(t!==-1&&t<n)a++,o=t+r.length;else{if(a--,a===0)return n;o=n+i.length}}return-1}function T(e,t){let r=e.map(e=>{if(e.type===`text`)return e.value;let r=t[e.name];return r?(0,n.createComponent)(n.Dynamic,{component:r,children:e.children.length>0?T(e.children,t):void 0}):T(e.children,t)});return r.length===1?r[0]:r}var E=t=>{let{t:r}=f(),i=(0,e.children)(()=>t.children),a=(0,e.createMemo)(()=>{let e=t.__message??t.message;return typeof e==`function`?e():e}),o=(0,e.createMemo)(()=>t.__components??t.components);return(()=>{let e=a(),s=o();if(e!==void 0&&s)return T(C(r({...t.id===void 0?{}:{id:t.id},message:e,...t.context===void 0?{}:{context:t.context},...t.comment===void 0?{}:{comment:t.comment}})),s);let c=i.toArray();if(c.length===0)return null;let l=_(c),u=r({...t.id===void 0?{}:{id:t.id},message:l.message,...t.context===void 0?{}:{context:t.context},...t.comment===void 0?{}:{comment:t.comment}}),d=l.components.length>0?y(u,l.components):u;return Array.isArray(d)&&d.length>1?(0,n.createComponent)(n.Dynamic,{get component(){return t.tag??`span`},children:d}):d})},D=[`zero`,`one`,`two`,`few`,`many`,`other`];function O(e,t){let n=[];for(let t of D){let r=e[t];if(r!==void 0){let e=t===`zero`?`=0`:t;n.push(`${e} {${r}}`)}}return`{count, plural, ${t?`offset:${t} `:``}${n.join(` `)}}`}var k=e=>{let{t:r}=f();function i(e){return typeof e==`function`?e():e}return(()=>{let a={};for(let t of D){let n=i(e[t]);n!==void 0&&(a[t]=n)}let{messages:o,components:s}=b(D,a),c=O({...o.zero!==void 0&&{zero:o.zero},...o.one!==void 0&&{one:o.one},...o.two!==void 0&&{two:o.two},...o.few!==void 0&&{few:o.few},...o.many!==void 0&&{many:o.many},other:o.other??``},e.offset),l=r({id:e.id??(e.context===void 0?c:(0,t.hashMessage)(c,e.context)),message:c,...e.context===void 0?{}:{context:e.context},...e.comment===void 0?{}:{comment:e.comment}},{count:e.value});return(0,n.createComponent)(n.Dynamic,{get component(){return e.tag??`span`},get children(){return(0,n.memo)(()=>s.length>0)()?y(l,s):l}})})},A=e=>{let{t:r}=f(),i=()=>e.tag??`span`,a=()=>{let n=e.options===void 0?{...Object.fromEntries(Object.entries(e).filter(([e])=>![`value`,`id`,`context`,`comment`,`options`,`other`,`tag`].includes(e))),other:e.other}:{...e.options,other:e.other},i=[...Object.keys(n).filter(e=>e!==`other`),`other`],{messages:a,components:o}=b(i,n),s=S(Object.fromEntries([...i].map(e=>[e,a[e]??``]))),c=r({id:e.id??(e.context===void 0?x(s.forms):(0,t.hashMessage)(x(s.forms),e.context)),message:x(s.forms),...e.context===void 0?{}:{context:e.context},...e.comment===void 0?{}:{comment:e.comment}},{value:s.valueMap[e.value]??`other`});return o.length>0?y(c,o):c};return(0,n.createComponent)(n.Dynamic,{get component(){return i()},get children(){return a()}})};function j(e){let{d:t}=f();return(0,n.memo)(()=>t(e.value,e.style))}function M(e){let{n:t}=f();return(0,n.memo)(()=>t(e.value,e.style))}exports.DateTime=j,exports.I18nCtx=u,exports.I18nProvider=d,exports.NumberFormat=M,exports.Plural=k,exports.Select=A,exports.Trans=E,exports.createI18n=c,exports.createI18nContext=o,Object.defineProperty(exports,`msg`,{enumerable:!0,get:function(){return t.msg}}),exports.t=p,exports.useI18n=f;
|
|
2
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["createContext","ParentComponent","createI18nContext","I18nConfig","I18nContext","I18nCtx","I18nProvider","props","ctx","_$createComponent","Provider","value","children","JSX","isNodeLike","value","Node","resolveValue","length","offsetIndices","message","offset","replace","_match","index","suffix","Number","extractMessage","components","visit","node","resolved","undefined","Array","isArray","child","String","nodeType","TEXT_NODE","textContent","DOCUMENT_FRAGMENT_NODE","from","childNodes","idx","inner","push","Element","cloneNode","appendChild","parent","entry","document","createTextNode","reconstruct","translated","tagRe","result","lastIndex","match","RegExpExecArray","exec","slice","template","clone","serializeRichForms","keys","T","forms","Partial","Record","messages","key","extracted","Object","entries","includes","buildICUSelectMessage","map","text","join","normalizeSelectForms","valueMap","normalized","safeKey","test","Dynamic","children","resolveChildren","createMemo","Component","JSX","useI18n","extractMessage","extractDomMessage","reconstruct","reconstructDomMessage","RichComponent","Element","TransProps","id","context","comment","tag","message","components","Record","__message","__components","TextToken","type","value","TagToken","name","Token","parseTokens","input","tokens","pos","length","openIdx","indexOf","push","slice","selfCloseMatch","match","openMatch","tagName","contentStart","innerEnd","findClosingTag","innerContent","closingTag","startPos","openTag","closeTag","depth","nextOpen","nextClose","renderTokens","elements","map","token","Comp","undefined","_$createComponent","component","Trans","props","t","resolvedChildren","raw","msg","comps","translated","toArray","extracted","result","Array","isArray","Dynamic","Component","JSX","hashMessage","useI18n","reconstruct","serializeRichForms","PLURAL_CATEGORIES","const","PluralCategory","buildICUPluralMessage","forms","Partial","Record","other","offset","parts","cat","text","undefined","key","push","offsetPrefix","join","PluralProps","value","id","context","comment","zero","Element","one","two","few","many","tag","Plural","props","t","resolveProp","val","resolvedValues","resolved","messages","components","icuMessage","translated","message","count","_$createComponent","component","children","_$memo","length","Component","JSX","Dynamic","hashMessage","useI18n","buildICUSelectMessage","normalizeSelectForms","reconstruct","serializeRichForms","SelectProps","value","id","context","comment","other","Element","options","Record","tag","key","SelectComp","props","t","resolvedTag","content","forms","undefined","Object","fromEntries","entries","filter","includes","orderedKeys","keys","const","messages","components","normalized","map","translated","message","valueMap","length","_$createComponent","component","children","useI18n","DateTimeProps","value","Date","style","DateTime","props","d","_$memo","useI18n","NumberProps","value","style","NumberFormat","props","n","_$memo"],"sources":["../src/context.ts","../src/provider.tsx","../src/use-i18n.ts","../src/compile-time-t.ts","../src/rich-dom.tsx","../src/trans.tsx","../src/plural.tsx","../src/select.tsx","../src/components/DateTime.tsx","../src/components/NumberFormat.tsx"],"sourcesContent":["import { createSignal, createRoot, type Accessor } from 'solid-js'\nimport { formatDate, formatNumber, interpolate as coreInterpolate, buildICUMessage, resolveDescriptorId } from '@fluenti/core'\nimport type { FluentConfig, Locale, Messages, CompiledMessage, MessageDescriptor, DateFormatOptions, NumberFormatOptions } from '@fluenti/core'\n\n/** Chunk loader for lazy locale loading */\nexport type ChunkLoader = (\n locale: string,\n) => Promise<Record<string, CompiledMessage> | { default: Record<string, CompiledMessage> }>\n\ninterface SplitRuntimeModule {\n __switchLocale?: (locale: string) => Promise<void>\n __preloadLocale?: (locale: string) => Promise<void>\n}\n\nconst SPLIT_RUNTIME_KEY = Symbol.for('fluenti.runtime.solid')\n\nfunction getSplitRuntimeModule(): SplitRuntimeModule | null {\n const runtime = (globalThis as Record<PropertyKey, unknown>)[SPLIT_RUNTIME_KEY]\n return typeof runtime === 'object' && runtime !== null\n ? runtime as SplitRuntimeModule\n : null\n}\n\nfunction resolveChunkMessages(\n loaded: Record<string, CompiledMessage> | { default: Record<string, CompiledMessage> },\n): Record<string, CompiledMessage> {\n return typeof loaded === 'object' && loaded !== null && 'default' in loaded\n ? (loaded as { default: Record<string, CompiledMessage> }).default\n : loaded\n}\n\n/** Extended config with lazy locale loading support */\nexport interface I18nConfig extends FluentConfig {\n /** Async chunk loader for lazy locale loading */\n chunkLoader?: ChunkLoader\n /** Enable lazy locale loading through chunkLoader */\n lazyLocaleLoading?: boolean\n /** Locale-specific fallback chains */\n fallbackChain?: Record<string, Locale[]>\n /** Named date format styles */\n dateFormats?: DateFormatOptions\n /** Named number format styles */\n numberFormats?: NumberFormatOptions\n}\n\n/** Reactive i18n context holding locale signal and translation utilities */\nexport interface I18nContext {\n /** Reactive accessor for the current locale */\n locale(): Locale\n /** Set the active locale (async when lazy locale loading is enabled) */\n setLocale(locale: Locale): Promise<void>\n /** Translate a message by id with optional interpolation values */\n t(id: string | MessageDescriptor, values?: Record<string, unknown>): string\n /** Tagged template form: t`Hello ${name}` */\n t(strings: TemplateStringsArray, ...exprs: unknown[]): string\n /** Merge additional messages into a locale catalog at runtime */\n loadMessages(locale: Locale, messages: Messages): void\n /** Return all locale codes that have loaded messages */\n getLocales(): Locale[]\n /** Format a date value for the current locale */\n d(value: Date | number, style?: string): string\n /** Format a number value for the current locale */\n n(value: number, style?: string): string\n /** Format an ICU message string directly (no catalog lookup) */\n format(message: string, values?: Record<string, unknown>): string\n /** Whether a locale chunk is currently being loaded */\n isLoading: Accessor<boolean>\n /** Set of locales whose messages have been loaded */\n loadedLocales: Accessor<Set<string>>\n /** Preload a locale in the background without switching to it */\n preloadLocale(locale: string): void\n}\n\n/**\n * Create a reactive i18n context backed by Solid signals.\n *\n * The returned `t()` reads the internal `locale()` signal, so any\n * Solid computation that calls `t()` will re-run when the locale changes.\n */\nexport function createI18nContext(config: FluentConfig | I18nConfig): I18nContext {\n const [locale, setLocaleSignal] = createSignal<Locale>(config.locale)\n const [isLoading, setIsLoading] = createSignal(false)\n const loadedLocalesSet = new Set<string>([config.locale])\n const [loadedLocales, setLoadedLocales] = createSignal(new Set(loadedLocalesSet))\n const messages: Record<string, Messages> = { ...config.messages }\n const i18nConfig = config as I18nConfig\n const lazyLocaleLoading = i18nConfig.lazyLocaleLoading\n ?? (config as I18nConfig & { splitting?: boolean }).splitting\n ?? false\n\n function lookupCatalog(\n id: string,\n loc: Locale,\n values?: Record<string, unknown>,\n ): string | undefined {\n const catalog = messages[loc]\n if (!catalog) {\n return undefined\n }\n\n const msg = catalog[id]\n if (msg === undefined) {\n return undefined\n }\n\n if (typeof msg === 'function') {\n return msg(values)\n }\n\n if (typeof msg === 'string' && values) {\n return coreInterpolate(msg, values, loc)\n }\n\n return String(msg)\n }\n\n function lookupWithFallbacks(\n id: string,\n loc: Locale,\n values?: Record<string, unknown>,\n ): string | undefined {\n const localesToTry: Locale[] = [loc]\n const seen = new Set(localesToTry)\n\n if (config.fallbackLocale && !seen.has(config.fallbackLocale)) {\n localesToTry.push(config.fallbackLocale)\n seen.add(config.fallbackLocale)\n }\n\n const chainLocales = i18nConfig.fallbackChain?.[loc] ?? i18nConfig.fallbackChain?.['*']\n if (chainLocales) {\n for (const chainLocale of chainLocales) {\n if (!seen.has(chainLocale)) {\n localesToTry.push(chainLocale)\n seen.add(chainLocale)\n }\n }\n }\n\n for (const targetLocale of localesToTry) {\n const result = lookupCatalog(id, targetLocale, values)\n if (result !== undefined) {\n return result\n }\n }\n\n return undefined\n }\n\n function resolveMissing(\n id: string,\n loc: Locale,\n ): string | undefined {\n if (!config.missing) {\n return undefined\n }\n\n const result = config.missing(loc, id)\n if (result !== undefined) {\n return result\n }\n return undefined\n }\n\n function resolveMessage(\n id: string,\n loc: Locale,\n values?: Record<string, unknown>,\n ): string {\n const catalogResult = lookupWithFallbacks(id, loc, values)\n if (catalogResult !== undefined) {\n return catalogResult\n }\n\n const missingResult = resolveMissing(id, loc)\n if (missingResult !== undefined) {\n return missingResult\n }\n\n if (id.includes('{')) {\n return coreInterpolate(id, values, loc)\n }\n\n return id\n }\n\n function t(strings: TemplateStringsArray, ...exprs: unknown[]): string\n function t(id: string | MessageDescriptor, values?: Record<string, unknown>): string\n function t(idOrStrings: string | MessageDescriptor | TemplateStringsArray, ...rest: unknown[]): string {\n // Tagged template form: t`Hello ${name}`\n if (Array.isArray(idOrStrings) && 'raw' in idOrStrings) {\n const strings = idOrStrings as TemplateStringsArray\n const icu = buildICUMessage(strings, rest)\n const values = Object.fromEntries(rest.map((v, i) => [String(i), v]))\n return t(icu, values)\n }\n\n const id = idOrStrings as string | MessageDescriptor\n const values = rest[0] as Record<string, unknown> | undefined\n const currentLocale = locale() // reactive dependency\n if (typeof id === 'object' && id !== null) {\n const messageId = resolveDescriptorId(id)\n if (messageId) {\n const catalogResult = lookupWithFallbacks(messageId, currentLocale, values)\n if (catalogResult !== undefined) {\n return catalogResult\n }\n\n const missingResult = resolveMissing(messageId, currentLocale)\n if (missingResult !== undefined) {\n return missingResult\n }\n }\n\n if (id.message !== undefined) {\n return coreInterpolate(id.message, values, currentLocale)\n }\n\n return messageId ?? ''\n }\n\n return resolveMessage(id, currentLocale, values)\n }\n\n const loadMessages = (loc: Locale, msgs: Messages): void => {\n messages[loc] = { ...messages[loc], ...msgs }\n loadedLocalesSet.add(loc)\n setLoadedLocales(new Set(loadedLocalesSet))\n }\n\n const setLocale = async (newLocale: Locale): Promise<void> => {\n if (!lazyLocaleLoading || !i18nConfig.chunkLoader) {\n setLocaleSignal(newLocale)\n return\n }\n\n const splitRuntime = getSplitRuntimeModule()\n\n if (loadedLocalesSet.has(newLocale)) {\n if (splitRuntime?.__switchLocale) {\n await splitRuntime.__switchLocale(newLocale)\n }\n setLocaleSignal(newLocale)\n return\n }\n\n setIsLoading(true)\n try {\n const loaded = resolveChunkMessages(await i18nConfig.chunkLoader(newLocale))\n messages[newLocale] = { ...messages[newLocale], ...loaded }\n loadedLocalesSet.add(newLocale)\n setLoadedLocales(new Set(loadedLocalesSet))\n if (splitRuntime?.__switchLocale) {\n await splitRuntime.__switchLocale(newLocale)\n }\n setLocaleSignal(newLocale)\n } finally {\n setIsLoading(false)\n }\n }\n\n const preloadLocale = (loc: string): void => {\n if (!lazyLocaleLoading || loadedLocalesSet.has(loc) || !i18nConfig.chunkLoader) return\n const splitRuntime = getSplitRuntimeModule()\n i18nConfig.chunkLoader(loc).then(async (loaded) => {\n const resolved = resolveChunkMessages(loaded)\n messages[loc] = { ...messages[loc], ...resolved }\n loadedLocalesSet.add(loc)\n setLoadedLocales(new Set(loadedLocalesSet))\n if (splitRuntime?.__preloadLocale) {\n await splitRuntime.__preloadLocale(loc)\n }\n }).catch(() => {\n // Silent failure for preload\n })\n }\n\n const getLocales = (): Locale[] => Object.keys(messages)\n\n const d = (value: Date | number, style?: string): string =>\n formatDate(value, locale(), style, i18nConfig.dateFormats)\n\n const n = (value: number, style?: string): string =>\n formatNumber(value, locale(), style, i18nConfig.numberFormats)\n\n const format = (message: string, values?: Record<string, unknown>): string => {\n return coreInterpolate(message, values, locale())\n }\n\n return { locale, setLocale, t, loadMessages, getLocales, d, n, format, isLoading, loadedLocales, preloadLocale }\n}\n\n// ─── Module-level singleton ─────────────────────────────────────────────────\n\nlet globalCtx: I18nContext | undefined\n\n/**\n * Initialize the global i18n singleton.\n *\n * Call once at app startup (e.g. in your entry file) before any `useI18n()`.\n * Signals are created inside a `createRoot` so they outlive any component scope.\n *\n * Returns the context for convenience, but `useI18n()` will also find it.\n */\nexport function createI18n(config: FluentConfig | I18nConfig): I18nContext {\n const ctx = createRoot(() => createI18nContext(config))\n\n // Only set global singleton in browser (client-side).\n // In SSR, each request should use <I18nProvider> for per-request isolation.\n if (typeof window !== 'undefined') {\n globalCtx = ctx\n } else {\n console.warn(\n '[fluenti] createI18n() detected SSR environment. ' +\n 'Use <I18nProvider> for per-request isolation in SSR.',\n )\n // Still set globalCtx as fallback, but document the risk\n globalCtx = ctx\n }\n\n return ctx\n}\n\n/** @internal — used by useI18n and I18nProvider */\nexport function getGlobalI18nContext(): I18nContext | undefined {\n return globalCtx\n}\n\n/** @internal — used by I18nProvider to set context without createRoot wrapper */\nexport function setGlobalI18nContext(ctx: I18nContext): void {\n globalCtx = ctx\n}\n\n/** @internal — reset the global singleton (for testing only) */\nexport function resetGlobalI18nContext(): void {\n globalCtx = undefined\n}\n","import { createContext } from 'solid-js'\nimport type { ParentComponent } from 'solid-js'\nimport { createI18nContext } from './context'\nimport type { I18nConfig, I18nContext } from './context'\n\n/** Solid context object for i18n — used internally by useI18n() */\nexport const I18nCtx = createContext<I18nContext>()\n\n/**\n * Provide i18n context to the component tree.\n *\n */\nexport const I18nProvider: ParentComponent<I18nConfig> = (props) => {\n const ctx = createI18nContext(props)\n return <I18nCtx.Provider value={ctx}>{props.children}</I18nCtx.Provider>\n}\n","import { useContext } from 'solid-js'\nimport { I18nCtx } from './provider'\nimport { getGlobalI18nContext } from './context'\nimport type { I18nContext } from './context'\n\n/**\n * Access the i18n context.\n *\n * Resolution order:\n * 1. Nearest `<I18nProvider>` in the component tree\n * 2. Module-level singleton created by `createI18n()`\n *\n * Throws if neither is available.\n */\nexport function useI18n(): I18nContext {\n const ctx = useContext(I18nCtx)\n if (ctx) {\n return ctx\n }\n\n const global = getGlobalI18nContext()\n if (global) {\n return global\n }\n\n throw new Error(\n 'useI18n requires either createI18n() to be called at startup, ' +\n 'or the component to be inside an <I18nProvider>.',\n )\n}\n","import type { CompileTimeT } from '@fluenti/core'\n\nexport const t: CompileTimeT = ((..._args: unknown[]) => {\n throw new Error(\n \"[fluenti] `t` imported from '@fluenti/solid' is a compile-time API. \" +\n 'Use it only with the Fluenti build transform inside a component or custom hook. ' +\n 'For runtime lookups, use useI18n().t(...).',\n )\n}) as CompileTimeT\n","import type { JSX } from 'solid-js'\n\nfunction isNodeLike(value: unknown): value is Node {\n return typeof Node !== 'undefined' && value instanceof Node\n}\n\nfunction resolveValue(value: unknown): unknown {\n if (typeof value === 'function' && !(value as { length?: number }).length) {\n return (value as () => unknown)()\n }\n return value\n}\n\nexport function offsetIndices(message: string, offset: number): string {\n if (offset === 0) return message\n return message\n .replace(/<(\\d+)(\\/?>)/g, (_match, index: string, suffix: string) => `<${Number(index) + offset}${suffix}`)\n .replace(/<\\/(\\d+)>/g, (_match, index: string) => `</${Number(index) + offset}>`)\n}\n\nexport function extractMessage(value: unknown): {\n message: string\n components: Node[]\n} {\n const components: Node[] = []\n let message = ''\n\n function visit(node: unknown): void {\n const resolved = resolveValue(node)\n if (resolved === null || resolved === undefined || typeof resolved === 'boolean') return\n if (Array.isArray(resolved)) {\n for (const child of resolved) visit(child)\n return\n }\n if (typeof resolved === 'string' || typeof resolved === 'number') {\n message += String(resolved)\n return\n }\n if (!isNodeLike(resolved)) return\n if (resolved.nodeType === Node.TEXT_NODE) {\n message += resolved.textContent ?? ''\n return\n }\n if (resolved.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {\n visit(Array.from(resolved.childNodes))\n return\n }\n\n const idx = components.length\n const inner = extractMessage(Array.from(resolved.childNodes))\n components.push((resolved as Element).cloneNode(false))\n components.push(...inner.components)\n message += `<${idx}>${offsetIndices(inner.message, idx + 1)}</${idx}>`\n }\n\n visit(value)\n return { message, components }\n}\n\nfunction appendChild(parent: Node, child: unknown): void {\n const resolved = resolveValue(child)\n if (resolved === null || resolved === undefined || typeof resolved === 'boolean') return\n if (Array.isArray(resolved)) {\n for (const entry of resolved) appendChild(parent, entry)\n return\n }\n if (typeof resolved === 'string' || typeof resolved === 'number') {\n parent.appendChild(document.createTextNode(String(resolved)))\n return\n }\n if (isNodeLike(resolved)) {\n parent.appendChild(resolved)\n }\n}\n\nexport function reconstruct(\n translated: string,\n components: Node[],\n): JSX.Element {\n const tagRe = /<(\\d+)>([\\s\\S]*?)<\\/\\1>/g\n const result: unknown[] = []\n let lastIndex = 0\n let match: RegExpExecArray | null\n\n tagRe.lastIndex = 0\n match = tagRe.exec(translated)\n while (match !== null) {\n if (match.index > lastIndex) {\n result.push(translated.slice(lastIndex, match.index))\n }\n\n const idx = Number(match[1])\n const template = components[idx]\n const inner = reconstruct(match[2]!, components)\n if (template) {\n const clone = template.cloneNode(false)\n appendChild(clone, inner)\n result.push(clone)\n } else {\n result.push(match[2]!)\n }\n\n lastIndex = tagRe.lastIndex\n match = tagRe.exec(translated)\n }\n\n if (lastIndex < translated.length) {\n result.push(translated.slice(lastIndex))\n }\n\n return (result.length <= 1 ? result[0] ?? '' : result) as JSX.Element\n}\n\nexport function serializeRichForms<T extends string>(\n keys: readonly T[],\n forms: Partial<Record<T, unknown>> & Record<string, unknown>,\n): {\n messages: Record<string, string>\n components: Node[]\n} {\n const messages: Record<string, string> = {}\n const components: Node[] = []\n\n for (const key of keys) {\n const value = forms[key]\n if (value === undefined) continue\n const extracted = extractMessage(value)\n messages[key] = offsetIndices(extracted.message, components.length)\n components.push(...extracted.components)\n }\n\n for (const [key, value] of Object.entries(forms)) {\n if (keys.includes(key as T) || value === undefined) continue\n const extracted = extractMessage(value)\n messages[key] = offsetIndices(extracted.message, components.length)\n components.push(...extracted.components)\n }\n\n return { messages, components }\n}\n\nexport function buildICUSelectMessage(forms: Record<string, string>): string {\n return `{value, select, ${Object.entries(forms).map(([key, text]) => `${key} {${text}}`).join(' ')}}`\n}\n\nexport function normalizeSelectForms(forms: Record<string, string>): {\n forms: Record<string, string>\n valueMap: Record<string, string>\n} {\n const normalized: Record<string, string> = {}\n const valueMap: Record<string, string> = {}\n let index = 0\n\n for (const [key, text] of Object.entries(forms)) {\n if (key === 'other') {\n normalized['other'] = text\n continue\n }\n\n const safeKey = /^[A-Za-z0-9_]+$/.test(key) ? key : `case_${index++}`\n normalized[safeKey] = text\n valueMap[key] = safeKey\n }\n\n if (normalized['other'] === undefined) {\n normalized['other'] = ''\n }\n\n return { forms: normalized, valueMap }\n}\n","import { Dynamic } from 'solid-js/web'\nimport { children as resolveChildren, createMemo } from 'solid-js'\nimport type { Component, JSX } from 'solid-js'\nimport { useI18n } from './use-i18n'\nimport { extractMessage as extractDomMessage, reconstruct as reconstructDomMessage } from './rich-dom'\n\n/** A Solid component that accepts children */\nexport type RichComponent = Component<{ children?: JSX.Element }>\n\n/** Props for the `<Trans>` component */\nexport interface TransProps {\n /** Override auto-generated hash ID */\n id?: string\n /** Message context used for identity and translator disambiguation */\n context?: string\n /** Translator-facing note preserved in extraction catalogs */\n comment?: string\n /** Wrapper element tag name (default: `'span'`) — used in children-only mode */\n tag?: string\n /** Children — the content to translate (legacy API) */\n children?: JSX.Element\n /** Translated message string with XML-like tags (e.g. `<bold>text</bold>`) */\n message?: string\n /** Map of tag names to Solid components */\n components?: Record<string, RichComponent>\n /** @internal Pre-computed message from build plugin */\n __message?: string\n /** @internal Pre-computed component map from build plugin */\n __components?: Record<string, RichComponent>\n}\n\n/**\n * A token from parsing the message string.\n * Either a plain text segment or a tag with inner content.\n */\ninterface TextToken {\n readonly type: 'text'\n readonly value: string\n}\n\ninterface TagToken {\n readonly type: 'tag'\n readonly name: string\n readonly children: readonly Token[]\n}\n\ntype Token = TextToken | TagToken\n\n/**\n * Parse a message string containing XML-like tags into a token tree.\n *\n * Supports:\n * - Named tags: `<bold>content</bold>`\n * - Self-closing tags: `<br/>`\n * - Nested tags: `<bold>hello <italic>world</italic></bold>`\n */\nfunction parseTokens(input: string): readonly Token[] {\n const tokens: Token[] = []\n let pos = 0\n\n while (pos < input.length) {\n const openIdx = input.indexOf('<', pos)\n\n if (openIdx === -1) {\n // No more tags — rest is plain text\n tokens.push({ type: 'text', value: input.slice(pos) })\n break\n }\n\n // Push any text before this tag\n if (openIdx > pos) {\n tokens.push({ type: 'text', value: input.slice(pos, openIdx) })\n }\n\n // Check for self-closing tag: <tagName/>\n const selfCloseMatch = input.slice(openIdx).match(/^<(\\w+)\\s*\\/>/)\n if (selfCloseMatch) {\n tokens.push({ type: 'tag', name: selfCloseMatch[1]!, children: [] })\n pos = openIdx + selfCloseMatch[0].length\n continue\n }\n\n // Check for opening tag: <tagName>\n const openMatch = input.slice(openIdx).match(/^<(\\w+)>/)\n if (!openMatch) {\n // Not a valid tag — treat '<' as text\n tokens.push({ type: 'text', value: '<' })\n pos = openIdx + 1\n continue\n }\n\n const tagName = openMatch[1]!\n const contentStart = openIdx + openMatch[0].length\n\n // Find the matching closing tag, respecting nesting\n const innerEnd = findClosingTag(input, tagName, contentStart)\n if (innerEnd === -1) {\n // No closing tag found — treat as plain text\n tokens.push({ type: 'text', value: input.slice(openIdx, contentStart) })\n pos = contentStart\n continue\n }\n\n const innerContent = input.slice(contentStart, innerEnd)\n const closingTag = `</${tagName}>`\n tokens.push({\n type: 'tag',\n name: tagName,\n children: parseTokens(innerContent),\n })\n pos = innerEnd + closingTag.length\n }\n\n return tokens\n}\n\n/**\n * Find the position of the matching closing tag, accounting for nesting\n * of the same tag name.\n *\n * Returns the index of the start of the closing tag, or -1 if not found.\n */\nfunction findClosingTag(input: string, tagName: string, startPos: number): number {\n const openTag = `<${tagName}>`\n const closeTag = `</${tagName}>`\n let depth = 1\n let pos = startPos\n\n while (pos < input.length && depth > 0) {\n const nextOpen = input.indexOf(openTag, pos)\n const nextClose = input.indexOf(closeTag, pos)\n\n if (nextClose === -1) return -1\n\n if (nextOpen !== -1 && nextOpen < nextClose) {\n depth++\n pos = nextOpen + openTag.length\n } else {\n depth--\n if (depth === 0) return nextClose\n pos = nextClose + closeTag.length\n }\n }\n\n return -1\n}\n\n/**\n * Render a token tree into Solid JSX elements using the components map.\n */\nfunction renderTokens(\n tokens: readonly Token[],\n components: Record<string, RichComponent>,\n): JSX.Element {\n const elements = tokens.map((token): JSX.Element => {\n if (token.type === 'text') {\n return token.value as unknown as JSX.Element\n }\n\n const Comp = components[token.name]\n if (!Comp) {\n // Unknown component — render inner content as plain text\n return renderTokens(token.children, components)\n }\n\n const innerContent = token.children.length > 0\n ? renderTokens(token.children, components)\n : undefined\n\n return (<Dynamic component={Comp}>{innerContent}</Dynamic>) as JSX.Element\n })\n\n if (elements.length === 1) return elements[0]!\n return (<>{elements}</>) as JSX.Element\n}\n\n/**\n * Render translated content with inline components.\n *\n * Supports two APIs:\n *\n * 1. **message + components** (recommended for rich text):\n * ```tsx\n * <Trans\n * message={t`Welcome to <bold>Fluenti</bold>!`}\n * components={{ bold: (props) => <strong>{props.children}</strong> }}\n * />\n * ```\n *\n * 2. **children** (legacy / simple passthrough):\n * ```tsx\n * <Trans>Click <a href=\"/next\">here</a> to continue</Trans>\n * ```\n */\nexport const Trans: Component<TransProps> = (props) => {\n const { t } = useI18n()\n const resolvedChildren = resolveChildren(() => props.children)\n // message + components API (including build-time __message/__components)\n // Note: the vite-plugin tagged-template transform wraps Solid expressions in\n // createMemo(), so props.message may be a memo accessor (function) instead of\n // a string. We unwrap it here to handle both cases.\n const message = createMemo(() => {\n const raw = props.__message ?? props.message\n return typeof raw === 'function' ? (raw as () => string)() : raw\n })\n const components = createMemo(() => props.__components ?? props.components)\n\n return (() => {\n const msg = message()\n const comps = components()\n\n if (msg !== undefined && comps) {\n const translated = t({\n ...(props.id !== undefined ? { id: props.id } : {}),\n message: msg,\n ...(props.context !== undefined ? { context: props.context } : {}),\n ...(props.comment !== undefined ? { comment: props.comment } : {}),\n })\n const tokens = parseTokens(translated)\n return renderTokens(tokens, comps)\n }\n\n // Fallback: children-only API with runtime extraction/reconstruction\n const children = resolvedChildren.toArray()\n if (children.length === 0) return null\n const extracted = extractDomMessage(children)\n const translated = t({\n ...(props.id !== undefined ? { id: props.id } : {}),\n message: extracted.message,\n ...(props.context !== undefined ? { context: props.context } : {}),\n ...(props.comment !== undefined ? { comment: props.comment } : {}),\n })\n const result = extracted.components.length > 0\n ? reconstructDomMessage(translated, extracted.components)\n : translated\n\n if (Array.isArray(result) && result.length > 1) {\n return (<Dynamic component={props.tag ?? 'span'}>{result}</Dynamic>) as JSX.Element\n }\n\n return result as JSX.Element\n }) as unknown as JSX.Element\n}\n","import { Dynamic } from 'solid-js/web'\nimport type { Component, JSX } from 'solid-js'\nimport { hashMessage } from '@fluenti/core'\nimport { useI18n } from './use-i18n'\nimport { reconstruct, serializeRichForms } from './rich-dom'\n\n/** Plural category names in a stable order for ICU message building. */\nconst PLURAL_CATEGORIES = ['zero', 'one', 'two', 'few', 'many', 'other'] as const\n\ntype PluralCategory = (typeof PLURAL_CATEGORIES)[number]\n\n/**\n * Build an ICU plural message string from individual category props.\n *\n * Given `{ zero: \"No items\", one: \"# item\", other: \"# items\" }`,\n * produces `\"{count, plural, =0 {No items} one {# item} other {# items}}\"`.\n *\n * @internal\n */\nfunction buildICUPluralMessage(\n forms: Partial<Record<PluralCategory, string>> & { other: string },\n offset?: number,\n): string {\n const parts: string[] = []\n for (const cat of PLURAL_CATEGORIES) {\n const text = forms[cat]\n if (text !== undefined) {\n // Map the `zero` prop to ICU `=0` exact match. In ICU MessageFormat,\n // `zero` is a CLDR plural category that only activates in languages\n // with a grammatical zero form (e.g. Arabic). The `=0` exact match\n // works universally for the common \"show this when count is 0\" intent.\n const key = cat === 'zero' ? '=0' : cat\n parts.push(`${key} {${text}}`)\n }\n }\n const offsetPrefix = offset ? `offset:${offset} ` : ''\n return `{count, plural, ${offsetPrefix}${parts.join(' ')}}`\n}\n\n/** Props for the `<Plural>` component */\nexport interface PluralProps {\n /** The numeric value to pluralise */\n value: number\n /** Override the auto-generated synthetic ICU message id */\n id?: string\n /** Message context used for identity and translator disambiguation */\n context?: string\n /** Translator-facing note preserved in extraction catalogs */\n comment?: string\n /** Offset from value before selecting form */\n offset?: number\n /** Message for the \"zero\" plural category */\n zero?: string | JSX.Element\n /** Message for the \"one\" plural category */\n one?: string | JSX.Element\n /** Message for the \"two\" plural category */\n two?: string | JSX.Element\n /** Message for the \"few\" plural category */\n few?: string | JSX.Element\n /** Message for the \"many\" plural category */\n many?: string | JSX.Element\n /** Fallback message when no category-specific prop matches */\n other: string | JSX.Element\n /** Wrapper element tag name (default: `'span'`) */\n tag?: string\n}\n\n/**\n * `<Plural>` component — shorthand for ICU plural patterns.\n *\n * Plural form props (`zero`, `one`, `two`, `few`, `many`, `other`) are treated\n * as source-language messages. The component builds an ICU plural message,\n * looks it up via `t()` in the catalog, and interpolates the translated result.\n *\n * When no catalog translation exists, the component falls back to interpolating\n * the source-language ICU message directly via core's `interpolate`.\n *\n * Rich text is supported via JSX element props:\n * ```tsx\n * <Plural\n * value={count()}\n * zero={<>No <strong>items</strong> left</>}\n * one={<><em>1</em> item remaining</>}\n * other={<><strong>{count()}</strong> items remaining</>}\n * />\n * ```\n *\n * String props still work (backward compatible):\n * ```tsx\n * <Plural value={count()} zero=\"No items\" one=\"# item\" other=\"# items\" />\n * ```\n */\nexport const Plural: Component<PluralProps> = (props) => {\n const { t } = useI18n()\n\n /** Resolve a category prop value — handles string, accessor function, and JSX */\n function resolveProp(val: string | JSX.Element | undefined): string | JSX.Element | undefined {\n if (typeof val === 'function') return (val as () => string | JSX.Element)()\n return val\n }\n\n return (() => {\n // Resolve all category values (handles Solid accessors from createMemo)\n const resolvedValues: Partial<Record<PluralCategory, string | JSX.Element>> = {}\n for (const cat of PLURAL_CATEGORIES) {\n const resolved = resolveProp(props[cat])\n if (resolved !== undefined) {\n resolvedValues[cat] = resolved\n }\n }\n const { messages, components } = serializeRichForms(PLURAL_CATEGORIES, resolvedValues)\n const icuMessage = buildICUPluralMessage(\n {\n ...(messages['zero'] !== undefined && { zero: messages['zero'] }),\n ...(messages['one'] !== undefined && { one: messages['one'] }),\n ...(messages['two'] !== undefined && { two: messages['two'] }),\n ...(messages['few'] !== undefined && { few: messages['few'] }),\n ...(messages['many'] !== undefined && { many: messages['many'] }),\n other: messages['other'] ?? '',\n },\n props.offset,\n )\n\n const translated = t(\n {\n id: props.id ?? (props.context === undefined ? icuMessage : hashMessage(icuMessage, props.context)),\n message: icuMessage,\n ...(props.context !== undefined ? { context: props.context } : {}),\n ...(props.comment !== undefined ? { comment: props.comment } : {}),\n },\n { count: props.value },\n )\n\n return (<Dynamic component={props.tag ?? 'span'}>{components.length > 0 ? reconstruct(translated, components) : translated}</Dynamic>) as JSX.Element\n }) as unknown as JSX.Element\n}\n","import type { Component, JSX } from 'solid-js'\nimport { Dynamic } from 'solid-js/web'\nimport { hashMessage } from '@fluenti/core'\nimport { useI18n } from './use-i18n'\nimport { buildICUSelectMessage, normalizeSelectForms, reconstruct, serializeRichForms } from './rich-dom'\n\n/** Props for the `<Select>` component */\nexport interface SelectProps {\n /** The value to match against prop keys */\n value: string\n /** Override the auto-generated synthetic ICU message id */\n id?: string\n /** Message context used for identity and translator disambiguation */\n context?: string\n /** Translator-facing note preserved in extraction catalogs */\n comment?: string\n /** Fallback message when no key matches */\n other: string | JSX.Element\n /**\n * Named options map. Keys are match values, values are display strings or JSX.\n * Takes precedence over dynamic attrs when both are provided.\n *\n * @example `{ male: 'He', female: 'She' }`\n */\n options?: Record<string, string | JSX.Element>\n /** Wrapper element tag name (default: `span`) */\n tag?: string\n /** Additional key/message pairs for matching (attrs fallback) */\n [key: string]: unknown\n}\n\n/**\n * Render a message selected by matching `value` against prop keys.\n *\n * Options can be provided via the type-safe `options` prop (recommended)\n * or as direct attrs (convenience). When both are present, `options` takes\n * precedence.\n *\n * Rich text is supported via JSX element values in the `options` prop or\n * as direct JSX element props:\n * ```tsx\n * <Select\n * value={gender()}\n * options={{\n * male: <><strong>He</strong> liked this</>,\n * female: <><strong>She</strong> liked this</>,\n * }}\n * other={<><em>They</em> liked this</>}\n * />\n * ```\n *\n * Falls back to the `other` prop when no key matches.\n */\nexport const SelectComp: Component<SelectProps> = (props) => {\n const { t } = useI18n()\n\n const resolvedTag = () => props.tag ?? 'span'\n\n const content = () => {\n const forms: Record<string, unknown> = props.options !== undefined\n ? { ...props.options, other: props.other }\n : {\n ...Object.fromEntries(\n Object.entries(props).filter(([key]) => !['value', 'id', 'context', 'comment', 'options', 'other', 'tag'].includes(key)),\n ),\n other: props.other,\n }\n\n const orderedKeys = [...Object.keys(forms).filter(key => key !== 'other'), 'other'] as const\n const { messages, components } = serializeRichForms(orderedKeys, forms)\n const normalized = normalizeSelectForms(\n Object.fromEntries([...orderedKeys].map((key) => [key, messages[key] ?? ''])),\n )\n const translated = t(\n {\n id: props.id ?? (props.context === undefined\n ? buildICUSelectMessage(normalized.forms)\n : hashMessage(buildICUSelectMessage(normalized.forms), props.context)),\n message: buildICUSelectMessage(normalized.forms),\n ...(props.context !== undefined ? { context: props.context } : {}),\n ...(props.comment !== undefined ? { comment: props.comment } : {}),\n },\n { value: normalized.valueMap[props.value] ?? 'other' },\n )\n\n return components.length > 0 ? reconstruct(translated, components) : translated\n }\n\n return (<Dynamic component={resolvedTag()}>{content()}</Dynamic>) as JSX.Element\n}\n","import { useI18n } from '../use-i18n'\n\nexport interface DateTimeProps {\n /** Date value to format */\n value: Date | number\n /** Named format style */\n style?: string\n}\n\n/**\n * `<DateTime>` — date formatting component using Intl APIs.\n *\n * @example\n * ```tsx\n * <DateTime value={new Date()} style=\"long\" />\n * ```\n */\nexport function DateTime(props: DateTimeProps) {\n const { d } = useI18n()\n return <>{d(props.value, props.style)}</>\n}\n","import { useI18n } from '../use-i18n'\n\nexport interface NumberProps {\n /** Number value to format */\n value: number\n /** Named format style */\n style?: string\n}\n\n/**\n * `<NumberFormat>` — number formatting component using Intl APIs.\n *\n * @example\n * ```tsx\n * <NumberFormat value={1234.56} style=\"currency\" />\n * ```\n */\nexport function NumberFormat(props: NumberProps) {\n const { n } = useI18n()\n return <>{n(props.value, props.style)}</>\n}\n"],"mappings":"kJAcA,IAAM,EAAoB,OAAO,IAAI,wBAAwB,CAE7D,SAAS,GAAmD,CAC1D,IAAM,EAAW,WAA4C,GAC7D,OAAO,OAAO,GAAY,UAAY,EAClC,EACA,KAGN,SAAS,EACP,EACiC,CACjC,OAAO,OAAO,GAAW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