@vielzeug/codex 2.0.0 → 2.0.1
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/data/catalog.json +25 -24
- package/data/llms-full.txt +82 -21
- package/data/llms.txt +1 -1
- package/data/manifest.json +1 -1
- package/data/packages/lingua.json +30 -28
- package/data/packages/vault.json +1 -1
- package/data/refine.json +4762 -4762
- package/data/search.json +8 -8
- package/package.json +1 -1
package/data/catalog.json
CHANGED
|
@@ -73,7 +73,7 @@
|
|
|
73
73
|
"coins"
|
|
74
74
|
],
|
|
75
75
|
"slug": "arsenal",
|
|
76
|
-
"version": "
|
|
76
|
+
"version": "2.0.0"
|
|
77
77
|
},
|
|
78
78
|
{
|
|
79
79
|
"availableDocPages": [
|
|
@@ -124,7 +124,7 @@
|
|
|
124
124
|
"refine"
|
|
125
125
|
],
|
|
126
126
|
"slug": "assay",
|
|
127
|
-
"version": "
|
|
127
|
+
"version": "2.0.0"
|
|
128
128
|
},
|
|
129
129
|
{
|
|
130
130
|
"availableDocPages": [
|
|
@@ -167,7 +167,7 @@
|
|
|
167
167
|
"ward"
|
|
168
168
|
],
|
|
169
169
|
"slug": "clockwork",
|
|
170
|
-
"version": "
|
|
170
|
+
"version": "2.0.0"
|
|
171
171
|
},
|
|
172
172
|
{
|
|
173
173
|
"availableDocPages": [
|
|
@@ -196,7 +196,7 @@
|
|
|
196
196
|
"refine"
|
|
197
197
|
],
|
|
198
198
|
"slug": "codex",
|
|
199
|
-
"version": "
|
|
199
|
+
"version": "2.0.0"
|
|
200
200
|
},
|
|
201
201
|
{
|
|
202
202
|
"availableDocPages": [
|
|
@@ -242,7 +242,7 @@
|
|
|
242
242
|
"spell"
|
|
243
243
|
],
|
|
244
244
|
"slug": "coins",
|
|
245
|
-
"version": "
|
|
245
|
+
"version": "2.0.0"
|
|
246
246
|
},
|
|
247
247
|
{
|
|
248
248
|
"availableDocPages": [
|
|
@@ -281,7 +281,7 @@
|
|
|
281
281
|
"rune"
|
|
282
282
|
],
|
|
283
283
|
"slug": "conduit",
|
|
284
|
-
"version": "
|
|
284
|
+
"version": "2.0.0"
|
|
285
285
|
},
|
|
286
286
|
{
|
|
287
287
|
"availableDocPages": [
|
|
@@ -327,7 +327,7 @@
|
|
|
327
327
|
"spell"
|
|
328
328
|
],
|
|
329
329
|
"slug": "courier",
|
|
330
|
-
"version": "
|
|
330
|
+
"version": "2.0.0"
|
|
331
331
|
},
|
|
332
332
|
{
|
|
333
333
|
"availableDocPages": [
|
|
@@ -417,7 +417,7 @@
|
|
|
417
417
|
"herald"
|
|
418
418
|
],
|
|
419
419
|
"slug": "familiar",
|
|
420
|
-
"version": "1.0.
|
|
420
|
+
"version": "1.0.7"
|
|
421
421
|
},
|
|
422
422
|
{
|
|
423
423
|
"availableDocPages": [
|
|
@@ -481,7 +481,7 @@
|
|
|
481
481
|
"courier"
|
|
482
482
|
],
|
|
483
483
|
"slug": "flux",
|
|
484
|
-
"version": "
|
|
484
|
+
"version": "2.0.0"
|
|
485
485
|
},
|
|
486
486
|
{
|
|
487
487
|
"availableDocPages": [
|
|
@@ -527,7 +527,7 @@
|
|
|
527
527
|
"courier"
|
|
528
528
|
],
|
|
529
529
|
"slug": "forge",
|
|
530
|
-
"version": "
|
|
530
|
+
"version": "2.0.0"
|
|
531
531
|
},
|
|
532
532
|
{
|
|
533
533
|
"availableDocPages": [
|
|
@@ -674,7 +674,7 @@
|
|
|
674
674
|
"vault"
|
|
675
675
|
],
|
|
676
676
|
"slug": "ledger",
|
|
677
|
-
"version": "
|
|
677
|
+
"version": "2.0.0"
|
|
678
678
|
},
|
|
679
679
|
{
|
|
680
680
|
"availableDocPages": [
|
|
@@ -692,6 +692,7 @@
|
|
|
692
692
|
"store"
|
|
693
693
|
],
|
|
694
694
|
"exports": [
|
|
695
|
+
"createCatalogTranslator",
|
|
695
696
|
"createTranslationStore",
|
|
696
697
|
"createTranslator",
|
|
697
698
|
"hydrateTranslationStore",
|
|
@@ -719,7 +720,7 @@
|
|
|
719
720
|
"courier"
|
|
720
721
|
],
|
|
721
722
|
"slug": "lingua",
|
|
722
|
-
"version": "
|
|
723
|
+
"version": "2.0.0"
|
|
723
724
|
},
|
|
724
725
|
{
|
|
725
726
|
"availableDocPages": [
|
|
@@ -784,7 +785,7 @@
|
|
|
784
785
|
"dnd"
|
|
785
786
|
],
|
|
786
787
|
"slug": "orbit",
|
|
787
|
-
"version": "1.1.
|
|
788
|
+
"version": "1.1.4"
|
|
788
789
|
},
|
|
789
790
|
{
|
|
790
791
|
"availableDocPages": [
|
|
@@ -852,7 +853,7 @@
|
|
|
852
853
|
"orbit"
|
|
853
854
|
],
|
|
854
855
|
"slug": "ore",
|
|
855
|
-
"version": "
|
|
856
|
+
"version": "2.0.0"
|
|
856
857
|
},
|
|
857
858
|
{
|
|
858
859
|
"availableDocPages": [
|
|
@@ -908,7 +909,7 @@
|
|
|
908
909
|
"orbit"
|
|
909
910
|
],
|
|
910
911
|
"slug": "prism",
|
|
911
|
-
"version": "
|
|
912
|
+
"version": "2.0.0"
|
|
912
913
|
},
|
|
913
914
|
{
|
|
914
915
|
"availableDocPages": [
|
|
@@ -959,7 +960,7 @@
|
|
|
959
960
|
"clockwork"
|
|
960
961
|
],
|
|
961
962
|
"slug": "pulse",
|
|
962
|
-
"version": "
|
|
963
|
+
"version": "2.0.0"
|
|
963
964
|
},
|
|
964
965
|
{
|
|
965
966
|
"availableDocPages": [
|
|
@@ -1057,7 +1058,7 @@
|
|
|
1057
1058
|
"keymap"
|
|
1058
1059
|
],
|
|
1059
1060
|
"slug": "refine",
|
|
1060
|
-
"version": "
|
|
1061
|
+
"version": "2.0.0"
|
|
1061
1062
|
},
|
|
1062
1063
|
{
|
|
1063
1064
|
"availableDocPages": [
|
|
@@ -1108,7 +1109,7 @@
|
|
|
1108
1109
|
"ledger"
|
|
1109
1110
|
],
|
|
1110
1111
|
"slug": "ripple",
|
|
1111
|
-
"version": "
|
|
1112
|
+
"version": "2.0.0"
|
|
1112
1113
|
},
|
|
1113
1114
|
{
|
|
1114
1115
|
"availableDocPages": [
|
|
@@ -1259,7 +1260,7 @@
|
|
|
1259
1260
|
"ripple"
|
|
1260
1261
|
],
|
|
1261
1262
|
"slug": "scout",
|
|
1262
|
-
"version": "
|
|
1263
|
+
"version": "2.0.0"
|
|
1263
1264
|
},
|
|
1264
1265
|
{
|
|
1265
1266
|
"availableDocPages": [
|
|
@@ -1311,7 +1312,7 @@
|
|
|
1311
1312
|
"refine"
|
|
1312
1313
|
],
|
|
1313
1314
|
"slug": "scroll",
|
|
1314
|
-
"version": "1.1.
|
|
1315
|
+
"version": "1.1.5"
|
|
1315
1316
|
},
|
|
1316
1317
|
{
|
|
1317
1318
|
"availableDocPages": [
|
|
@@ -1379,7 +1380,7 @@
|
|
|
1379
1380
|
"wayfinder"
|
|
1380
1381
|
],
|
|
1381
1382
|
"slug": "sourcerer",
|
|
1382
|
-
"version": "
|
|
1383
|
+
"version": "2.0.0"
|
|
1383
1384
|
},
|
|
1384
1385
|
{
|
|
1385
1386
|
"availableDocPages": [
|
|
@@ -1438,7 +1439,7 @@
|
|
|
1438
1439
|
"vault"
|
|
1439
1440
|
],
|
|
1440
1441
|
"slug": "spell",
|
|
1441
|
-
"version": "
|
|
1442
|
+
"version": "2.0.0"
|
|
1442
1443
|
},
|
|
1443
1444
|
{
|
|
1444
1445
|
"availableDocPages": [
|
|
@@ -1563,7 +1564,7 @@
|
|
|
1563
1564
|
"ripple"
|
|
1564
1565
|
],
|
|
1565
1566
|
"slug": "vault",
|
|
1566
|
-
"version": "
|
|
1567
|
+
"version": "2.0.0"
|
|
1567
1568
|
},
|
|
1568
1569
|
{
|
|
1569
1570
|
"availableDocPages": [
|
|
@@ -1675,5 +1676,5 @@
|
|
|
1675
1676
|
"version": "1.0.4"
|
|
1676
1677
|
}
|
|
1677
1678
|
],
|
|
1678
|
-
"version": "
|
|
1679
|
+
"version": "2.0.0"
|
|
1679
1680
|
}
|
package/data/llms-full.txt
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Vielzeug — Full Documentation
|
|
2
2
|
|
|
3
|
-
> Complete documentation for 31 packages. Version:
|
|
3
|
+
> Complete documentation for 31 packages. Version: 2.0.0
|
|
4
4
|
|
|
5
5
|
---
|
|
6
6
|
|
|
@@ -10969,7 +10969,8 @@ try {
|
|
|
10969
10969
|
|
|
10970
10970
|
## Features
|
|
10971
10971
|
|
|
10972
|
-
- `
|
|
10972
|
+
- `createCatalogTranslator()` compiles one immutable fixed-locale catalog.
|
|
10973
|
+
- `createTranslator()` compiles immutable locale-keyed catalogs.
|
|
10973
10974
|
- `createTranslationStore()` manages locale changes and declared catalogs.
|
|
10974
10975
|
- `translate()` renders text and plural messages through explicit catalog nodes.
|
|
10975
10976
|
- `translateDynamic()` makes runtime-key lookup explicit.
|
|
@@ -10996,6 +10997,7 @@ try {
|
|
|
10996
10997
|
|
|
10997
10998
|
| Symbol | Purpose | Execution mode | Common gotcha |
|
|
10998
10999
|
| --- | --- | --- | --- |
|
|
11000
|
+
| `createCatalogTranslator()` | Compile one immutable locale catalog | Sync | No fallback locales |
|
|
10999
11001
|
| `createTranslator()` | Compile immutable locale catalogs | Sync | Locale is fixed for translator lifetime |
|
|
11000
11002
|
| `createTranslationStore()` | Create mutable locale and catalog store | Sync | Load lazy locale explicitly |
|
|
11001
11003
|
| `hydrateTranslationStore()` | Create store from serialized loaded catalogs | Sync | Serialized state never includes loaders |
|
|
@@ -11013,6 +11015,39 @@ try {
|
|
|
11013
11015
|
|
|
11014
11016
|
## Translation Factories
|
|
11015
11017
|
|
|
11018
|
+
### createCatalogTranslator
|
|
11019
|
+
|
|
11020
|
+
```ts
|
|
11021
|
+
function createCatalogTranslator(
|
|
11022
|
+
catalog: C,
|
|
11023
|
+
options?: CatalogTranslatorOptions,
|
|
11024
|
+
): Translator;
|
|
11025
|
+
```
|
|
11026
|
+
|
|
11027
|
+
Compiles one catalog and returns an immutable fixed-locale translator. Locale defaults to `en` and controls plural selection and diagnostics.
|
|
11028
|
+
|
|
11029
|
+
| Parameter | Type | Description |
|
|
11030
|
+
| --- | --- | --- |
|
|
11031
|
+
| `catalog` | `C` | One catalog containing only messages and grouping objects |
|
|
11032
|
+
| `options` | `CatalogTranslatorOptions` | Locale and missing-message handlers; fallback is unavailable |
|
|
11033
|
+
|
|
11034
|
+
**Returns:** `Translator`.
|
|
11035
|
+
|
|
11036
|
+
**Example:**
|
|
11037
|
+
|
|
11038
|
+
```ts
|
|
11039
|
+
import { createCatalogTranslator } from '@vielzeug/lingua';
|
|
11040
|
+
|
|
11041
|
+
const translator = createCatalogTranslator(
|
|
11042
|
+
{ save: 'Enregistrer' },
|
|
11043
|
+
{ locale: 'fr' },
|
|
11044
|
+
);
|
|
11045
|
+
|
|
11046
|
+
translator.translate('save');
|
|
11047
|
+
```
|
|
11048
|
+
|
|
11049
|
+
---
|
|
11050
|
+
|
|
11016
11051
|
### createTranslator
|
|
11017
11052
|
|
|
11018
11053
|
```ts
|
|
@@ -11207,6 +11242,7 @@ type PluralMessage = { readonly plural: Partial> };
|
|
|
11207
11242
|
type CatalogNode = Catalog | PluralMessage | string;
|
|
11208
11243
|
type Catalog = { readonly [key: string]: CatalogNode };
|
|
11209
11244
|
type Catalogs = Record;
|
|
11245
|
+
type CatalogTranslatorOptions = Omit;
|
|
11210
11246
|
type CatalogLoader = () => Promise;
|
|
11211
11247
|
type CatalogSource = C | CatalogLoader;
|
|
11212
11248
|
type CatalogSources = Record>;
|
|
@@ -11329,19 +11365,33 @@ const catalog = {
|
|
|
11329
11365
|
};
|
|
11330
11366
|
```
|
|
11331
11367
|
|
|
11332
|
-
Use `{ values }` for text replacements. Pass `count` at top level for plural selection; Lingua injects it into selected template.
|
|
11368
|
+
Use `{ values }` for text replacements. Pass `count` at top level for plural selection; Lingua injects it into selected template. Absent replacements render as `{name}` by default. `segments()` preserves an own `undefined` or `null` value; omit property to receive `{name}`.
|
|
11369
|
+
|
|
11370
|
+
Catalogs contain strings, grouping objects, and explicit `{ plural: ... }` messages only. Keep application data outside catalog, then translate display labels while constructing it.
|
|
11371
|
+
|
|
11372
|
+
```ts
|
|
11373
|
+
import { createCatalogTranslator } from '@vielzeug/lingua';
|
|
11374
|
+
|
|
11375
|
+
const messages = {
|
|
11376
|
+
status: { blocked: 'Blocked', done: 'Done', inProgress: 'In progress' },
|
|
11377
|
+
};
|
|
11378
|
+
const statusDefinitions = [
|
|
11379
|
+
{ labelKey: 'status.inProgress', value: 'in-progress' },
|
|
11380
|
+
{ labelKey: 'status.blocked', value: 'blocked' },
|
|
11381
|
+
{ labelKey: 'status.done', value: 'done' },
|
|
11382
|
+
] as const;
|
|
11383
|
+
const translator = createCatalogTranslator(messages);
|
|
11384
|
+
const statusOptions = statusDefinitions.map(({ labelKey, value }) => ({ label: translator.translate(labelKey), value }));
|
|
11385
|
+
```
|
|
11333
11386
|
|
|
11334
11387
|
## Render Framework Content
|
|
11335
11388
|
|
|
11336
11389
|
Use `segments()` when replacements are framework nodes, links, or other values that must not be stringified.
|
|
11337
11390
|
|
|
11338
11391
|
```ts
|
|
11339
|
-
import {
|
|
11392
|
+
import { createCatalogTranslator } from '@vielzeug/lingua';
|
|
11340
11393
|
|
|
11341
|
-
const translator =
|
|
11342
|
-
{ en: { error: 'Try {retry} or {support}.' } },
|
|
11343
|
-
{ locale: 'en' },
|
|
11344
|
-
);
|
|
11394
|
+
const translator = createCatalogTranslator({ error: 'Try {retry} or {support}.' });
|
|
11345
11395
|
|
|
11346
11396
|
const retry = { href: '/retry', label: 'retry' };
|
|
11347
11397
|
const support = { href: '/support', label: 'support' };
|
|
@@ -11349,11 +11399,24 @@ const support = { href: '/support', label: 'support' };
|
|
|
11349
11399
|
console.log(translator.segments('error', { values: { retry, support } }));
|
|
11350
11400
|
```
|
|
11351
11401
|
|
|
11352
|
-
Render returned array with framework fragment or list primitive.
|
|
11402
|
+
Render returned array with framework fragment or list primitive. Give UI values consumer-owned keys before passing them to `segments()`; Lingua preserves value identity and never clones or mutates them.
|
|
11353
11403
|
|
|
11354
11404
|
## Use Static Catalogs
|
|
11355
11405
|
|
|
11356
|
-
Use `
|
|
11406
|
+
Use `createCatalogTranslator()` when one catalog and locale stay fixed for translator lifetime. It defaults locale to `en`; pass `locale` when plural rules or diagnostics need another locale. Lingua snapshots catalog messages during construction. Do not mutate source catalog objects afterward.
|
|
11407
|
+
|
|
11408
|
+
```ts
|
|
11409
|
+
import { createCatalogTranslator } from '@vielzeug/lingua';
|
|
11410
|
+
|
|
11411
|
+
const translator = createCatalogTranslator(
|
|
11412
|
+
{ save: 'Enregistrer' },
|
|
11413
|
+
{ locale: 'fr' },
|
|
11414
|
+
);
|
|
11415
|
+
|
|
11416
|
+
console.log(translator.translate('save'));
|
|
11417
|
+
```
|
|
11418
|
+
|
|
11419
|
+
Use `createTranslator()` when fixed translation requires locale-keyed catalogs and fallback resolution.
|
|
11357
11420
|
|
|
11358
11421
|
```ts
|
|
11359
11422
|
import { createTranslator } from '@vielzeug/lingua';
|
|
@@ -11407,7 +11470,7 @@ Pass `{ signal }` when an `AbortController` owns subscription lifetime.
|
|
|
11407
11470
|
|
|
11408
11471
|
## SSR State
|
|
11409
11472
|
|
|
11410
|
-
Serialize
|
|
11473
|
+
Serialize resolved catalogs on server, then hydrate client store from same payload. `getSnapshot()` stays referentially stable until store revision changes, so use same hydrated store throughout initial client render.
|
|
11411
11474
|
|
|
11412
11475
|
```ts
|
|
11413
11476
|
import { createTranslationStore, hydrateTranslationStore } from '@vielzeug/lingua';
|
|
@@ -11444,7 +11507,7 @@ console.log(validateCatalog(catalog, 'en'));
|
|
|
11444
11507
|
|
|
11445
11508
|
## Framework Integration
|
|
11446
11509
|
|
|
11447
|
-
|
|
11510
|
+
Pass stable `getSnapshot()` and `subscribe()` methods to framework state primitives. For SSR, create client store from same serialized state used by server before calling `useSyncExternalStore`.
|
|
11448
11511
|
|
|
11449
11512
|
```ts [React]
|
|
11450
11513
|
import { useSyncExternalStore } from 'react';
|
|
@@ -11452,11 +11515,9 @@ import { useSyncExternalStore } from 'react';
|
|
|
11452
11515
|
import type { TranslationStore } from '@vielzeug/lingua';
|
|
11453
11516
|
|
|
11454
11517
|
export function useTranslator(i18n: TranslationStore) {
|
|
11455
|
-
|
|
11456
|
-
|
|
11457
|
-
|
|
11458
|
-
() => i18n.getSnapshot().translator,
|
|
11459
|
-
);
|
|
11518
|
+
const snapshot = useSyncExternalStore(i18n.subscribe, i18n.getSnapshot, i18n.getSnapshot);
|
|
11519
|
+
|
|
11520
|
+
return snapshot.translator;
|
|
11460
11521
|
}
|
|
11461
11522
|
```
|
|
11462
11523
|
|
|
@@ -11510,13 +11571,13 @@ Use Courier loaders when locale catalogs come from HTTP rather than bundled modu
|
|
|
11510
11571
|
|
|
11511
11572
|
## Best Practices
|
|
11512
11573
|
|
|
11513
|
-
- Define plural messages with `{ plural: ... }
|
|
11514
|
-
- Keep
|
|
11574
|
+
- Define plural messages with `{ plural: ... }` and no sibling metadata.
|
|
11575
|
+
- Keep arrays and application metadata outside catalogs.
|
|
11576
|
+
- Treat source catalog objects as immutable after construction.
|
|
11515
11577
|
- Use `translateDynamic()` only for runtime-generated keys.
|
|
11516
11578
|
- Load a lazy catalog before rendering it.
|
|
11517
|
-
-
|
|
11579
|
+
- Give UI values keys before passing them to `segments()`.
|
|
11518
11580
|
- Keep loader functions out of SSR payloads.
|
|
11519
|
-
- Pass an `AbortSignal` to subscriptions owned by component or request.
|
|
11520
11581
|
- Dispose temporary stores after requests, tests, and route lifetimes.
|
|
11521
11582
|
|
|
11522
11583
|
### Examples
|
package/data/llms.txt
CHANGED
package/data/manifest.json
CHANGED