docs-i18n 0.8.0 → 0.8.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.
|
@@ -15556,26 +15556,6 @@ async function getStartManifest(matchedRoutes) {
|
|
|
15556
15556
|
//#endregion
|
|
15557
15557
|
//#region \0#tanstack-start-server-fn-resolver
|
|
15558
15558
|
var manifest = {
|
|
15559
|
-
"a3d81974aeece150d4b02be5b91590b8187442ebea56be4a89dcbf053626d22b": {
|
|
15560
|
-
functionName: "fetchVersion_createServerFn_handler",
|
|
15561
|
-
importer: () => import("./assets/misc-y6t3-UOP.js")
|
|
15562
|
-
},
|
|
15563
|
-
"3bf4ba50ca8ccc3c8c60d8f2e53307a320940d68c478df494552066904c5cd74": {
|
|
15564
|
-
functionName: "fetchLlmConfig_createServerFn_handler",
|
|
15565
|
-
importer: () => import("./assets/misc-y6t3-UOP.js")
|
|
15566
|
-
},
|
|
15567
|
-
"e0b4116f6b2c8d096830102e36458acf9c616a056fcdddda956a4d66984ef58c": {
|
|
15568
|
-
functionName: "fetchConfig_createServerFn_handler",
|
|
15569
|
-
importer: () => import("./assets/misc-y6t3-UOP.js")
|
|
15570
|
-
},
|
|
15571
|
-
"a054a04356fe9987891efee8b7a11cd2dedb00f6b2e8f26d1c642e001e553d53": {
|
|
15572
|
-
functionName: "openFile_createServerFn_handler",
|
|
15573
|
-
importer: () => import("./assets/misc-y6t3-UOP.js")
|
|
15574
|
-
},
|
|
15575
|
-
"5080dc3f2f2309ec6981b94c431969637130c657e8a1dfb10400b4614eecc1ea": {
|
|
15576
|
-
functionName: "fetchModels_createServerFn_handler",
|
|
15577
|
-
importer: () => import("./assets/models-YNa3F3nn.js")
|
|
15578
|
-
},
|
|
15579
15559
|
"4e218d79545765572808c7eab33b7663d4496209c15406d0b449366905b6b83f": {
|
|
15580
15560
|
functionName: "fetchStatus_createServerFn_handler",
|
|
15581
15561
|
importer: () => import("./assets/status-CM7Azp4n.js")
|
|
@@ -15596,6 +15576,10 @@ var manifest = {
|
|
|
15596
15576
|
functionName: "rescanVersion_createServerFn_handler",
|
|
15597
15577
|
importer: () => import("./assets/status-CM7Azp4n.js")
|
|
15598
15578
|
},
|
|
15579
|
+
"5080dc3f2f2309ec6981b94c431969637130c657e8a1dfb10400b4614eecc1ea": {
|
|
15580
|
+
functionName: "fetchModels_createServerFn_handler",
|
|
15581
|
+
importer: () => import("./assets/models-YNa3F3nn.js")
|
|
15582
|
+
},
|
|
15599
15583
|
"421de02ce39dde6e27cf4689e837ec072cbd01e63f8cdd5c2a3f42f0bd5ca613": {
|
|
15600
15584
|
functionName: "fetchJobs_createServerFn_handler",
|
|
15601
15585
|
importer: () => import("./assets/jobs-FXffC7LH.js")
|
|
@@ -15611,6 +15595,22 @@ var manifest = {
|
|
|
15611
15595
|
"88c2855c84e91504070bfecc50ddfa50339d22c305626800b6d9b05d79385d71": {
|
|
15612
15596
|
functionName: "deleteJob_createServerFn_handler",
|
|
15613
15597
|
importer: () => import("./assets/jobs-FXffC7LH.js")
|
|
15598
|
+
},
|
|
15599
|
+
"a3d81974aeece150d4b02be5b91590b8187442ebea56be4a89dcbf053626d22b": {
|
|
15600
|
+
functionName: "fetchVersion_createServerFn_handler",
|
|
15601
|
+
importer: () => import("./assets/misc-y6t3-UOP.js")
|
|
15602
|
+
},
|
|
15603
|
+
"3bf4ba50ca8ccc3c8c60d8f2e53307a320940d68c478df494552066904c5cd74": {
|
|
15604
|
+
functionName: "fetchLlmConfig_createServerFn_handler",
|
|
15605
|
+
importer: () => import("./assets/misc-y6t3-UOP.js")
|
|
15606
|
+
},
|
|
15607
|
+
"e0b4116f6b2c8d096830102e36458acf9c616a056fcdddda956a4d66984ef58c": {
|
|
15608
|
+
functionName: "fetchConfig_createServerFn_handler",
|
|
15609
|
+
importer: () => import("./assets/misc-y6t3-UOP.js")
|
|
15610
|
+
},
|
|
15611
|
+
"a054a04356fe9987891efee8b7a11cd2dedb00f6b2e8f26d1c642e001e553d53": {
|
|
15612
|
+
functionName: "openFile_createServerFn_handler",
|
|
15613
|
+
importer: () => import("./assets/misc-y6t3-UOP.js")
|
|
15614
15614
|
}
|
|
15615
15615
|
};
|
|
15616
15616
|
async function getServerFnById(id) {
|
package/package.json
CHANGED
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Admin Dashboard
|
|
3
|
+
description: Web UI for monitoring translation progress, managing translation jobs, previewing files, and browsing LLM models.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Admin Dashboard
|
|
7
|
+
|
|
8
|
+
The docs-i18n admin dashboard is a web-based UI for managing your translations. It is built with TanStack Start and React, and runs as a local development server.
|
|
9
|
+
|
|
10
|
+
## Starting the Dashboard
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
npx docs-i18n admin
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
The dashboard opens at `http://localhost:3456`. Use `--port` to change the port:
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npx docs-i18n admin --port 4000
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
The dashboard reads your `docs-i18n.config.ts` to discover projects, versions, and languages. The admin is pre-built and requires no additional dependencies.
|
|
23
|
+
|
|
24
|
+
## Features
|
|
25
|
+
|
|
26
|
+
### Translation Overview
|
|
27
|
+
|
|
28
|
+
The main dashboard page shows a grid of all versions and languages with translation progress. For each version/language pair, you see:
|
|
29
|
+
|
|
30
|
+
- Total number of source nodes (EN content units).
|
|
31
|
+
- Number of translated nodes.
|
|
32
|
+
- Percentage complete.
|
|
33
|
+
- Breakdown by section (e.g., `docs/`, `blog/`, `learn/`), showing file counts and node counts per section.
|
|
34
|
+
|
|
35
|
+
English is always shown as 100% complete since it is the source language.
|
|
36
|
+
|
|
37
|
+
The overview auto-scans source files on load. If source files have not been scanned yet, the dashboard triggers a scan automatically.
|
|
38
|
+
|
|
39
|
+
### File Browser
|
|
40
|
+
|
|
41
|
+
Clicking on a version/language cell opens a file-level coverage list. Each file shows:
|
|
42
|
+
|
|
43
|
+
- File path (relative to the source directory).
|
|
44
|
+
- Total translatable nodes in that file.
|
|
45
|
+
- Number of translated nodes.
|
|
46
|
+
|
|
47
|
+
Files are sorted by path. You can click on any file to open the block-level preview.
|
|
48
|
+
|
|
49
|
+
### File Preview
|
|
50
|
+
|
|
51
|
+
The file preview shows every block (AST node) in a file side by side:
|
|
52
|
+
|
|
53
|
+
- **Source** -- the original English text.
|
|
54
|
+
- **Translation** -- the cached translation for the selected language, or empty if not yet translated.
|
|
55
|
+
|
|
56
|
+
Each block displays its type (heading, paragraph, list, blockquote, frontmatter, code, html) and MD5 key. Non-translatable blocks (code, pure HTML tags, gaps between nodes) are shown but clearly distinguished.
|
|
57
|
+
|
|
58
|
+
### Cache Management
|
|
59
|
+
|
|
60
|
+
From the file preview, you can delete individual cache entries. This is useful when a translation is incorrect and you want to re-translate a specific node. After deleting, run the translate command again to get a fresh translation for that key.
|
|
61
|
+
|
|
62
|
+
The dashboard also supports rescanning source files for a specific version via the UI. This rebuilds the source index and cleans orphaned entries.
|
|
63
|
+
|
|
64
|
+
### Translation Jobs
|
|
65
|
+
|
|
66
|
+
The dashboard includes a job management system for running translations directly from the UI instead of the command line.
|
|
67
|
+
|
|
68
|
+
#### Creating a Job
|
|
69
|
+
|
|
70
|
+
Click the job creation button and configure:
|
|
71
|
+
|
|
72
|
+
- **Language** -- target language code.
|
|
73
|
+
- **Version** -- which version to translate.
|
|
74
|
+
- **Project** -- optionally filter to a specific project.
|
|
75
|
+
- **Model** -- LLM model to use (can be selected from the model browser).
|
|
76
|
+
- **Model rotation** -- optionally provide multiple models to rotate through.
|
|
77
|
+
- **Max chunks** -- limit the number of API call chunks.
|
|
78
|
+
- **Concurrency** -- number of parallel API calls (default: 3).
|
|
79
|
+
- **Files** -- optionally select specific files to translate.
|
|
80
|
+
|
|
81
|
+
#### Job Status
|
|
82
|
+
|
|
83
|
+
Running jobs show:
|
|
84
|
+
|
|
85
|
+
- Status: `running`, `completed`, `failed`, or `cancelled`.
|
|
86
|
+
- Start time and finish time.
|
|
87
|
+
- Number of translated chunks and total chunks.
|
|
88
|
+
- Current chunk being processed.
|
|
89
|
+
- Live log output (last 20 lines displayed, up to 500 lines stored).
|
|
90
|
+
|
|
91
|
+
You can cancel a running job, which sends SIGTERM to the translation process. Completed or failed jobs can be removed from the list.
|
|
92
|
+
|
|
93
|
+
#### How Jobs Work
|
|
94
|
+
|
|
95
|
+
Under the hood, the job manager spawns a child process running the `docs-i18n translate` CLI command with the configured options. It captures stdout and stderr, parses progress information from the output, and exposes it through the dashboard API. The child process inherits the API key from your config or environment variables.
|
|
96
|
+
|
|
97
|
+
### Model Browser
|
|
98
|
+
|
|
99
|
+
The dashboard includes an OpenRouter model browser that fetches the list of available models from the OpenRouter API. For each model, it displays:
|
|
100
|
+
|
|
101
|
+
- Model ID and name.
|
|
102
|
+
- Pricing (prompt and completion per million tokens).
|
|
103
|
+
- Context length and maximum output tokens.
|
|
104
|
+
- Whether the model supports JSON response format and tool use.
|
|
105
|
+
- Provider name.
|
|
106
|
+
- Whether the model is free.
|
|
107
|
+
|
|
108
|
+
The model list is cached for 5 minutes. It only shows text-to-text models (filtered by architecture modality) and excludes models with negative pricing. Models are sorted by prompt price (cheapest first).
|
|
109
|
+
|
|
110
|
+
This is useful for selecting a model when creating a translation job.
|
|
111
|
+
|
|
112
|
+
### Open in Editor
|
|
113
|
+
|
|
114
|
+
The dashboard can open source files in your local editor. It tries the following editors in order:
|
|
115
|
+
|
|
116
|
+
1. The value of the `EDITOR_CMD` environment variable (if set).
|
|
117
|
+
2. `code` (VS Code)
|
|
118
|
+
3. `cursor` (Cursor)
|
|
119
|
+
4. `zed` (Zed)
|
|
120
|
+
|
|
121
|
+
If none are found, it falls back to the system default (`open` on macOS, `xdg-open` on Linux, `start` on Windows).
|
|
122
|
+
|
|
123
|
+
## Architecture
|
|
124
|
+
|
|
125
|
+
The admin dashboard uses:
|
|
126
|
+
|
|
127
|
+
- **TanStack Start** -- Full-stack React framework with server functions.
|
|
128
|
+
- **TanStack React Query** -- For data fetching and cache management.
|
|
129
|
+
- **TanStack Router** -- For client-side routing.
|
|
130
|
+
- **Vite** -- Dev server and build tool.
|
|
131
|
+
- **Hono** -- HTTP server (used by TanStack Start internally).
|
|
132
|
+
|
|
133
|
+
Server functions are defined in `packages/admin/server/functions/` and handle:
|
|
134
|
+
|
|
135
|
+
- `fetchStatus` / `fetchFileCoverage` / `fetchFileBlocks` -- Read translation status from SQLite.
|
|
136
|
+
- `deleteCacheEntry` -- Delete a specific translation from the cache.
|
|
137
|
+
- `rescanVersion` -- Rescan source files for a version.
|
|
138
|
+
- `createJob` / `fetchJobs` / `fetchJob` / `deleteJob` -- Manage translation jobs.
|
|
139
|
+
- `fetchModels` -- Fetch available models from OpenRouter.
|
|
140
|
+
- `fetchVersion` / `fetchConfig` -- Get docs-i18n version and project root.
|
|
141
|
+
- `openFile` -- Open a file in the local editor.
|
|
142
|
+
|
|
143
|
+
The dashboard shares the same `TranslationCache` and `parseMdx` functions as the CLI, ensuring consistent behavior.
|
|
@@ -0,0 +1,324 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: CLI Reference
|
|
3
|
+
description: Complete reference for all docs-i18n CLI commands, flags, and common workflows.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# CLI Reference
|
|
7
|
+
|
|
8
|
+
docs-i18n provides a command-line interface for managing documentation translations. All commands read from `docs-i18n.config.ts` in the current working directory by default.
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
docs-i18n <command> [options]
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## Global Options
|
|
15
|
+
|
|
16
|
+
| Flag | Description |
|
|
17
|
+
| --- | --- |
|
|
18
|
+
| `--config <path>` | Path to config file (default: `docs-i18n.config.ts`) |
|
|
19
|
+
| `--version`, `-v` | Print the docs-i18n version |
|
|
20
|
+
| `--help`, `-h` | Show help text |
|
|
21
|
+
|
|
22
|
+
## Commands
|
|
23
|
+
|
|
24
|
+
### `translate`
|
|
25
|
+
|
|
26
|
+
Translate content to a target language. Sends untranslated nodes to the configured LLM and caches the results.
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
docs-i18n translate --lang <code> [options]
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
**Required:**
|
|
33
|
+
|
|
34
|
+
| Flag | Description |
|
|
35
|
+
| --- | --- |
|
|
36
|
+
| `--lang <code>` | Target language code (e.g., `zh-hans`, `ja`, `es`) |
|
|
37
|
+
|
|
38
|
+
**Optional:**
|
|
39
|
+
|
|
40
|
+
| Flag | Default | Description |
|
|
41
|
+
| --- | --- | --- |
|
|
42
|
+
| `--project <id>` | all projects | Filter to a specific project |
|
|
43
|
+
| `--version <ver>` | all versions | Filter to a specific version |
|
|
44
|
+
| `--files <paths>` | all files | Comma-separated list of relative file paths to translate |
|
|
45
|
+
| `--max <n>` | 999 | Maximum number of API call chunks to process |
|
|
46
|
+
| `--concurrency <n>` | 3 | Number of parallel API calls |
|
|
47
|
+
| `--model <model>` | config value | Override the LLM model |
|
|
48
|
+
| `--api-key <key>` | config/env | Override the API key |
|
|
49
|
+
| `--max-tokens <n>` | 16384 | Max output tokens per API call |
|
|
50
|
+
| `--context-length <n>` | 32768 | Model context window size |
|
|
51
|
+
| `--dry-run` | false | Preview what would be translated without making API calls |
|
|
52
|
+
|
|
53
|
+
**Examples:**
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
# Translate everything to Simplified Chinese
|
|
57
|
+
docs-i18n translate --lang zh-hans
|
|
58
|
+
|
|
59
|
+
# Translate a specific version with dry run
|
|
60
|
+
docs-i18n translate --lang zh-hans --version latest --dry-run
|
|
61
|
+
|
|
62
|
+
# Translate specific files only
|
|
63
|
+
docs-i18n translate --lang zh-hans --files docs/intro.mdx,docs/guide.mdx
|
|
64
|
+
|
|
65
|
+
# Use a different model with higher token limits
|
|
66
|
+
docs-i18n translate --lang ja --model qwen/qwen3.5-flash-02-23 --max-tokens 65536 --context-length 1000000
|
|
67
|
+
|
|
68
|
+
# Limit API calls for testing
|
|
69
|
+
docs-i18n translate --lang es --max 5 --concurrency 1
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
**How it works:**
|
|
73
|
+
|
|
74
|
+
1. Loads the SQLite cache and finds all untranslated keys for the given language and version.
|
|
75
|
+
2. Groups untranslated nodes into chunks that fit within the model's context window, accounting for input tokens, output tokens, and language-specific token multipliers (e.g., Japanese uses 2.5x more output tokens than English).
|
|
76
|
+
3. Sends each chunk to the LLM as structured JSON: an array of typed nodes with MD5 keys.
|
|
77
|
+
4. Parses the JSON response, validates keys, and stores translations in the cache.
|
|
78
|
+
5. Runs chunks in parallel up to the concurrency limit.
|
|
79
|
+
|
|
80
|
+
Translation logs are written to `.logs/` with timestamps for debugging.
|
|
81
|
+
|
|
82
|
+
---
|
|
83
|
+
|
|
84
|
+
### `assemble`
|
|
85
|
+
|
|
86
|
+
Assemble translated files by combining English source content with cached translations. For any untranslated nodes, the original English text is used as a fallback.
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
docs-i18n assemble [options]
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
**Optional:**
|
|
93
|
+
|
|
94
|
+
| Flag | Default | Description |
|
|
95
|
+
| --- | --- | --- |
|
|
96
|
+
| `--project <id>` | all projects | Filter to a specific project |
|
|
97
|
+
| `--version <ver>` | all versions | Filter to a specific version |
|
|
98
|
+
| `--lang <code>` | all languages | Filter to a specific language |
|
|
99
|
+
|
|
100
|
+
**Examples:**
|
|
101
|
+
|
|
102
|
+
```bash
|
|
103
|
+
# Assemble all projects, versions, and languages
|
|
104
|
+
docs-i18n assemble
|
|
105
|
+
|
|
106
|
+
# Assemble only Chinese for the latest version
|
|
107
|
+
docs-i18n assemble --lang zh-hans --version latest
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
Output is written to `.cache/content/<version>/<lang>/` by default. Each file mirrors the structure of the English source directory.
|
|
111
|
+
|
|
112
|
+
---
|
|
113
|
+
|
|
114
|
+
### `rescan`
|
|
115
|
+
|
|
116
|
+
Rescan source files and rebuild the source index. Also cleans orphaned translations and sources that no longer exist in the source files.
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
docs-i18n rescan [options]
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
**Optional:**
|
|
123
|
+
|
|
124
|
+
| Flag | Default | Description |
|
|
125
|
+
| --- | --- | --- |
|
|
126
|
+
| `--project <id>` | all projects | Filter to a specific project |
|
|
127
|
+
| `--version <ver>` | all versions | Filter to a specific version |
|
|
128
|
+
|
|
129
|
+
**Examples:**
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
# Rescan all source files
|
|
133
|
+
docs-i18n rescan
|
|
134
|
+
|
|
135
|
+
# Rescan a specific version only
|
|
136
|
+
docs-i18n rescan --version latest
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
**What it does:**
|
|
140
|
+
|
|
141
|
+
1. Walks all source directories and parses every markdown/MDX file.
|
|
142
|
+
2. Extracts translatable nodes and stores their MD5 keys, source text, node types, file paths, and line numbers in the SQLite cache.
|
|
143
|
+
3. Deletes orphaned translations whose source keys no longer exist in any source file.
|
|
144
|
+
4. Deletes orphaned source entries that are no longer referenced by any file.
|
|
145
|
+
|
|
146
|
+
Run `rescan` after adding, removing, or significantly editing source files.
|
|
147
|
+
|
|
148
|
+
---
|
|
149
|
+
|
|
150
|
+
### `status`
|
|
151
|
+
|
|
152
|
+
Show translation coverage for all projects and versions.
|
|
153
|
+
|
|
154
|
+
```bash
|
|
155
|
+
docs-i18n status [options]
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
**Optional:**
|
|
159
|
+
|
|
160
|
+
| Flag | Default | Description |
|
|
161
|
+
| --- | --- | --- |
|
|
162
|
+
| `--lang <code>` | all languages | Show status for a specific language only |
|
|
163
|
+
|
|
164
|
+
**Examples:**
|
|
165
|
+
|
|
166
|
+
```bash
|
|
167
|
+
# Show status for all languages
|
|
168
|
+
docs-i18n status
|
|
169
|
+
|
|
170
|
+
# Show status for Chinese only
|
|
171
|
+
docs-i18n status --lang zh-hans
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
**Output:**
|
|
175
|
+
|
|
176
|
+
```
|
|
177
|
+
Translation Status
|
|
178
|
+
|
|
179
|
+
latest (1523 keys):
|
|
180
|
+
zh-hans ████████████████████ 100% (1523/1523)
|
|
181
|
+
ja ████████████░░░░░░░░ 62% (944/1523)
|
|
182
|
+
es ██░░░░░░░░░░░░░░░░░░ 10% (152/1523)
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
If a version shows "no source files (run rescan first)", you need to run `docs-i18n rescan` before checking status.
|
|
186
|
+
|
|
187
|
+
---
|
|
188
|
+
|
|
189
|
+
### `admin`
|
|
190
|
+
|
|
191
|
+
Start the admin dashboard web UI for managing translations.
|
|
192
|
+
|
|
193
|
+
```bash
|
|
194
|
+
docs-i18n admin [options]
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
**Optional:**
|
|
198
|
+
|
|
199
|
+
| Flag | Default | Description |
|
|
200
|
+
| --- | --- | --- |
|
|
201
|
+
| `--port <n>` | 3456 | Port to run the dashboard on |
|
|
202
|
+
|
|
203
|
+
**Examples:**
|
|
204
|
+
|
|
205
|
+
```bash
|
|
206
|
+
# Start on default port
|
|
207
|
+
docs-i18n admin
|
|
208
|
+
|
|
209
|
+
# Start on custom port
|
|
210
|
+
docs-i18n admin --port 4000
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
The dashboard opens at `http://localhost:3456` (or your custom port). See the [Admin Dashboard](./admin.md) documentation for details on its features.
|
|
214
|
+
|
|
215
|
+
---
|
|
216
|
+
|
|
217
|
+
### `site`
|
|
218
|
+
|
|
219
|
+
Manage the documentation site. Built with TanStack Start and supports dev server, production build, content upload to D1, and deployment to Cloudflare Workers.
|
|
220
|
+
|
|
221
|
+
```bash
|
|
222
|
+
docs-i18n site [subcommand] [options]
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
**Subcommands:**
|
|
226
|
+
|
|
227
|
+
| Subcommand | Description |
|
|
228
|
+
| --- | --- |
|
|
229
|
+
| `dev` (default) | Start the Vite dev server with hot reload |
|
|
230
|
+
| `build` | Build the site for production |
|
|
231
|
+
| `upload` | Upload content and translations to Cloudflare D1 |
|
|
232
|
+
| `deploy` | Deploy to Cloudflare Workers |
|
|
233
|
+
|
|
234
|
+
**Optional:**
|
|
235
|
+
|
|
236
|
+
| Flag | Default | Description |
|
|
237
|
+
| --- | --- | --- |
|
|
238
|
+
| `--port <n>` | 3000 | Port for the dev server |
|
|
239
|
+
| `--db <name>` | `docs-i18n-db` | D1 database name (for `upload`) |
|
|
240
|
+
|
|
241
|
+
**Examples:**
|
|
242
|
+
|
|
243
|
+
```bash
|
|
244
|
+
# Start dev server
|
|
245
|
+
docs-i18n site
|
|
246
|
+
|
|
247
|
+
# Start on custom port
|
|
248
|
+
docs-i18n site dev --port 4000
|
|
249
|
+
|
|
250
|
+
# Build for production
|
|
251
|
+
docs-i18n site build
|
|
252
|
+
|
|
253
|
+
# Upload content to D1
|
|
254
|
+
docs-i18n site upload --db my-docs-db
|
|
255
|
+
|
|
256
|
+
# Deploy to Cloudflare Workers
|
|
257
|
+
docs-i18n site deploy
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
**How it works:**
|
|
261
|
+
|
|
262
|
+
The `site` command does not require a `docs-i18n.config.ts`. It reads the `site.config.ts` file from your project root to configure the documentation site (project names, colors, locales, etc.).
|
|
263
|
+
|
|
264
|
+
On first run, the template's dependencies are automatically installed. The dev server uses Vite with the consumer's `site.config.ts` aliased into the template for customization.
|
|
265
|
+
|
|
266
|
+
For non-English languages, the site automatically loads translations from the `.cache/translations.db` SQLite cache and assembles them at runtime.
|
|
267
|
+
|
|
268
|
+
---
|
|
269
|
+
|
|
270
|
+
## Common Workflows
|
|
271
|
+
|
|
272
|
+
### Full translation pipeline
|
|
273
|
+
|
|
274
|
+
```bash
|
|
275
|
+
# 1. Scan source files
|
|
276
|
+
docs-i18n rescan
|
|
277
|
+
|
|
278
|
+
# 2. Check what needs translating
|
|
279
|
+
docs-i18n status
|
|
280
|
+
|
|
281
|
+
# 3. Translate
|
|
282
|
+
docs-i18n translate --lang zh-hans
|
|
283
|
+
|
|
284
|
+
# 4. Assemble output
|
|
285
|
+
docs-i18n assemble --lang zh-hans
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
### Translate a single file for review
|
|
289
|
+
|
|
290
|
+
```bash
|
|
291
|
+
docs-i18n translate --lang zh-hans --files docs/getting-started.mdx --max 1
|
|
292
|
+
docs-i18n assemble --lang zh-hans
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
### Preview translation volume before spending API credits
|
|
296
|
+
|
|
297
|
+
```bash
|
|
298
|
+
docs-i18n translate --lang ja --dry-run
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
This reports the number of untranslated keys and chunks without making any API calls.
|
|
302
|
+
|
|
303
|
+
### Multi-project translation
|
|
304
|
+
|
|
305
|
+
```bash
|
|
306
|
+
# Translate only the "query" project
|
|
307
|
+
docs-i18n translate --lang zh-hans --project query
|
|
308
|
+
|
|
309
|
+
# Assemble only the "table" project
|
|
310
|
+
docs-i18n assemble --project table --lang zh-hans
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
### After editing source files
|
|
314
|
+
|
|
315
|
+
```bash
|
|
316
|
+
# Rescan to detect changes and clean orphans
|
|
317
|
+
docs-i18n rescan
|
|
318
|
+
|
|
319
|
+
# Translate only new/changed content (cached translations are reused)
|
|
320
|
+
docs-i18n translate --lang zh-hans
|
|
321
|
+
|
|
322
|
+
# Rebuild output files
|
|
323
|
+
docs-i18n assemble
|
|
324
|
+
```
|