@better-intl/cli 0.1.0 → 0.1.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/README.md +118 -0
- package/package.json +5 -4
package/README.md
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
# @better-intl/cli
|
|
2
|
+
|
|
3
|
+
CLI for **better-intl** — extract, validate, compile translations.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install -D @better-intl/cli
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Configuration
|
|
12
|
+
|
|
13
|
+
Create `better-intl.config.json` at your project root:
|
|
14
|
+
|
|
15
|
+
```json
|
|
16
|
+
{
|
|
17
|
+
"defaultLocale": "en",
|
|
18
|
+
"locales": ["en", "pt-BR", "es"],
|
|
19
|
+
"catalogs": "./locales/{locale}.json",
|
|
20
|
+
"include": ["src/**/*.tsx", "app/**/*.tsx"]
|
|
21
|
+
}
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Also supports `better-intl.config.js`, `.better-intlrc.json`, or a `"better-intl"` key in `package.json`.
|
|
25
|
+
|
|
26
|
+
## Commands
|
|
27
|
+
|
|
28
|
+
### `i18n extract`
|
|
29
|
+
|
|
30
|
+
Scans source files and generates/updates locale catalogs:
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
i18n extract
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
```
|
|
37
|
+
✦ Extracted 12 messages from 5 files
|
|
38
|
+
locales/en.json — 3 added, 0 removed
|
|
39
|
+
locales/pt-BR.json — 3 added, 0 removed
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### `i18n validate`
|
|
43
|
+
|
|
44
|
+
Checks all locales for missing translations:
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
i18n validate
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### `i18n missing`
|
|
51
|
+
|
|
52
|
+
Shows missing translation count per locale:
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
i18n missing
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### `i18n dead-keys`
|
|
59
|
+
|
|
60
|
+
Finds keys in catalogs that are no longer in source:
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
i18n dead-keys
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### `i18n compile`
|
|
67
|
+
|
|
68
|
+
Compiles catalogs into optimized JS modules:
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
i18n compile
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### `i18n show`
|
|
75
|
+
|
|
76
|
+
Displays all translations in a table:
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
i18n show
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### `i18n dev`
|
|
83
|
+
|
|
84
|
+
Opens an interactive translation dashboard in the terminal:
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
i18n dev
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
```
|
|
91
|
+
better-intl dashboard
|
|
92
|
+
12 keys · 3 locales · 9 extracted · 3 manual
|
|
93
|
+
|
|
94
|
+
EXTRACTED FROM SOURCE
|
|
95
|
+
Source Default en pt-BR es
|
|
96
|
+
──────────────────────────────────────────────────────────────────────
|
|
97
|
+
Hero.tsx:3 <h1> Hello world ─ ✓ ✗
|
|
98
|
+
|
|
99
|
+
COVERAGE
|
|
100
|
+
en ████████████████████ 100% (12/12)
|
|
101
|
+
pt-BR ████████████░░░░░░░░ 60% (7/12)
|
|
102
|
+
es ██░░░░░░░░░░░░░░░░░░ 10% (1/12)
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
## Programmatic API
|
|
106
|
+
|
|
107
|
+
All commands are also available as functions:
|
|
108
|
+
|
|
109
|
+
```ts
|
|
110
|
+
import { loadConfig, extractCommand, validateCommand } from "@better-intl/cli";
|
|
111
|
+
|
|
112
|
+
const config = await loadConfig(process.cwd());
|
|
113
|
+
await extractCommand(config, process.cwd());
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
## License
|
|
117
|
+
|
|
118
|
+
MIT
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@better-intl/cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "CLI for better-intl — extract, validate, compile translations",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -18,13 +18,14 @@
|
|
|
18
18
|
}
|
|
19
19
|
},
|
|
20
20
|
"files": [
|
|
21
|
-
"dist"
|
|
21
|
+
"dist",
|
|
22
|
+
"README.md"
|
|
22
23
|
],
|
|
23
24
|
"dependencies": {
|
|
24
25
|
"ink": "^7.0.0",
|
|
25
26
|
"react": "^19.0.0",
|
|
26
|
-
"@better-intl/core": "0.1.
|
|
27
|
-
"@better-intl/compiler": "0.1.
|
|
27
|
+
"@better-intl/core": "0.1.1",
|
|
28
|
+
"@better-intl/compiler": "0.1.1"
|
|
28
29
|
},
|
|
29
30
|
"sideEffects": false,
|
|
30
31
|
"license": "MIT",
|