docs-i18n 0.8.0 → 0.8.2

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.
Files changed (80) hide show
  1. package/package.json +1 -1
  2. package/template/app/utils/content-loader.ts +4 -0
  3. package/template/app/utils/docs.server.ts +7 -0
  4. package/template/content/blog/en/announcing-query-v5.md +110 -0
  5. package/template/content/blog/en/hello-world.md +26 -0
  6. package/template/content/blog/en/i18n-best-practices.md +57 -0
  7. package/template/content/blog/en/react-query-vs-swr.md +100 -0
  8. package/template/content/blog/en/state-management-2024.md +143 -0
  9. package/template/content/blog/en/tanstack-router-1.0.md +121 -0
  10. package/template/content/blog/ja/announcing-query-v5.md +110 -0
  11. package/template/content/blog/ja/hello-world.md +26 -0
  12. package/template/content/blog/zh-hans/announcing-query-v5.md +93 -0
  13. package/template/content/blog/zh-hans/hello-world.md +26 -0
  14. package/template/content/docs-i18n/docs.config.json +25 -0
  15. package/template/content/docs-i18n/en/admin.md +143 -0
  16. package/template/content/docs-i18n/en/architecture.md +222 -0
  17. package/template/content/docs-i18n/en/cli.md +324 -0
  18. package/template/content/docs-i18n/en/configuration.md +331 -0
  19. package/template/content/docs-i18n/en/deployment.md +209 -0
  20. package/template/content/docs-i18n/en/getting-started.md +168 -0
  21. package/template/content/docs.config.json +25 -0
  22. package/template/content/en/admin.md +151 -0
  23. package/template/content/en/architecture.md +222 -0
  24. package/template/content/en/cli.md +269 -0
  25. package/template/content/en/configuration.md +331 -0
  26. package/template/content/en/deployment.md +209 -0
  27. package/template/content/en/getting-started.md +168 -0
  28. package/template/content/form/docs.config.json +18 -0
  29. package/template/content/form/en/guides/validation.md +175 -0
  30. package/template/content/form/en/installation.md +63 -0
  31. package/template/content/form/en/overview.md +71 -0
  32. package/template/content/form/en/quick-start.md +121 -0
  33. package/template/content/form/ja/installation.md +63 -0
  34. package/template/content/form/ja/overview.md +71 -0
  35. package/template/content/form/zh-hans/installation.md +63 -0
  36. package/template/content/form/zh-hans/overview.md +71 -0
  37. package/template/content/query/docs.config.json +32 -0
  38. package/template/content/query/en/guides/mutations.md +126 -0
  39. package/template/content/query/en/guides/pagination.md +98 -0
  40. package/template/content/query/en/guides/queries.md +120 -0
  41. package/template/content/query/en/installation.md +78 -0
  42. package/template/content/query/en/overview.md +72 -0
  43. package/template/content/query/en/quick-start.md +108 -0
  44. package/template/content/query/ja/installation.md +78 -0
  45. package/template/content/query/ja/overview.md +72 -0
  46. package/template/content/query/zh-hans/guides/mutations.md +126 -0
  47. package/template/content/query/zh-hans/guides/pagination.md +98 -0
  48. package/template/content/query/zh-hans/guides/queries.md +120 -0
  49. package/template/content/query/zh-hans/installation.md +95 -0
  50. package/template/content/query/zh-hans/overview.md +72 -0
  51. package/template/content/query/zh-hans/quick-start.md +108 -0
  52. package/template/content/router/docs.config.json +18 -0
  53. package/template/content/router/en/guides/routing-concepts.md +131 -0
  54. package/template/content/router/en/installation.md +57 -0
  55. package/template/content/router/en/overview.md +74 -0
  56. package/template/content/router/en/quick-start.md +88 -0
  57. package/template/content/router/ja/installation.md +57 -0
  58. package/template/content/router/ja/overview.md +78 -0
  59. package/template/content/router/zh-hans/guides/routing-concepts.md +131 -0
  60. package/template/content/router/zh-hans/installation.md +57 -0
  61. package/template/content/router/zh-hans/overview.md +81 -0
  62. package/template/content/router/zh-hans/quick-start.md +88 -0
  63. package/template/content/table/docs.config.json +18 -0
  64. package/template/content/table/en/guides/column-definitions.md +135 -0
  65. package/template/content/table/en/installation.md +56 -0
  66. package/template/content/table/en/overview.md +79 -0
  67. package/template/content/table/en/quick-start.md +112 -0
  68. package/template/content/table/ja/installation.md +56 -0
  69. package/template/content/table/ja/overview.md +79 -0
  70. package/template/content/table/zh-hans/installation.md +56 -0
  71. package/template/content/table/zh-hans/overview.md +79 -0
  72. package/template/content/virtual/docs.config.json +18 -0
  73. package/template/content/virtual/en/guides/dynamic-sizing.md +129 -0
  74. package/template/content/virtual/en/installation.md +57 -0
  75. package/template/content/virtual/en/overview.md +74 -0
  76. package/template/content/virtual/en/quick-start.md +114 -0
  77. package/template/content/virtual/ja/installation.md +57 -0
  78. package/template/content/virtual/ja/overview.md +74 -0
  79. package/template/content/virtual/zh-hans/installation.md +57 -0
  80. package/template/content/virtual/zh-hans/overview.md +74 -0
@@ -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
+ ```
@@ -0,0 +1,331 @@
1
+ ---
2
+ title: Configuration
3
+ description: Complete reference for the docs-i18n configuration file and all available options.
4
+ ---
5
+
6
+ # Configuration
7
+
8
+ docs-i18n is configured via a `docs-i18n.config.ts` file in your project root. Use the `defineConfig` helper for type safety.
9
+
10
+ ```ts
11
+ import { defineConfig } from 'docs-i18n';
12
+
13
+ export default defineConfig({
14
+ // ... options
15
+ });
16
+ ```
17
+
18
+ ## Full Config Reference
19
+
20
+ ```ts
21
+ interface DocsI18nConfig {
22
+ projects: Record<string, ProjectConfig>;
23
+ languages: string[];
24
+ cacheDir?: string;
25
+ translatableFields?: string[];
26
+ include?: string[];
27
+ context?: string;
28
+ llm?: {
29
+ provider?: 'openrouter' | 'openai' | 'anthropic';
30
+ model?: string;
31
+ apiKey?: string;
32
+ contextLength?: number;
33
+ maxTokens?: number;
34
+ };
35
+ onTranslated?: (info: {
36
+ project: string;
37
+ version: string;
38
+ lang: string;
39
+ }) => Promise<void>;
40
+ }
41
+
42
+ interface ProjectConfig {
43
+ sources: Record<string, string>;
44
+ }
45
+ ```
46
+
47
+ ## Options
48
+
49
+ ### `projects`
50
+
51
+ **Required.** A map of project IDs to their configuration. Each project has a `sources` object mapping version names to source directories (relative to project root).
52
+
53
+ ```ts
54
+ projects: {
55
+ mydocs: {
56
+ sources: {
57
+ latest: 'content/docs',
58
+ },
59
+ },
60
+ }
61
+ ```
62
+
63
+ The version key (e.g., `latest`, `v1`) is used to organize translations in the cache and in assembled output. The source path points to the directory containing your English markdown/MDX files.
64
+
65
+ **Single project:**
66
+
67
+ When you have a single project, version keys are used directly in the database and output paths (e.g., `latest`).
68
+
69
+ ```ts
70
+ projects: {
71
+ docs: {
72
+ sources: { latest: 'content/docs' },
73
+ },
74
+ }
75
+ ```
76
+
77
+ **Multi-project:**
78
+
79
+ When you have multiple projects, keys become compound: `project/version` (e.g., `query/latest`, `table/v1`).
80
+
81
+ ```ts
82
+ projects: {
83
+ query: {
84
+ sources: {
85
+ latest: 'content/query/latest',
86
+ v4: 'content/query/v4',
87
+ },
88
+ },
89
+ table: {
90
+ sources: {
91
+ latest: 'content/table/latest',
92
+ },
93
+ },
94
+ blog: {
95
+ sources: {
96
+ latest: 'content/blog',
97
+ },
98
+ },
99
+ }
100
+ ```
101
+
102
+ ### `languages`
103
+
104
+ **Required.** An array of target language codes to translate into. These codes are used as identifiers in the cache and output directories.
105
+
106
+ ```ts
107
+ languages: ['zh-hans', 'ja', 'es', 'ko', 'fr', 'de']
108
+ ```
109
+
110
+ Common language codes:
111
+
112
+ | Code | Language |
113
+ | --- | --- |
114
+ | `zh-hans` | Simplified Chinese |
115
+ | `zh-hant` | Traditional Chinese |
116
+ | `ja` | Japanese |
117
+ | `ko` | Korean |
118
+ | `es` | Spanish |
119
+ | `fr` | French |
120
+ | `de` | German |
121
+ | `pt` | Portuguese |
122
+ | `ru` | Russian |
123
+ | `ar` | Arabic |
124
+ | `vi` | Vietnamese |
125
+ | `hi` | Hindi |
126
+ | `th` | Thai |
127
+
128
+ ### `cacheDir`
129
+
130
+ **Optional.** Directory for the SQLite cache database and assembled output. Default: `'.cache'`.
131
+
132
+ ```ts
133
+ cacheDir: '.cache'
134
+ ```
135
+
136
+ The cache database is stored at `<cacheDir>/translations.db`. Assembled output files are written to `<cacheDir>/content/<version>/<lang>/`.
137
+
138
+ ### `translatableFields`
139
+
140
+ **Optional.** Frontmatter YAML fields to translate. Supports dot notation for nested fields. Default: `['title', 'description', 'nav_title']`.
141
+
142
+ ```ts
143
+ translatableFields: ['title', 'description', 'nav_title', 'related.title', 'related.description']
144
+ ```
145
+
146
+ When a frontmatter block is detected, only these fields are extracted and sent to the LLM as plain text. All other frontmatter fields are preserved unchanged. After translation, the frontmatter is reconstructed with translated values while maintaining original YAML formatting.
147
+
148
+ ### `include`
149
+
150
+ **Optional.** Glob patterns for files to include. Default: `['**/*.mdx', '**/*.md']`.
151
+
152
+ ```ts
153
+ include: ['**/*.mdx', '**/*.md']
154
+ ```
155
+
156
+ Files not matching these patterns are ignored during scanning, translation, and assembly.
157
+
158
+ ### `context`
159
+
160
+ **Optional.** Project context injected into the LLM system prompt. Use this to provide domain-specific information that helps the LLM produce better translations.
161
+
162
+ ```ts
163
+ context: 'TanStack Query is a data-fetching and state management library for React, Vue, Solid, and Angular. It was previously known as React Query.'
164
+ ```
165
+
166
+ This text is appended to the system prompt under a "CONTEXT" section, giving the LLM background about your project, terminology preferences, or naming conventions.
167
+
168
+ ### `llm`
169
+
170
+ **Optional.** LLM provider configuration.
171
+
172
+ ```ts
173
+ llm: {
174
+ provider: 'openrouter',
175
+ model: 'qwen/qwen3.5-flash-02-23',
176
+ apiKey: process.env.OPENROUTER_API_KEY,
177
+ contextLength: 1_000_000,
178
+ maxTokens: 65536,
179
+ }
180
+ ```
181
+
182
+ #### `llm.provider`
183
+
184
+ The API provider. Default: `'openrouter'`.
185
+
186
+ | Provider | Base URL | API Key Env Var |
187
+ | --- | --- | --- |
188
+ | `'openrouter'` | `https://openrouter.ai/api/v1` | `OPENROUTER_API_KEY` |
189
+ | `'openai'` | `https://api.deepseek.com` | `OPENAI_API_KEY` |
190
+ | `'anthropic'` | `https://api.anthropic.com/v1` | `ANTHROPIC_API_KEY` |
191
+
192
+ All providers use the OpenAI-compatible chat completions API.
193
+
194
+ #### `llm.model`
195
+
196
+ The model identifier. Defaults vary by provider:
197
+
198
+ - `openrouter`: `'deepseek/deepseek-chat-v3-0324:free'`
199
+ - `openai`: `'deepseek-chat'`
200
+ - `anthropic`: `'claude-sonnet-4-20250514'`
201
+
202
+ You can also override the model per command with `--model`.
203
+
204
+ #### `llm.apiKey`
205
+
206
+ API key for the provider. Falls back to the corresponding environment variable (`OPENROUTER_API_KEY`, `OPENAI_API_KEY`, or `ANTHROPIC_API_KEY`). Can also be overridden per command with `--api-key`.
207
+
208
+ #### `llm.contextLength`
209
+
210
+ Total context window of the model in tokens. Default: `32768`. Used to calculate how many translation nodes fit in a single API call. Set this to match your model's actual context window for optimal chunking.
211
+
212
+ #### `llm.maxTokens`
213
+
214
+ Maximum output tokens per API call. Default: `16384`. The actual output budget is calculated as `min(maxTokens, contextLength - 4096)`. The translator detects truncated output (when `finish_reason` is `'length'`) and retries.
215
+
216
+ ### `onTranslated`
217
+
218
+ **Optional.** Async callback invoked after translation completes for a project/version/language combination.
219
+
220
+ ```ts
221
+ onTranslated: async ({ project, version, lang }) => {
222
+ console.log(`Finished translating ${project}/${version} to ${lang}`);
223
+ // Trigger a build, send a notification, etc.
224
+ }
225
+ ```
226
+
227
+ ## Example Configurations
228
+
229
+ ### Simple single-project setup
230
+
231
+ ```ts
232
+ import { defineConfig } from 'docs-i18n';
233
+
234
+ export default defineConfig({
235
+ projects: {
236
+ docs: {
237
+ sources: { latest: 'docs' },
238
+ },
239
+ },
240
+ languages: ['zh-hans'],
241
+ llm: {
242
+ provider: 'openrouter',
243
+ apiKey: process.env.OPENROUTER_API_KEY,
244
+ model: 'deepseek/deepseek-chat-v3-0324:free',
245
+ },
246
+ });
247
+ ```
248
+
249
+ ### Multi-project monorepo (e.g., TanStack)
250
+
251
+ ```ts
252
+ import { defineConfig } from 'docs-i18n';
253
+
254
+ export default defineConfig({
255
+ projects: {
256
+ query: {
257
+ sources: {
258
+ latest: 'content/query/latest',
259
+ v4: 'content/query/v4',
260
+ },
261
+ },
262
+ table: {
263
+ sources: { latest: 'content/table/latest' },
264
+ },
265
+ router: {
266
+ sources: { latest: 'content/router/latest' },
267
+ },
268
+ blog: {
269
+ sources: { latest: 'content/blog' },
270
+ },
271
+ },
272
+ languages: ['zh-hans', 'ja', 'ko', 'es'],
273
+ cacheDir: '.cache',
274
+ translatableFields: ['title', 'description', 'nav_title'],
275
+ include: ['**/*.md'],
276
+ context: 'TanStack provides high-quality open-source libraries for web development including Query, Router, Table, and Form.',
277
+ llm: {
278
+ provider: 'openrouter',
279
+ model: 'qwen/qwen3.5-flash-02-23',
280
+ apiKey: process.env.OPENROUTER_API_KEY,
281
+ contextLength: 1_000_000,
282
+ maxTokens: 65536,
283
+ },
284
+ });
285
+ ```
286
+
287
+ ### Using Anthropic
288
+
289
+ ```ts
290
+ import { defineConfig } from 'docs-i18n';
291
+
292
+ export default defineConfig({
293
+ projects: {
294
+ docs: {
295
+ sources: { latest: 'content/docs' },
296
+ },
297
+ },
298
+ languages: ['ja', 'fr'],
299
+ llm: {
300
+ provider: 'anthropic',
301
+ model: 'claude-sonnet-4-20250514',
302
+ apiKey: process.env.ANTHROPIC_API_KEY,
303
+ contextLength: 200000,
304
+ maxTokens: 16384,
305
+ },
306
+ });
307
+ ```
308
+
309
+ ### With post-translation hook
310
+
311
+ ```ts
312
+ import { defineConfig } from 'docs-i18n';
313
+ import { exec } from 'node:child_process';
314
+
315
+ export default defineConfig({
316
+ projects: {
317
+ docs: {
318
+ sources: { latest: 'content/docs' },
319
+ },
320
+ },
321
+ languages: ['zh-hans'],
322
+ llm: {
323
+ provider: 'openrouter',
324
+ apiKey: process.env.OPENROUTER_API_KEY,
325
+ },
326
+ onTranslated: async ({ project, version, lang }) => {
327
+ // Rebuild the site after translation
328
+ exec('npm run build');
329
+ },
330
+ });
331
+ ```