inlang-plugin-rich-icu 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 +86 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +4842 -0
- package/package.json +46 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Donald
|
|
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,86 @@
|
|
|
1
|
+
# inlang-plugin-rich-icu
|
|
2
|
+
|
|
3
|
+
An inlang storage plugin that reads/writes **inline ICU MessageFormat** catalogs
|
|
4
|
+
**and preserves rich-text markup tags** (`<strong>…</strong>`, `<link>…</link>`)
|
|
5
|
+
as first-class inlang markup — so Paraglide JS renders them as real components,
|
|
6
|
+
even inside plural/select branches.
|
|
7
|
+
|
|
8
|
+
## Install
|
|
9
|
+
|
|
10
|
+
The plugin is loaded by inlang as an ESM module from a CDN — you don't install it
|
|
11
|
+
as a dependency. Add it to your `project.inlang/settings.json`:
|
|
12
|
+
|
|
13
|
+
```json
|
|
14
|
+
{
|
|
15
|
+
"$schema": "https://inlang.com/schema/project-settings",
|
|
16
|
+
"baseLocale": "en",
|
|
17
|
+
"locales": ["en", "fr"],
|
|
18
|
+
"modules": [
|
|
19
|
+
"https://cdn.jsdelivr.net/npm/inlang-plugin-rich-icu@latest/dist/index.js"
|
|
20
|
+
],
|
|
21
|
+
"plugin.donal2.richIcu": {
|
|
22
|
+
"pathPattern": "./messages/{locale}.json"
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Catalogs are JSON maps of `key → ICU string`, one file per locale:
|
|
28
|
+
|
|
29
|
+
```json
|
|
30
|
+
{ "resumeCount": "{count, plural, one {Vous avez <strong># CV</strong>.} other {Vous avez <strong># CV</strong>.}}" }
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Render (Paraglide + React)
|
|
34
|
+
|
|
35
|
+
```tsx
|
|
36
|
+
<ParaglideMessage
|
|
37
|
+
message={m.resumeCount}
|
|
38
|
+
inputs={{ count }}
|
|
39
|
+
markup={{ strong: ({ children }) => <strong>{children}</strong> }}
|
|
40
|
+
/>
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Supported ICU features
|
|
44
|
+
|
|
45
|
+
- **`select`, `plural`, `selectordinal`** — including exact matches (`=0`, `=1`, …)
|
|
46
|
+
and `offset:`. Sibling selectors keep their source order.
|
|
47
|
+
- **`#`** (octothorpe) inside `plural` / `selectordinal` cases.
|
|
48
|
+
- **Markup tags** — paired (`<strong>…</strong>`) and self-closing (`<br/>`),
|
|
49
|
+
including selectors nested inside a tag (`<b>{n, plural, …}</b>`).
|
|
50
|
+
- **Formatter functions** `number`, `date`, `time` — with named styles
|
|
51
|
+
(`percent`, `short`, …) **and** `::` skeletons (`{p, number, ::currency/USD}`),
|
|
52
|
+
preserved on round-trip.
|
|
53
|
+
|
|
54
|
+
## Not supported in v1
|
|
55
|
+
|
|
56
|
+
These throw a clear error on import (the offending message is skipped, the rest
|
|
57
|
+
of the file still imports):
|
|
58
|
+
|
|
59
|
+
- The `spellout`, `ordinal` and `duration` **formatter functions**
|
|
60
|
+
(`{n, spellout}`, `{n, ordinal}`, `{d, duration}`). Note: `selectordinal`
|
|
61
|
+
*is* supported — only the standalone `ordinal` number formatter is not.
|
|
62
|
+
- Markup **attributes / options** (`<link href="…">`) — tags carry their name only.
|
|
63
|
+
|
|
64
|
+
Other notes:
|
|
65
|
+
|
|
66
|
+
- `pathPattern` is a single string (must contain `{locale}` and end in `.json`).
|
|
67
|
+
- A `plural` / `select` / `selectordinal` without an `other` clause is rejected,
|
|
68
|
+
as required by ICU MessageFormat.
|
|
69
|
+
|
|
70
|
+
## Tested with
|
|
71
|
+
|
|
72
|
+
- `@inlang/sdk` 2.10.2
|
|
73
|
+
- `@formatjs/icu-messageformat-parser` ^2
|
|
74
|
+
- Parité d'AST vérifiée contre `@inlang/plugin-icu1` 1.1.0 (corpus sans markup)
|
|
75
|
+
|
|
76
|
+
## Development
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
pnpm install
|
|
80
|
+
pnpm test
|
|
81
|
+
pnpm build
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## License
|
|
85
|
+
|
|
86
|
+
MIT
|