@vocoder/cli 0.1.4 → 0.1.6
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 +6 -57
- package/dist/bin.mjs +397 -1212
- package/dist/bin.mjs.map +1 -1
- package/package.json +1 -2
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @vocoder/cli
|
|
2
2
|
|
|
3
|
-
Command-line tool for Vocoder. Handles project setup
|
|
3
|
+
Command-line tool for Vocoder. Handles project setup and automatic string wrapping for translation.
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
@@ -30,48 +30,11 @@ The command detects your git remote and checks if a Vocoder project already exis
|
|
|
30
30
|
|
|
31
31
|
| Flag | Description |
|
|
32
32
|
|---|---|
|
|
33
|
-
| `--api-url <url>` | Override Vocoder API URL |
|
|
34
33
|
| `--yes` | Skip confirmation prompts |
|
|
35
34
|
| `--project-name <name>` | Pre-fill project name |
|
|
36
35
|
| `--source-locale <locale>` | Pre-fill source locale |
|
|
37
36
|
| `--target-locales <list>` | Comma-separated target locales (e.g., `es,fr,de`) |
|
|
38
37
|
|
|
39
|
-
### `vocoder sync`
|
|
40
|
-
|
|
41
|
-
Extract translatable strings from your source code and push them to Vocoder for translation.
|
|
42
|
-
|
|
43
|
-
```bash
|
|
44
|
-
vocoder sync
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
This command:
|
|
48
|
-
|
|
49
|
-
1. Detects the current git branch and repository
|
|
50
|
-
2. Scans your source files for `<T>` components and `t()` calls
|
|
51
|
-
3. Extracts the source text, file location, and any context/formality hints
|
|
52
|
-
4. Sends the extracted strings to the Vocoder API
|
|
53
|
-
5. Optionally waits for translations to complete (based on sync mode)
|
|
54
|
-
|
|
55
|
-
**Options:**
|
|
56
|
-
|
|
57
|
-
| Flag | Description |
|
|
58
|
-
|---|---|
|
|
59
|
-
| `--branch <name>` | Override branch detection |
|
|
60
|
-
| `--include <pattern>` | Glob pattern(s) to include (repeatable) |
|
|
61
|
-
| `--exclude <pattern>` | Glob pattern(s) to exclude (repeatable) |
|
|
62
|
-
| `--force` | Sync even if not on a target branch |
|
|
63
|
-
| `--mode <mode>` | Sync mode: `auto`, `required`, or `best-effort` |
|
|
64
|
-
| `--max-wait-ms <ms>` | Max wait time before fallback (milliseconds) |
|
|
65
|
-
| `--no-fallback` | Fail instead of falling back to cached translations |
|
|
66
|
-
| `--dry-run` | Show what would be synced without sending |
|
|
67
|
-
| `--verbose` | Show detailed progress |
|
|
68
|
-
|
|
69
|
-
#### Sync Modes
|
|
70
|
-
|
|
71
|
-
- **`auto`** (default) -- Checks the project's sync policy. Blocking branches (e.g., `main`, `production`) use `required` mode; other branches use `best-effort`.
|
|
72
|
-
- **`required`** -- Waits for translations to complete before finishing. Fails if translations can't be completed within the timeout.
|
|
73
|
-
- **`best-effort`** -- Sends strings for translation but doesn't wait. Falls back to the latest available translations.
|
|
74
|
-
|
|
75
38
|
### `vocoder wrap`
|
|
76
39
|
|
|
77
40
|
Automatically wrap string literals in your source code with `<T>` and `t()`.
|
|
@@ -93,29 +56,15 @@ Scans your JSX/TSX files for user-facing string literals and wraps them with the
|
|
|
93
56
|
| `--confidence <level>` | Minimum confidence: `high`, `medium`, `low` (default: `high`) |
|
|
94
57
|
| `--verbose` | Detailed output |
|
|
95
58
|
|
|
96
|
-
## Environment Variables
|
|
97
|
-
|
|
98
|
-
| Variable | Required | Description |
|
|
99
|
-
|---|---|---|
|
|
100
|
-
| `VOCODER_API_KEY` | Yes (for `sync`) | API key for authenticating with the Vocoder API |
|
|
101
|
-
| `VOCODER_API_URL` | No | Override API URL (default: `https://vocoder.app`) |
|
|
102
|
-
|
|
103
|
-
The CLI reads `.env` files in the project root automatically.
|
|
104
|
-
|
|
105
59
|
## String Extraction
|
|
106
60
|
|
|
107
|
-
The
|
|
108
|
-
|
|
109
|
-
- `<T>` component children: `<T>Hello, world!</T>`
|
|
110
|
-
- `<T>` component `msg` prop: `<T msg="{count, plural, one {# item} other {# items}}" />`
|
|
111
|
-
- `t()` function calls: `t('Hello, world!')`
|
|
61
|
+
The `wrap` command uses Babel to parse JSX/TSX files and detect strings that are likely user-facing. It distinguishes between:
|
|
112
62
|
|
|
113
|
-
|
|
63
|
+
- JSX text content (wrapped with `<T>`)
|
|
64
|
+
- String props like `placeholder`, `title`, `aria-label` (wrapped with `t()`)
|
|
65
|
+
- Non-translatable strings like class names, keys, and URLs (left alone)
|
|
114
66
|
|
|
115
|
-
|
|
116
|
-
- The source text (used as the translation key)
|
|
117
|
-
- File path and line number
|
|
118
|
-
- Optional `context` and `formality` props
|
|
67
|
+
It tracks imports from `@vocoder/react` to avoid double-wrapping strings that are already marked for translation.
|
|
119
68
|
|
|
120
69
|
## Git Integration
|
|
121
70
|
|