verbaly 0.21.0 → 0.23.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 +17 -17
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
</p>
|
|
4
4
|
|
|
5
5
|
<p align="center">
|
|
6
|
-
<em>Effortless i18n
|
|
6
|
+
<em>Effortless i18n: write natural text, ship type-safe, tree-shakeable translations.</em>
|
|
7
7
|
</p>
|
|
8
8
|
|
|
9
9
|
<p align="center">
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
|
|
17
17
|
---
|
|
18
18
|
|
|
19
|
-
Most i18n tools make you maintain key files by hand
|
|
19
|
+
Most i18n tools make you maintain key files by hand: keys drift from the code, no type-safety, heavy setup. **Verbaly inverts the flow:** write the source text in your code, a build plugin extracts stable keys, types and per-locale modules. Compiler-grade safety, a runtime under **~3KB**, zero dependencies.
|
|
20
20
|
|
|
21
21
|
```ts
|
|
22
22
|
// You write this:
|
|
@@ -29,7 +29,7 @@ t('EMo3ph4u', { name, count }); // ← fully typed, tree-shakeable
|
|
|
29
29
|
t.id('inbox.title')`Hello ${name}`; // → t('inbox.title', { name })
|
|
30
30
|
```
|
|
31
31
|
|
|
32
|
-
Missing a translation? **The build fails
|
|
32
|
+
Missing a translation? **The build fails**, so raw keys never reach production.
|
|
33
33
|
|
|
34
34
|
## 🚀 Try it in 30 seconds
|
|
35
35
|
|
|
@@ -45,7 +45,7 @@ export default { plugins: [verbaly({ locales: ['en', 'es', 'pt'] })] };
|
|
|
45
45
|
```
|
|
46
46
|
|
|
47
47
|
```ts
|
|
48
|
-
// anywhere in your app
|
|
48
|
+
// anywhere in your app, extracted + typed on save
|
|
49
49
|
import { t, setLocale } from 'virtual:verbaly';
|
|
50
50
|
|
|
51
51
|
t`Hello ${name}`;
|
|
@@ -69,18 +69,18 @@ v.t('greeting', { name: 'Aron' }); // "Hello Aron"
|
|
|
69
69
|
v.setLocale('es'); // auto-loads the catalog; or: await v.loadLocale('es') first
|
|
70
70
|
```
|
|
71
71
|
|
|
72
|
-
### 🌐 Plain HTML
|
|
72
|
+
### 🌐 Plain HTML, no framework needed
|
|
73
73
|
|
|
74
74
|
```html
|
|
75
75
|
<h1 data-verbaly="home.title"></h1>
|
|
76
76
|
<p data-verbaly="home.intro" data-verbaly-rich></p>
|
|
77
|
-
<!-- rich: 'The build <em>gate</em>' renders a real <em>
|
|
77
|
+
<!-- rich: 'The build <em>gate</em>' renders a real <em> (whitelist, XSS-safe) -->
|
|
78
78
|
<p
|
|
79
79
|
data-verbaly="home.cta"
|
|
80
80
|
data-verbaly-rich
|
|
81
81
|
data-verbaly-links='{"repo":"https://github.com/x"}'
|
|
82
82
|
></p>
|
|
83
|
-
<!-- links: 'See the <repo>repo</repo>' renders <a href
|
|
83
|
+
<!-- links: 'See the <repo>repo</repo>' renders <a href>; hrefs from you, never from messages -->
|
|
84
84
|
```
|
|
85
85
|
|
|
86
86
|
```ts
|
|
@@ -108,14 +108,14 @@ const v = createVerbaly({ locale, fallback: 'en', messages });
|
|
|
108
108
|
|
|
109
109
|
## ✨ What you get
|
|
110
110
|
|
|
111
|
-
- **Hybrid compiler + runtime
|
|
112
|
-
- **Type-safe params
|
|
113
|
-
- **`Intl`-powered format
|
|
114
|
-
- **Plain, portable JSON catalogs
|
|
115
|
-
- **DOM interpreter** for framework-less HTML
|
|
116
|
-
- **Lazy catalogs
|
|
117
|
-
- **Runtime devtools
|
|
118
|
-
- **Fast, with receipts
|
|
111
|
+
- **Hybrid compiler + runtime**: static text compiled (types + tree-shaking), dynamic content via a real runtime path.
|
|
112
|
+
- **Type-safe params**: `{name}`, plurals, currency and dates inferred from the message; wrong/missing params fail to compile.
|
|
113
|
+
- **`Intl`-powered format**: number/currency/date/time/relative/list/unit + CLDR plurals and select/gender, tiny surface. `'Updated {when:relative}'` · `'{langs:list}'` · `'{d:unit/kilometer}'`.
|
|
114
|
+
- **Plain, portable JSON catalogs**: no proprietary format, no lock-in.
|
|
115
|
+
- **DOM interpreter** for framework-less HTML, with opt-in rich text (whitelist-based, XSS-safe) and named links (`richLinks` / `data-verbaly-links`; hrefs come from the caller, `javascript:` blocked).
|
|
116
|
+
- **Lazy catalogs**: `loaders` + `loadLocale` load per-locale JSON on demand, in the runtime itself.
|
|
117
|
+
- **Runtime devtools**: opt-in `verbaly/devtools` answers "what key is this text?" in the browser: hover to see any element's key/locale/source, plus a live missing-keys panel. Tree-shaken out of production (its own chunk). Or wire the `onResolve` hook yourself.
|
|
118
|
+
- **Fast, with receipts**: fully memoized hot path, benchmarked every release: 5–35× faster than i18next on lookup, interpolation and plurals.
|
|
119
119
|
|
|
120
120
|
## 🧩 Ecosystem
|
|
121
121
|
|
|
@@ -129,9 +129,9 @@ const v = createVerbaly({ locale, fallback: 'en', messages });
|
|
|
129
129
|
|
|
130
130
|
📖 **Docs & live playground:** https://verbaly-web.vercel.app
|
|
131
131
|
|
|
132
|
-
🔁 **Coming from i18next?** Keep your keys and catalogs
|
|
132
|
+
🔁 **Coming from i18next?** Keep your keys and catalogs: the [migration guide](https://verbaly-web.vercel.app/docs/migrate) maps everything one-to-one.
|
|
133
133
|
|
|
134
|
-
> ⚠️ Early development (`0.x`)
|
|
134
|
+
> ⚠️ Early development (`0.x`): API not stable yet.
|
|
135
135
|
|
|
136
136
|
## License
|
|
137
137
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "verbaly",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Effortless i18n
|
|
3
|
+
"version": "0.23.0",
|
|
4
|
+
"description": "Effortless i18n: write natural text, ship type-safe, tree-shakeable translations.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"i18n",
|
|
7
7
|
"internationalization",
|