@saykit/format-json 0.9.1 → 0.10.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/README.md +9 -9
- package/dist/formatter.d.mts +3 -3
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
[](https://codecov.io/gh/k0d13/saykit?flags%5B0%5D=format-json)
|
|
6
6
|
|
|
7
|
-
Writes one JSON catalogue per locale
|
|
7
|
+
Writes one JSON catalogue per locale, the de facto format for web i18n
|
|
8
8
|
(react-intl, FormatJS, i18next, …). Reach for this instead of
|
|
9
9
|
[`@saykit/format-po`](https://github.com/k0d13/saykit/tree/main/packages/format-po)
|
|
10
10
|
when you want plain JSON bundles with no Gettext tooling.
|
|
@@ -25,7 +25,7 @@ formatter: json();
|
|
|
25
25
|
```
|
|
26
26
|
|
|
27
27
|
Each catalogue is a pretty-printed, flat map keyed by the message id (falling
|
|
28
|
-
back to a stable content hash when a message has no id
|
|
28
|
+
back to a stable content hash when a message has no id, the same key the
|
|
29
29
|
runtime resolves), with the translation as the value:
|
|
30
30
|
|
|
31
31
|
```json
|
|
@@ -34,19 +34,19 @@ runtime resolves), with the translation as the value:
|
|
|
34
34
|
}
|
|
35
35
|
```
|
|
36
36
|
|
|
37
|
-
ICU MessageFormat strings are stored verbatim as JSON string values
|
|
37
|
+
ICU MessageFormat strings are stored verbatim as JSON string values, so JSON
|
|
38
38
|
escaping is handled for you.
|
|
39
39
|
|
|
40
40
|
### Dialects
|
|
41
41
|
|
|
42
42
|
The plain layout above is just `{ key: value }`, so it drops comments, context,
|
|
43
|
-
and source references. Pass `dialect` to keep them using a richer
|
|
44
|
-
standard
|
|
43
|
+
and source references. Pass `dialect` to keep them using a richer but still
|
|
44
|
+
standard JSON layout:
|
|
45
45
|
|
|
46
|
-
- `dialect: 'arb'
|
|
46
|
+
- `dialect: 'arb'`: [Application Resource Bundle](https://github.com/google/app-resource-bundle)
|
|
47
47
|
(Flutter/Dart `intl`). Strings stay flat; each key's metadata lives in a
|
|
48
48
|
sibling `@key` object.
|
|
49
|
-
- `dialect: 'webextension'
|
|
49
|
+
- `dialect: 'webextension'`: the Chrome/WebExtension `messages.json` shape,
|
|
50
50
|
where each key maps to a `{ message, description }` object.
|
|
51
51
|
|
|
52
52
|
```ts
|
|
@@ -67,7 +67,7 @@ formatter: json({ dialect: 'arb' });
|
|
|
67
67
|
|
|
68
68
|
Both formats carry translator comments in their native `description` field.
|
|
69
69
|
Context and source references have no standard slot, so SayKit round-trips them
|
|
70
|
-
through `x-saykit-context` / `x-saykit-references` extension fields
|
|
70
|
+
through `x-saykit-context` / `x-saykit-references` extension fields, so other
|
|
71
71
|
tooling reads the `description` and safely ignores the rest.
|
|
72
72
|
|
|
73
73
|
### Options
|
|
@@ -80,7 +80,7 @@ tooling reads the `description` and safely ignores the rest.
|
|
|
80
80
|
> [!NOTE]
|
|
81
81
|
> JSON catalogues are keyed by message id, so give your messages explicit ids to
|
|
82
82
|
> get stable, human-readable keys. The plain layout carries no source
|
|
83
|
-
> references, comments, or contexts
|
|
83
|
+
> references, comments, or contexts: it is a lean runtime format.
|
|
84
84
|
|
|
85
85
|
## Documentation
|
|
86
86
|
|
package/dist/formatter.d.mts
CHANGED
|
@@ -5,11 +5,11 @@ interface FormatterOptions {
|
|
|
5
5
|
/**
|
|
6
6
|
* The JSON dialect to write. A dialect other than the default plain
|
|
7
7
|
* `{ key: value }` map carries message metadata (comments, context, source
|
|
8
|
-
* references) using a richer
|
|
8
|
+
* references) using a richer, but still standard, layout.
|
|
9
9
|
*
|
|
10
|
-
* - `'arb'
|
|
10
|
+
* - `'arb'`: Application Resource Bundle (Flutter/Dart `intl`). Strings stay
|
|
11
11
|
* flat and each key's metadata lives in a sibling `@key` object.
|
|
12
|
-
* - `'webextension'
|
|
12
|
+
* - `'webextension'`: the Chrome/WebExtension `messages.json` shape, where
|
|
13
13
|
* each key maps to a `{ message, description }` object.
|
|
14
14
|
*
|
|
15
15
|
* Both carry translator comments in their native `description` field. Context
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@saykit/format-json",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"description": "JSON file formatter for saykit",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"formatter",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"provenance": true
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
|
-
"@saykit/config": "^0.
|
|
37
|
+
"@saykit/config": "^0.10.0"
|
|
38
38
|
},
|
|
39
39
|
"peerDependencies": {
|
|
40
40
|
"@saykit/config": "*"
|