docs-i18n 0.6.3 → 0.7.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/{src/admin/ui → admin/app}/components/JobDialog.tsx +21 -2
- package/{src/admin/ui → admin/app}/components/JobPanel.tsx +1 -1
- package/{src/admin/ui → admin/app}/components/Preview.tsx +2 -5
- package/{src/admin/ui → admin/app}/lib/api.ts +18 -39
- package/admin/app/routeTree.gen.ts +68 -0
- package/admin/app/router.tsx +23 -0
- package/admin/app/routes/__root.tsx +55 -0
- package/admin/app/routes/index.tsx +416 -0
- package/{src/admin/ui → admin/app}/styles.css +36 -3
- package/admin/package.json +26 -0
- package/admin/server/functions/jobs.ts +53 -0
- package/admin/server/functions/misc.ts +84 -0
- package/{src/admin/server/routes → admin/server/functions}/models.ts +16 -29
- package/admin/server/functions/status.ts +61 -0
- package/admin/server/index.ts +35 -0
- package/admin/server/init.ts +46 -0
- package/{src/admin → admin}/server/services/job-manager.ts +39 -10
- package/{src/admin → admin}/server/services/status.ts +6 -6
- package/admin/tsconfig.json +19 -0
- package/{src/admin → admin}/vite.config.ts +8 -2
- package/dist/{assemble-7H4QCW35.js → assemble-CP2BRYQJ.js} +6 -4
- package/dist/{chunk-A3YQNPKZ.js → chunk-CLYUAWZE.js} +1 -1
- package/dist/{chunk-YN4VJHCQ.js → chunk-JHBSHTXC.js} +1 -1
- package/dist/chunk-L64GJ4OB.js +32 -0
- package/dist/{chunk-SKKZIV3L.js → chunk-PNKVD2UK.js} +1 -29
- package/dist/{chunk-XEOYZUHS.js → chunk-QKIR7RKQ.js} +4 -31
- package/dist/chunk-TRURQFP4.js +31 -0
- package/dist/cli.js +108 -7
- package/dist/index.d.ts +41 -1
- package/dist/index.js +92 -3
- package/dist/{rescan-O5D3CYC2.js → rescan-HXMWFAOC.js} +5 -3
- package/dist/{status-F4MYIAAY.js → status-AGZDXOTZ.js} +4 -2
- package/dist/{translate-ZIVKNAC4.js → translate-A5X6MX4Y.js} +14 -7
- package/dist/upload-XL6KG6S2.js +132 -0
- package/package.json +17 -15
- package/template/app/components/BlogArticle.tsx +159 -0
- package/template/app/components/BlogList.tsx +88 -0
- package/template/app/components/Breadcrumbs.tsx +81 -0
- package/template/app/components/Card.tsx +31 -0
- package/template/app/components/Doc.tsx +191 -0
- package/template/app/components/DocBreadcrumb.tsx +60 -0
- package/template/app/components/DocContainer.tsx +13 -0
- package/template/app/components/DocTitle.tsx +11 -0
- package/template/app/components/DocsLayout.tsx +715 -0
- package/template/app/components/Dropdown.tsx +116 -0
- package/template/app/components/FallbackBanner.tsx +36 -0
- package/template/app/components/Footer.tsx +29 -0
- package/template/app/components/FrameworkSelect.tsx +150 -0
- package/template/app/components/LibraryCard.tsx +178 -0
- package/template/app/components/LocaleSwitcher.tsx +43 -0
- package/template/app/components/Navbar.tsx +430 -0
- package/template/app/components/PostNotFound.tsx +20 -0
- package/template/app/components/SearchButton.tsx +32 -0
- package/template/app/components/Select.tsx +103 -0
- package/template/app/components/Spinner.tsx +18 -0
- package/template/app/components/ThemeProvider.tsx +141 -0
- package/template/app/components/ThemeToggle.tsx +31 -0
- package/template/app/components/Toc.tsx +86 -0
- package/template/app/components/VersionSelect.tsx +118 -0
- package/template/app/components/icons/BSkyIcon.tsx +27 -0
- package/template/app/components/icons/BaseballCapIcon.tsx +25 -0
- package/template/app/components/icons/BrandXIcon.tsx +28 -0
- package/template/app/components/icons/CheckCircleIcon.tsx +28 -0
- package/template/app/components/icons/CogsIcon.tsx +25 -0
- package/template/app/components/icons/DiscordIcon.tsx +24 -0
- package/template/app/components/icons/GithubIcon.tsx +24 -0
- package/template/app/components/icons/GoogleIcon.tsx +24 -0
- package/template/app/components/icons/InstagramIcon.tsx +24 -0
- package/template/app/components/icons/NpmIcon.tsx +26 -0
- package/template/app/components/icons/YinYangIcon.tsx +26 -0
- package/template/app/components/icons/YouTubeIcon.tsx +24 -0
- package/template/app/components/markdown/CodeBlock.tsx +254 -0
- package/template/app/components/markdown/FileTabs.tsx +58 -0
- package/template/app/components/markdown/FrameworkContent.tsx +76 -0
- package/template/app/components/markdown/Markdown.tsx +216 -0
- package/template/app/components/markdown/MarkdownContent.tsx +89 -0
- package/template/app/components/markdown/MarkdownFrameworkHandler.tsx +66 -0
- package/template/app/components/markdown/MarkdownHeadingContext.tsx +35 -0
- package/template/app/components/markdown/MarkdownLink.tsx +46 -0
- package/template/app/components/markdown/MarkdownTabsHandler.tsx +109 -0
- package/template/app/components/markdown/PackageManagerTabs.tsx +95 -0
- package/template/app/components/markdown/Tabs.tsx +139 -0
- package/template/app/components/markdown/index.ts +15 -0
- package/template/app/components/ui/Button.tsx +141 -0
- package/template/app/components/ui/InlineCode.tsx +16 -0
- package/template/app/components/ui/MarkdownImg.tsx +21 -0
- package/template/app/config/frameworks.ts +93 -0
- package/template/app/contexts/SearchContext.tsx +36 -0
- package/template/app/db/index.ts +17 -0
- package/template/app/db/schema.ts +74 -0
- package/template/app/hooks/useClickOutside.ts +106 -0
- package/template/app/routeTree.gen.ts +584 -0
- package/template/app/router.tsx +29 -0
- package/template/app/routes/$lang.$project.$version.docs.$.tsx +128 -0
- package/template/app/routes/$lang.$project.$version.docs.framework.$framework.$.tsx +106 -0
- package/template/app/routes/$lang.$project.$version.docs.framework.$framework.index.tsx +27 -0
- package/template/app/routes/$lang.$project.$version.docs.framework.index.tsx +44 -0
- package/template/app/routes/$lang.$project.$version.docs.index.tsx +27 -0
- package/template/app/routes/$lang.$project.$version.docs.tsx +70 -0
- package/template/app/routes/$lang.$project.$version.tsx +69 -0
- package/template/app/routes/$lang.$project.docs.$.tsx +104 -0
- package/template/app/routes/$lang.$project.docs.index.tsx +20 -0
- package/template/app/routes/$lang.$project.docs.tsx +79 -0
- package/template/app/routes/$lang.$project.tsx +89 -0
- package/template/app/routes/$lang.blog.$.tsx +82 -0
- package/template/app/routes/$lang.blog.index.tsx +56 -0
- package/template/app/routes/$lang.blog.tsx +26 -0
- package/template/app/routes/$lang.docs.$.tsx +100 -0
- package/template/app/routes/$lang.docs.framework.$framework.$.tsx +104 -0
- package/template/app/routes/$lang.docs.framework.$framework.index.tsx +32 -0
- package/template/app/routes/$lang.docs.framework.index.tsx +47 -0
- package/template/app/routes/$lang.docs.index.tsx +20 -0
- package/template/app/routes/$lang.docs.tsx +90 -0
- package/template/app/routes/$lang.tsx +16 -0
- package/template/app/routes/__root.tsx +180 -0
- package/template/app/routes/index.tsx +89 -0
- package/template/app/site.config.ts +182 -0
- package/template/app/styles/app.css +1029 -0
- package/template/app/types/index.ts +77 -0
- package/template/app/utils/blog.server.ts +193 -0
- package/template/app/utils/blog.ts +42 -0
- package/template/app/utils/config.ts +120 -0
- package/template/app/utils/content-loader.ts +400 -0
- package/template/app/utils/dates.ts +29 -0
- package/template/app/utils/docs.server.ts +150 -0
- package/template/app/utils/markdown/filterFrameworkContent.ts +233 -0
- package/template/app/utils/markdown/index.ts +2 -0
- package/template/app/utils/markdown/installCommand.ts +143 -0
- package/template/app/utils/markdown/plugins/collectHeadings.ts +104 -0
- package/template/app/utils/markdown/plugins/extractCodeMeta.ts +57 -0
- package/template/app/utils/markdown/plugins/helpers.ts +33 -0
- package/template/app/utils/markdown/plugins/index.ts +8 -0
- package/template/app/utils/markdown/plugins/parseCommentComponents.ts +103 -0
- package/template/app/utils/markdown/plugins/transformCommentComponents.ts +23 -0
- package/template/app/utils/markdown/plugins/transformFrameworkComponent.ts +217 -0
- package/template/app/utils/markdown/plugins/transformTabsComponent.ts +359 -0
- package/template/app/utils/markdown/processor.ts +75 -0
- package/template/app/utils/site-config.tsx +11 -0
- package/template/app/utils/upload.ts +232 -0
- package/template/app/utils/useLocalStorage.ts +65 -0
- package/template/app/utils/utils.ts +23 -0
- package/template/package.json +53 -0
- package/template/public/favicon.svg +1 -0
- package/template/public/fonts/Inter-latin-ext.woff2 +0 -0
- package/template/public/fonts/Inter-latin.woff2 +0 -0
- package/template/public/images/frameworks/angular-logo.svg +1 -0
- package/template/public/images/frameworks/js-logo.svg +1 -0
- package/template/public/images/frameworks/lit-logo.svg +1 -0
- package/template/public/images/frameworks/preact-logo.svg +6 -0
- package/template/public/images/frameworks/qwik-logo.svg +1 -0
- package/template/public/images/frameworks/react-logo.svg +1 -0
- package/template/public/images/frameworks/solid-logo.svg +1 -0
- package/template/public/images/frameworks/svelte-logo.svg +1 -0
- package/template/public/images/frameworks/vue-logo.svg +4 -0
- package/template/tsconfig.json +24 -0
- package/template/vite.config.ts +43 -0
- package/template/wrangler.jsonc +16 -0
- package/README.md +0 -161
- package/dist/server-73AVSOL5.js +0 -598
- package/src/admin/index.html +0 -13
- package/src/admin/server/index.ts +0 -138
- package/src/admin/server/routes/jobs.ts +0 -113
- package/src/admin/server/routes/status.ts +0 -57
- package/src/admin/ui/App.tsx +0 -332
- package/src/admin/ui/main.tsx +0 -19
- /package/{src/admin/ui → admin/app}/components/FileList.tsx +0 -0
- /package/{src/admin/ui → admin/app}/components/LangGrid.tsx +0 -0
- /package/{src/admin/ui → admin/app}/components/ProgressBar.tsx +0 -0
- /package/{src/admin/ui → admin/app}/lib/flags.ts +0 -0
package/README.md
DELETED
|
@@ -1,161 +0,0 @@
|
|
|
1
|
-
# docs-i18n
|
|
2
|
-
|
|
3
|
-
Universal documentation translation engine. Parse markdown/MDX into translatable nodes, translate via LLM, cache in SQLite, manage with admin dashboard.
|
|
4
|
-
|
|
5
|
-
## Features
|
|
6
|
-
|
|
7
|
-
- **AST-based parsing** — splits markdown into translatable nodes with MD5 keys
|
|
8
|
-
- **Incremental translation** — only translates changed/new content
|
|
9
|
-
- **Smart chunking** — respects LLM context window and output token limits
|
|
10
|
-
- **YAML-aware frontmatter** — translates title/description fields individually
|
|
11
|
-
- **SQLite cache** — concurrent-safe with WAL mode
|
|
12
|
-
- **Admin dashboard** — web UI for managing translation progress and jobs
|
|
13
|
-
- **Runtime serve** — D1-compatible translator for SSR sites
|
|
14
|
-
- **Framework-agnostic** — works with any docs site (Next.js, Astro, TanStack Start, etc.)
|
|
15
|
-
|
|
16
|
-
## Quick Start
|
|
17
|
-
|
|
18
|
-
```bash
|
|
19
|
-
npm install docs-i18n
|
|
20
|
-
# or
|
|
21
|
-
bun add docs-i18n
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
Create `docs-i18n.config.ts` in your project root:
|
|
25
|
-
|
|
26
|
-
```ts
|
|
27
|
-
import { defineConfig } from 'docs-i18n';
|
|
28
|
-
|
|
29
|
-
export default defineConfig({
|
|
30
|
-
projects: {
|
|
31
|
-
mydocs: {
|
|
32
|
-
sources: {
|
|
33
|
-
latest: 'content/latest',
|
|
34
|
-
v1: 'content/v1',
|
|
35
|
-
},
|
|
36
|
-
},
|
|
37
|
-
},
|
|
38
|
-
languages: ['zh-hans', 'ja', 'es'],
|
|
39
|
-
cacheDir: '.cache',
|
|
40
|
-
translatableFields: ['title', 'description', 'nav_title'],
|
|
41
|
-
llm: {
|
|
42
|
-
provider: 'openrouter', // or 'openai', 'anthropic'
|
|
43
|
-
model: 'qwen/qwen3.5-flash-02-23',
|
|
44
|
-
apiKey: process.env.OPENROUTER_API_KEY,
|
|
45
|
-
contextLength: 1_000_000,
|
|
46
|
-
maxTokens: 65536,
|
|
47
|
-
},
|
|
48
|
-
context: 'MyProject is a TypeScript library for building web apps.',
|
|
49
|
-
});
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
## CLI
|
|
53
|
-
|
|
54
|
-
```bash
|
|
55
|
-
# Check translation progress
|
|
56
|
-
docs-i18n status
|
|
57
|
-
|
|
58
|
-
# Translate
|
|
59
|
-
docs-i18n translate --lang zh-hans
|
|
60
|
-
docs-i18n translate --lang zh-hans --version latest --dry-run
|
|
61
|
-
docs-i18n translate --lang zh-hans --files docs/intro.mdx,docs/guide.mdx
|
|
62
|
-
|
|
63
|
-
# Assemble translated files (EN source + cache → output)
|
|
64
|
-
docs-i18n assemble
|
|
65
|
-
docs-i18n assemble --lang zh-hans --version latest
|
|
66
|
-
|
|
67
|
-
# Rescan source files and clean orphans
|
|
68
|
-
docs-i18n rescan
|
|
69
|
-
|
|
70
|
-
# Start admin dashboard (http://localhost:3456)
|
|
71
|
-
docs-i18n admin
|
|
72
|
-
docs-i18n admin --port 4000
|
|
73
|
-
```
|
|
74
|
-
|
|
75
|
-
### npm scripts
|
|
76
|
-
|
|
77
|
-
```json
|
|
78
|
-
{
|
|
79
|
-
"scripts": {
|
|
80
|
-
"i18n": "docs-i18n",
|
|
81
|
-
"i18n:status": "docs-i18n status",
|
|
82
|
-
"i18n:admin": "docs-i18n admin",
|
|
83
|
-
"i18n:translate": "docs-i18n translate",
|
|
84
|
-
"i18n:assemble": "docs-i18n assemble",
|
|
85
|
-
"i18n:rescan": "docs-i18n rescan"
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
## Multi-Project Support
|
|
91
|
-
|
|
92
|
-
For projects with multiple libraries (e.g., TanStack), use compound version keys:
|
|
93
|
-
|
|
94
|
-
```ts
|
|
95
|
-
export default defineConfig({
|
|
96
|
-
projects: {
|
|
97
|
-
query: {
|
|
98
|
-
sources: { latest: 'content/query/latest', v4: 'content/query/v4' },
|
|
99
|
-
},
|
|
100
|
-
table: {
|
|
101
|
-
sources: { latest: 'content/table/latest' },
|
|
102
|
-
},
|
|
103
|
-
blog: {
|
|
104
|
-
sources: { latest: 'content/blog' },
|
|
105
|
-
},
|
|
106
|
-
},
|
|
107
|
-
languages: ['zh-hans'],
|
|
108
|
-
});
|
|
109
|
-
```
|
|
110
|
-
|
|
111
|
-
The admin dashboard automatically groups by project.
|
|
112
|
-
|
|
113
|
-
## Runtime Translation (for SSR)
|
|
114
|
-
|
|
115
|
-
For SSR sites that fetch markdown at runtime (e.g., TanStack Start), use the serve module with Cloudflare D1:
|
|
116
|
-
|
|
117
|
-
```ts
|
|
118
|
-
import { createTranslator } from 'docs-i18n/serve';
|
|
119
|
-
|
|
120
|
-
const translator = createTranslator();
|
|
121
|
-
|
|
122
|
-
// In your request handler:
|
|
123
|
-
const enMarkdown = await fetchFromGitHub(repo, branch, filePath);
|
|
124
|
-
const translated = await translator.translate(enMarkdown, 'zh-hans', env.DB);
|
|
125
|
-
```
|
|
126
|
-
|
|
127
|
-
## Config Reference
|
|
128
|
-
|
|
129
|
-
```ts
|
|
130
|
-
interface DocsI18nConfig {
|
|
131
|
-
projects: Record<string, {
|
|
132
|
-
sources: Record<string, string>; // version → source directory
|
|
133
|
-
}>;
|
|
134
|
-
languages: string[]; // target languages
|
|
135
|
-
cacheDir?: string; // default: '.cache'
|
|
136
|
-
translatableFields?: string[]; // default: ['title', 'description', 'nav_title']
|
|
137
|
-
include?: string[]; // default: ['**/*.mdx', '**/*.md']
|
|
138
|
-
context?: string; // injected into LLM prompt
|
|
139
|
-
llm?: {
|
|
140
|
-
provider?: 'openrouter' | 'openai' | 'anthropic';
|
|
141
|
-
model?: string;
|
|
142
|
-
apiKey?: string;
|
|
143
|
-
contextLength?: number; // default: 32768
|
|
144
|
-
maxTokens?: number; // default: 16384
|
|
145
|
-
};
|
|
146
|
-
onTranslated?: (info: {
|
|
147
|
-
project: string;
|
|
148
|
-
version: string;
|
|
149
|
-
lang: string;
|
|
150
|
-
}) => Promise<void>;
|
|
151
|
-
}
|
|
152
|
-
```
|
|
153
|
-
|
|
154
|
-
## Requirements
|
|
155
|
-
|
|
156
|
-
- Node.js 20+ or Bun
|
|
157
|
-
- Admin dashboard requires `vite` and `@vitejs/plugin-react` as dev dependencies
|
|
158
|
-
|
|
159
|
-
## License
|
|
160
|
-
|
|
161
|
-
MIT
|