verbaly 0.14.5 → 0.15.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 +7 -7
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
|
|
19
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:
|
|
23
23
|
t`Hello ${name}, you have ${count} messages`;
|
|
24
24
|
|
|
@@ -33,18 +33,18 @@ Missing a translation? **The build fails** — raw keys never reach production.
|
|
|
33
33
|
|
|
34
34
|
## 🚀 Try it in 30 seconds
|
|
35
35
|
|
|
36
|
-
```
|
|
36
|
+
```bash
|
|
37
37
|
pnpm add verbaly @verbaly/vite
|
|
38
38
|
```
|
|
39
39
|
|
|
40
|
-
```
|
|
40
|
+
```ts
|
|
41
41
|
// vite.config.ts
|
|
42
42
|
import verbaly from '@verbaly/vite';
|
|
43
43
|
|
|
44
44
|
export default { plugins: [verbaly({ locales: ['en', 'es', 'pt'] })] };
|
|
45
45
|
```
|
|
46
46
|
|
|
47
|
-
```
|
|
47
|
+
```ts
|
|
48
48
|
// anywhere in your app — extracted + typed on save
|
|
49
49
|
import { t, setLocale } from 'virtual:verbaly';
|
|
50
50
|
|
|
@@ -56,7 +56,7 @@ await setLocale('es'); // per-locale bundle loaded on demand
|
|
|
56
56
|
|
|
57
57
|
`verbaly` also works on its own for dynamic/CMS content:
|
|
58
58
|
|
|
59
|
-
```
|
|
59
|
+
```ts
|
|
60
60
|
import { createVerbaly } from 'verbaly';
|
|
61
61
|
|
|
62
62
|
const v = createVerbaly({
|
|
@@ -71,7 +71,7 @@ v.setLocale('es'); // auto-loads the catalog; or: await v.loadLocale('es') first
|
|
|
71
71
|
|
|
72
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
77
|
<!-- rich: 'The build <em>gate</em>' renders a real <em> — whitelist, XSS-safe -->
|
|
@@ -83,7 +83,7 @@ v.setLocale('es'); // auto-loads the catalog; or: await v.loadLocale('es') first
|
|
|
83
83
|
<!-- links: 'See the <repo>repo</repo>' renders <a href> — hrefs from you, never from messages -->
|
|
84
84
|
```
|
|
85
85
|
|
|
86
|
-
```
|
|
86
|
+
```ts
|
|
87
87
|
import { bindDom, createVerbaly, persistLocale, resolveLocale } from 'verbaly';
|
|
88
88
|
|
|
89
89
|
const v = createVerbaly({
|