ai-i18n-tools 1.2.8 → 1.4.0
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 +24 -16
- package/dist/build-info.generated.d.ts +1 -1
- package/dist/build-info.generated.js +1 -1
- package/dist/cli/check-markdown.d.ts +25 -0
- package/dist/cli/check-markdown.d.ts.map +1 -0
- package/dist/cli/check-markdown.js +78 -0
- package/dist/cli/check-markdown.js.map +1 -0
- package/dist/cli/clean-temp.d.ts +17 -0
- package/dist/cli/clean-temp.d.ts.map +1 -0
- package/dist/cli/clean-temp.js +119 -0
- package/dist/cli/clean-temp.js.map +1 -0
- package/dist/cli/doc-translate.d.ts +37 -1
- package/dist/cli/doc-translate.d.ts.map +1 -1
- package/dist/cli/doc-translate.js +163 -9
- package/dist/cli/doc-translate.js.map +1 -1
- package/dist/cli/index.js +137 -16
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/strip-md-bold-inline.js +1 -1
- package/dist/cli/strip-md-bold-inline.js.map +1 -1
- package/dist/cli/translate-svg.d.ts +1 -1
- package/dist/cli/translate-svg.js +1 -1
- package/dist/core/cache-tracking-keys.d.ts +3 -3
- package/dist/core/cache-tracking-keys.d.ts.map +1 -1
- package/dist/core/cache-tracking-keys.js +3 -3
- package/dist/core/cache-tracking-keys.js.map +1 -1
- package/dist/core/cache.d.ts +21 -2
- package/dist/core/cache.d.ts.map +1 -1
- package/dist/core/cache.js +125 -2
- package/dist/core/cache.js.map +1 -1
- package/dist/core/doc-file-tracking.d.ts +5 -0
- package/dist/core/doc-file-tracking.d.ts.map +1 -1
- package/dist/core/doc-file-tracking.js +13 -0
- package/dist/core/doc-file-tracking.js.map +1 -1
- package/dist/core/prompts.js +1 -1
- package/dist/core/prompts.js.map +1 -1
- package/dist/core/svg-asset-paths.d.ts +2 -2
- package/dist/core/svg-asset-paths.d.ts.map +1 -1
- package/dist/core/svg-asset-paths.js +3 -3
- package/dist/core/svg-asset-paths.js.map +1 -1
- package/dist/core/types.d.ts +26 -2
- package/dist/core/types.d.ts.map +1 -1
- package/dist/core/types.js +9 -4
- package/dist/core/types.js.map +1 -1
- package/dist/edit-cache-app/app.js +215 -0
- package/dist/edit-cache-app/index.html +60 -0
- package/dist/extractors/classify-segment.d.ts.map +1 -1
- package/dist/extractors/classify-segment.js +1 -4
- package/dist/extractors/classify-segment.js.map +1 -1
- package/dist/extractors/markdown-extractor.d.ts.map +1 -1
- package/dist/extractors/markdown-extractor.js +5 -2
- package/dist/extractors/markdown-extractor.js.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/processors/admonition-placeholders.d.ts.map +1 -1
- package/dist/processors/admonition-placeholders.js +11 -4
- package/dist/processors/admonition-placeholders.js.map +1 -1
- package/dist/processors/emphasis-placeholders.d.ts +32 -0
- package/dist/processors/emphasis-placeholders.d.ts.map +1 -1
- package/dist/processors/emphasis-placeholders.js +35 -5
- package/dist/processors/emphasis-placeholders.js.map +1 -1
- package/dist/processors/jsx-attribute-placeholders.d.ts +32 -0
- package/dist/processors/jsx-attribute-placeholders.d.ts.map +1 -0
- package/dist/processors/jsx-attribute-placeholders.js +115 -0
- package/dist/processors/jsx-attribute-placeholders.js.map +1 -0
- package/dist/processors/markdown-source-diagnostics.d.ts +27 -0
- package/dist/processors/markdown-source-diagnostics.d.ts.map +1 -0
- package/dist/processors/markdown-source-diagnostics.js +335 -0
- package/dist/processors/markdown-source-diagnostics.js.map +1 -0
- package/dist/processors/mdx-placeholders.d.ts +37 -0
- package/dist/processors/mdx-placeholders.d.ts.map +1 -0
- package/dist/processors/mdx-placeholders.js +272 -0
- package/dist/processors/mdx-placeholders.js.map +1 -0
- package/dist/processors/placeholder-handler.d.ts +11 -2
- package/dist/processors/placeholder-handler.d.ts.map +1 -1
- package/dist/processors/placeholder-handler.js +9 -3
- package/dist/processors/placeholder-handler.js.map +1 -1
- package/dist/processors/translation-placeholder-leaks.js +1 -1
- package/dist/processors/translation-placeholder-leaks.js.map +1 -1
- package/dist/server/translation-editor.d.ts.map +1 -1
- package/dist/server/translation-editor.js +50 -1
- package/dist/server/translation-editor.js.map +1 -1
- package/docs/GETTING_STARTED.md +249 -143
- package/docs/PACKAGE_OVERVIEW.md +25 -14
- package/docs/ai-i18n-tools-context.md +105 -55
- package/docs/markdown-mdx-stress-test.md +170 -0
- package/docs/translation-cache-editor.png +0 -0
- package/package.json +5 -5
- package/translated-docs/README.de.md +24 -16
- package/translated-docs/README.es.md +24 -16
- package/translated-docs/README.fr.md +25 -17
- package/translated-docs/README.hi.md +24 -16
- package/translated-docs/README.ja.md +25 -17
- package/translated-docs/README.ko.md +24 -16
- package/translated-docs/README.pt-BR.md +24 -16
- package/translated-docs/README.zh-CN.md +24 -16
- package/translated-docs/README.zh-TW.md +24 -16
- package/translated-docs/docs/GETTING_STARTED.de.md +227 -121
- package/translated-docs/docs/GETTING_STARTED.es.md +223 -117
- package/translated-docs/docs/GETTING_STARTED.fr.md +224 -118
- package/translated-docs/docs/GETTING_STARTED.hi.md +227 -121
- package/translated-docs/docs/GETTING_STARTED.ja.md +227 -121
- package/translated-docs/docs/GETTING_STARTED.ko.md +226 -120
- package/translated-docs/docs/GETTING_STARTED.pt-BR.md +225 -119
- package/translated-docs/docs/GETTING_STARTED.zh-CN.md +228 -122
- package/translated-docs/docs/GETTING_STARTED.zh-TW.md +229 -123
- package/translated-docs/docs/PACKAGE_OVERVIEW.de.md +25 -14
- package/translated-docs/docs/PACKAGE_OVERVIEW.es.md +25 -14
- package/translated-docs/docs/PACKAGE_OVERVIEW.fr.md +25 -14
- package/translated-docs/docs/PACKAGE_OVERVIEW.hi.md +25 -14
- package/translated-docs/docs/PACKAGE_OVERVIEW.ja.md +25 -14
- package/translated-docs/docs/PACKAGE_OVERVIEW.ko.md +25 -14
- package/translated-docs/docs/PACKAGE_OVERVIEW.pt-BR.md +25 -14
- package/translated-docs/docs/PACKAGE_OVERVIEW.zh-CN.md +25 -14
- package/translated-docs/docs/PACKAGE_OVERVIEW.zh-TW.md +25 -14
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
[](./LICENSE)
|
|
8
8
|
[](https://github.com/wsj-br/ai-i18n-tools/actions/workflows/ci.yml)
|
|
9
9
|
|
|
10
|
-
CLI and
|
|
10
|
+
CLI and toolkit for internationalizing JavaScript/TypeScript applications and documentation sites. Extracts UI strings, translates them using large language models via OpenRouter, and generates locale-ready JSON files for i18next. For documentation, it translates markdown and MDX under `contentPaths` (the localized pages readers open). Optional Docusaurus label JSON from `jsonSource` covers site shell strings (`write-translations` catalogs such as theme/nav/footer), distinct from page body copy. SVG file translation uses `features.translateSVG` and the top-level `svg` block.
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
<small>**Read in other languages:** </small>
|
|
@@ -43,18 +43,18 @@ CLI and programmatic toolkit for internationalising JavaScript/TypeScript applic
|
|
|
43
43
|
|
|
44
44
|
Builds a master catalog (`strings.json` with optional per-locale `models` metadata) from `t("…")` / `i18n.t("…")` **literals**, optionally `package.json` `description`, and optionally each `englishName` from `ui-languages.json` when enabled in config. Translates missing entries per locale via OpenRouter and writes flat JSON files (`de.json`, `pt-BR.json`, …) ready for i18next.
|
|
45
45
|
|
|
46
|
-
**Workflow 2 - Document translation** (Markdown, Docusaurus JSON)
|
|
46
|
+
**Workflow 2 - Document translation** (Markdown / MDX, optional Docusaurus shell JSON)
|
|
47
47
|
|
|
48
|
-
Translates `.md` and `.mdx` from each `documentations` block’s `contentPaths` and
|
|
48
|
+
Translates `.md` and `.mdx` from each `documentations` block’s `contentPaths` — that is the localized documentation. When `features.translateJSON` and `jsonSource` are set, it also translates Docusaurus **label JSON** (navbar, footer, theme/plugin UI from `write-translations`), not MDX body text. Supports Docusaurus-style and flat locale-suffixed layouts per block (`documentations[].markdownOutput`). Shared root `cacheDir` holds the SQLite cache so only new or changed segments are sent to the LLM. **SVG:** enable `features.translateSVG`, add the top-level `svg` block, then use `translate-svg` (also run from `sync` when both are set).
|
|
49
49
|
|
|
50
|
-
Both workflows share a single `ai-i18n-tools.config.json` file and can be used independently or together.
|
|
50
|
+
Both workflows share a single `ai-i18n-tools.config.json` file and can be used independently or together. SVG file translation uses `features.translateSVG` plus the top-level `svg` block and runs through `translate-svg` (or the SVG stage inside `sync`).
|
|
51
51
|
|
|
52
52
|
---
|
|
53
53
|
|
|
54
54
|
<a id="installation"></a>
|
|
55
55
|
## Installation
|
|
56
56
|
|
|
57
|
-
The published package is **ESM-only** (`"type": "module"`). Use `import` from Node.js, bundlers, or `import()` — `require('ai-i18n-tools')` **is not supported.** The package declares
|
|
57
|
+
The published package is **ESM-only** (`"type": "module"`). Use `import` from Node.js, bundlers, or `import()` — `require('ai-i18n-tools')` **is not supported.** The package declares `engines.node` `>=22.16.0`; older Node.js versions are unsupported.
|
|
58
58
|
|
|
59
59
|
```bash
|
|
60
60
|
npm install ai-i18n-tools
|
|
@@ -62,6 +62,7 @@ npm install ai-i18n-tools
|
|
|
62
62
|
pnpm add ai-i18n-tools
|
|
63
63
|
```
|
|
64
64
|
|
|
65
|
+
<a id="using-the-cli"></a>
|
|
65
66
|
### Using the CLI
|
|
66
67
|
|
|
67
68
|
**Per-project (recommended)** — install as a dependency or devDependency, then call via `npx`, `pnpm exec`, or a `package.json` script:
|
|
@@ -80,7 +81,7 @@ npx ai-i18n-tools sync # or: pnpm exec ai-i18n-tools sync
|
|
|
80
81
|
|
|
81
82
|
The package manager writes `node_modules/.bin/ai-i18n-tools` with the correct permissions on Linux and macOS and `.cmd` / `.ps1` shims on Windows; script runners pick it up automatically.
|
|
82
83
|
|
|
83
|
-
**Bare** `ai-i18n-tools` **in the terminal
|
|
84
|
+
**Bare** `ai-i18n-tools` **in the terminal:** `package.json` scripts already run with `node_modules/.bin` on `PATH`, so commands like `pnpm run i18n:sync` invoke the CLI without typing `npx`. To run `ai-i18n-tools` directly in an interactive shell (from the project root, after a local install), prepend the local bin directory to `PATH`:
|
|
84
85
|
|
|
85
86
|
```bash
|
|
86
87
|
# bash/zsh — project root
|
|
@@ -94,7 +95,7 @@ $env:Path = "$PWD\node_modules\.bin;$env:Path"
|
|
|
94
95
|
ai-i18n-tools sync
|
|
95
96
|
```
|
|
96
97
|
|
|
97
|
-
With [direnv](https://direnv.net/), add `PATH_add node_modules/.bin` to a `.envrc` in the project root so the bare command is available after `cd` into the repo. Without adjusting `PATH`, keep using `npx ai-i18n-tools …` or `pnpm exec ai-i18n-tools …`.
|
|
98
|
+
With [**direnv**](https://direnv.net/), add `PATH_add node_modules/.bin` to a `.envrc` in the project root so the bare command is available after `cd` into the repo. Without adjusting `PATH`, keep using `npx ai-i18n-tools …` or `pnpm exec ai-i18n-tools …`.
|
|
98
99
|
|
|
99
100
|
**Zero-install one-off** — `npx ai-i18n-tools <cmd>` or `pnpm dlx ai-i18n-tools <cmd>` (downloads the package for that invocation; no entry in `package.json`).
|
|
100
101
|
|
|
@@ -111,7 +112,7 @@ export OPENROUTER_API_KEY=sk-or-v1-your-key-here
|
|
|
111
112
|
<a id="openrouter"></a>
|
|
112
113
|
## OpenRouter
|
|
113
114
|
|
|
114
|
-
Commands that call OpenRouter (`translate-ui`, `translate-docs`, `sync`, `check-models`, and related scripts) need `OPENROUTER_API_KEY` in the environment.
|
|
115
|
+
Commands that call OpenRouter (`translate-ui`, `translate-docs`, `sync`, `check-models`, and related scripts) need `OPENROUTER_API_KEY` in the environment. `check-markdown` does not use OpenRouter.
|
|
115
116
|
|
|
116
117
|
In `ai-i18n-tools.config.json`, the `openrouter` object includes model lists, `baseUrl`, `maxTokens`, `temperature`, and `requestTimeoutMs`: the maximum time in milliseconds to wait for each HTTP request to OpenRouter (chat completions and internal `GET /models` calls). The default is `30000` (30 seconds).
|
|
117
118
|
|
|
@@ -221,24 +222,31 @@ ai-i18n-tools init [-t ui-markdown|ui-docusaurus] [-o path] [--with-translate-ig
|
|
|
221
222
|
ai-i18n-tools check-models Validate configured OpenRouter model ids against GET /models (pricing, expiration); requires OPENROUTER_API_KEY
|
|
222
223
|
ai-i18n-tools generate-ui-languages [--master path] [--dry-run] Build ui-languages.json from locales + master catalog (needs uiLanguagesPath)
|
|
223
224
|
ai-i18n-tools extract Merge scanner output, optional package.json description, optional manifest englishName into strings.json
|
|
224
|
-
ai-i18n-tools translate-docs
|
|
225
|
-
--force
|
|
226
|
-
--prompt-format
|
|
225
|
+
ai-i18n-tools translate-docs … Translate documentation: markdown/MDX from contentPaths; optional Docusaurus label JSON from jsonSource. Flags include -l/--locale <codes>, -p/-f path, --dry-run,
|
|
226
|
+
--force, --force-update, --stats, --clear-cache, --type, --json-only, --no-json, -j, -b,
|
|
227
|
+
--prompt-format, --emphasis-placeholders, --no-emphasis-placeholders, --debug-failed
|
|
227
228
|
ai-i18n-tools write-heading-ids … Insert HTML anchor lines before ATX headings in .md/.mdx (documentations[])
|
|
228
229
|
ai-i18n-tools strip-md-bold-inline … Remove bold (**) around inline code in markdown/MDX (documentations[])
|
|
229
|
-
ai-i18n-tools
|
|
230
|
-
ai-i18n-tools translate-
|
|
230
|
+
ai-i18n-tools check-markdown [-p|--path <path>] [--json] [--no-cache] Scan documentation markdown for delimiter / inline-code issues and strong-outside-code or strong-outside-link patterns; refresh SQLite markdown_source_issues; exit 1 if any issue
|
|
231
|
+
ai-i18n-tools translate-svg … SVG files (features.translateSVG + config.svg); flags include -l/--locale <codes>,
|
|
232
|
+
-p/-f path, --dry-run, --force, --force-update, --no-cache, -j, -b
|
|
233
|
+
ai-i18n-tools translate-ui … Translate UI strings only; flags include -l/--locale <codes>, --dry-run, --force, -j
|
|
231
234
|
ai-i18n-tools lint-source … Run extract, then LLM review of source-locale UI strings (OpenRouter)
|
|
232
|
-
ai-i18n-tools export-ui-xliff
|
|
233
|
-
ai-i18n-tools sync
|
|
235
|
+
ai-i18n-tools export-ui-xliff … Export UI strings to XLIFF 2.0 (one file per locale); -l, -o, --untranslated-only, --dry-run
|
|
236
|
+
ai-i18n-tools sync … Extract, then UI / SVG / docs; flags include -l/--locale <codes>, -p/-f path, --dry-run, --force,
|
|
237
|
+
--force-update, --no-ui, --no-svg, --no-docs, -j, -b, --emphasis-placeholders,
|
|
238
|
+
--no-emphasis-placeholders, --debug-failed
|
|
234
239
|
ai-i18n-tools status [--max-columns <n>] UI strings per locale; markdown per file × locale in tables of up to n locales (default 9)
|
|
235
240
|
ai-i18n-tools statistics [--max-columns <n>] Documentation cache + strings.json aggregates (same as editor Statistics)
|
|
236
241
|
ai-i18n-tools editor Open cache/glossary web editor
|
|
237
242
|
ai-i18n-tools cleanup [--dry-run] [--no-backup] [--backup <path>] Runs sync --force-update, then cleans stale + orphaned cache rows; backs up SQLite by default
|
|
243
|
+
ai-i18n-tools clean-temp [-r|--root <path>] [-f|--force] [--dry-run] List *.log and cache.db.backup*.sqlite; delete after `y`, with `-f`, or skip if none match
|
|
238
244
|
ai-i18n-tools glossary-generate Create empty glossary CSV template
|
|
239
245
|
```
|
|
240
246
|
|
|
241
|
-
|
|
247
|
+
Complete per-command flag lists are maintained next to `src/cli/index.ts` in [CLI flags by command](docs/GETTING_STARTED.md#cli-flags-by-command). Run `ai-i18n-tools <command> --help` for built-in usage text.
|
|
248
|
+
|
|
249
|
+
Global options on every command: `-c <config>` (default: `ai-i18n-tools.config.json`), `-v` (verbose), optional `-w` / `--write-logs [path]` to tee console output to a log file (default: under the translation cache directory), `-V` / `--version`, and `-h` / `--help`. See [Getting Started](docs/GETTING_STARTED.md#cli-reference) for the command overview table.
|
|
242
250
|
|
|
243
251
|
---
|
|
244
252
|
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { I18nConfig } from "../core/types.js";
|
|
2
|
+
export interface CheckMarkdownOptions {
|
|
3
|
+
cwd: string;
|
|
4
|
+
config: I18nConfig;
|
|
5
|
+
pathFilter?: string;
|
|
6
|
+
json: boolean;
|
|
7
|
+
noCache: boolean;
|
|
8
|
+
verbose: boolean;
|
|
9
|
+
}
|
|
10
|
+
export interface CheckMarkdownJsonRow {
|
|
11
|
+
filepath: string;
|
|
12
|
+
displayPath: string;
|
|
13
|
+
line: number | null;
|
|
14
|
+
issueCode: string;
|
|
15
|
+
detail: string;
|
|
16
|
+
sourceHash: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Scan configured documentation markdown for delimiter / inline-code issues; optional SQLite refresh.
|
|
20
|
+
* @returns exit code 0 = no issues, 1 = at least one issue
|
|
21
|
+
*/
|
|
22
|
+
export declare function runCheckMarkdown(opts: CheckMarkdownOptions): Promise<{
|
|
23
|
+
exitCode: number;
|
|
24
|
+
}>;
|
|
25
|
+
//# sourceMappingURL=check-markdown.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"check-markdown.d.ts","sourceRoot":"","sources":["../../src/cli/check-markdown.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAenD,MAAM,WAAW,oBAAoB;IACnC,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,UAAU,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,OAAO,CAAC;IACd,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,WAAW,oBAAoB;IACnC,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;CACpB;AAED;;;GAGG;AACH,wBAAsB,gBAAgB,CAAC,IAAI,EAAE,oBAAoB,GAAG,OAAO,CAAC;IAAE,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC,CAuEhG"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import path from "path";
|
|
3
|
+
import chalk from "chalk";
|
|
4
|
+
import { toDocTranslateConfig } from "../core/config.js";
|
|
5
|
+
import { TranslationCache } from "../core/cache.js";
|
|
6
|
+
import { documentationFileTrackingKey } from "../core/doc-file-tracking.js";
|
|
7
|
+
import { MarkdownExtractor } from "../extractors/markdown-extractor.js";
|
|
8
|
+
import { collectMarkdownIssuesForSegment } from "../processors/markdown-source-diagnostics.js";
|
|
9
|
+
import { collectFilesByExtension } from "./file-utils.js";
|
|
10
|
+
import { loadTranslateIgnore, isIgnored } from "../utils/ignore-parser.js";
|
|
11
|
+
import { matchesPathFilter, buildMarkdownExtractOpts } from "./doc-translate.js";
|
|
12
|
+
function filterIgnoredFiles(files, cwd) {
|
|
13
|
+
const ig = loadTranslateIgnore(".translate-ignore", cwd);
|
|
14
|
+
return files.filter((f) => !isIgnored(ig, path.join(cwd, f), cwd));
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Scan configured documentation markdown for delimiter / inline-code issues; optional SQLite refresh.
|
|
18
|
+
* @returns exit code 0 = no issues, 1 = at least one issue
|
|
19
|
+
*/
|
|
20
|
+
export async function runCheckMarkdown(opts) {
|
|
21
|
+
const projectRoot = opts.cwd;
|
|
22
|
+
const jsonRows = [];
|
|
23
|
+
let issueCount = 0;
|
|
24
|
+
const cache = !opts.noCache && opts.config.cacheDir
|
|
25
|
+
? new TranslationCache(path.join(projectRoot, opts.config.cacheDir))
|
|
26
|
+
: null;
|
|
27
|
+
try {
|
|
28
|
+
for (let bi = 0; bi < opts.config.documentations.length; bi++) {
|
|
29
|
+
const block = opts.config.documentations[bi];
|
|
30
|
+
const view = toDocTranslateConfig(opts.config, block);
|
|
31
|
+
const md = filterIgnoredFiles(collectFilesByExtension(block.contentPaths, [".md", ".mdx"], projectRoot), projectRoot).filter((r) => matchesPathFilter(r, opts.pathFilter));
|
|
32
|
+
const mdExtractOpts = buildMarkdownExtractOpts(view.documentation);
|
|
33
|
+
const extractor = new MarkdownExtractor();
|
|
34
|
+
for (const relPath of md) {
|
|
35
|
+
const abs = path.join(projectRoot, relPath);
|
|
36
|
+
const content = fs.readFileSync(abs, "utf8");
|
|
37
|
+
const segments = extractor.extract(content, relPath, mdExtractOpts);
|
|
38
|
+
const trackKey = documentationFileTrackingKey(bi, relPath);
|
|
39
|
+
const rows = segments.flatMap((s) => collectMarkdownIssuesForSegment(s, trackKey));
|
|
40
|
+
if (cache) {
|
|
41
|
+
cache.replaceMarkdownIssuesForFilepath(trackKey, rows);
|
|
42
|
+
}
|
|
43
|
+
for (const row of rows) {
|
|
44
|
+
issueCount++;
|
|
45
|
+
if (opts.json) {
|
|
46
|
+
jsonRows.push({
|
|
47
|
+
filepath: row.filepath,
|
|
48
|
+
displayPath: relPath,
|
|
49
|
+
line: row.startLine,
|
|
50
|
+
issueCode: row.issueCode,
|
|
51
|
+
detail: row.detail,
|
|
52
|
+
sourceHash: row.sourceHash,
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
const line = row.startLine ?? "?";
|
|
57
|
+
console.error(chalk.cyan(`${relPath}:${line}`) +
|
|
58
|
+
chalk.yellow(`: [${row.issueCode}] ${row.detail}${opts.verbose ? ` (hash ${row.sourceHash})` : ""}`));
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
finally {
|
|
65
|
+
cache?.close();
|
|
66
|
+
}
|
|
67
|
+
if (opts.json) {
|
|
68
|
+
console.log(JSON.stringify({ issues: jsonRows, count: issueCount }, null, 2));
|
|
69
|
+
}
|
|
70
|
+
else if (issueCount > 0) {
|
|
71
|
+
console.error(chalk.red(`\n❌ check-markdown: ${issueCount} issue(s) in documentation sources`));
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
console.log(chalk.green("✅ check-markdown: no markdown source issues found"));
|
|
75
|
+
}
|
|
76
|
+
return { exitCode: issueCount > 0 ? 1 : 0 };
|
|
77
|
+
}
|
|
78
|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AE,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,UAAU,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;IAChF,CAAC;SAAM,IAAI,UAAU,GAAG,CAAC,EAAE,CAAC;QAC1B,OAAO,CAAC,KAAK,CACX,KAAK,CAAC,GAAG,CAAC,uBAAuB,UAAU,oCAAoC,CAAC,CACjF,CAAC;IACJ,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,mDAAmD,CAAC,CAAC,CAAC;IAChF,CAAC;IAED,OAAO,EAAE,QAAQ,EAAE,UAAU,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AAC9C,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/** Basenames matched by `find … \( -name '*.log' -o -name 'cache.db.backup*.sqlite' \)`. */
|
|
2
|
+
export declare function matchesCleanTempBasename(basename: string): boolean;
|
|
3
|
+
/** Print path like `find . -print` (posix-style `./…` under `rootAbs`). */
|
|
4
|
+
export declare function formatFindPrintLine(rootAbs: string, fileAbs: string): string;
|
|
5
|
+
export type RunCleanTempOptions = {
|
|
6
|
+
rootDir: string;
|
|
7
|
+
/** When true, skip the prompt and do not delete (list only). Overrides `force`. */
|
|
8
|
+
dryRun?: boolean;
|
|
9
|
+
/** When true, delete without prompting (after listing). Ignored when `dryRun` is true. */
|
|
10
|
+
force?: boolean;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Lists `*.log` and `cache.db.backup*.sqlite` under `rootDir`, prints paths like `find -print`,
|
|
14
|
+
* then prompts unless `force` or there are no matches; deletes on exact `y`, or immediately when `force`.
|
|
15
|
+
*/
|
|
16
|
+
export declare function runCleanTemp(opts: RunCleanTempOptions): Promise<void>;
|
|
17
|
+
//# sourceMappingURL=clean-temp.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clean-temp.d.ts","sourceRoot":"","sources":["../../src/cli/clean-temp.ts"],"names":[],"mappings":"AAKA,4FAA4F;AAC5F,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAKlE;AAED,2EAA2E;AAC3E,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAK5E;AA+CD,MAAM,MAAM,mBAAmB,GAAG;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,mFAAmF;IACnF,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,0FAA0F;IAC1F,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB,CAAC;AAEF;;;GAGG;AACH,wBAAsB,YAAY,CAAC,IAAI,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC,CA+C3E"}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import readline from "node:readline/promises";
|
|
4
|
+
import chalk from "chalk";
|
|
5
|
+
/** Basenames matched by `find … \( -name '*.log' -o -name 'cache.db.backup*.sqlite' \)`. */
|
|
6
|
+
export function matchesCleanTempBasename(basename) {
|
|
7
|
+
if (basename.endsWith(".log"))
|
|
8
|
+
return true;
|
|
9
|
+
if (basename.endsWith(".tmp"))
|
|
10
|
+
return true;
|
|
11
|
+
if (basename.startsWith("cache.db.backup") && basename.endsWith(".sqlite"))
|
|
12
|
+
return true;
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
/** Print path like `find . -print` (posix-style `./…` under `rootAbs`). */
|
|
16
|
+
export function formatFindPrintLine(rootAbs, fileAbs) {
|
|
17
|
+
const rel = path.relative(rootAbs, fileAbs);
|
|
18
|
+
const norm = rel.split(path.sep).join("/");
|
|
19
|
+
if (norm === "" || norm === ".")
|
|
20
|
+
return "./";
|
|
21
|
+
return `[clean-temp]` + chalk.cyan(` ./${norm}`);
|
|
22
|
+
}
|
|
23
|
+
async function collectCleanTempFiles(rootAbs) {
|
|
24
|
+
const out = [];
|
|
25
|
+
async function visit(dir) {
|
|
26
|
+
let entries;
|
|
27
|
+
try {
|
|
28
|
+
entries = await fs.promises.readdir(dir, { withFileTypes: true });
|
|
29
|
+
}
|
|
30
|
+
catch {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
for (const ent of entries) {
|
|
34
|
+
const full = path.join(dir, ent.name);
|
|
35
|
+
if (ent.isSymbolicLink()) {
|
|
36
|
+
let st;
|
|
37
|
+
try {
|
|
38
|
+
st = await fs.promises.lstat(full);
|
|
39
|
+
}
|
|
40
|
+
catch {
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
if (st.isDirectory())
|
|
44
|
+
continue;
|
|
45
|
+
if (matchesCleanTempBasename(ent.name))
|
|
46
|
+
out.push(full);
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
if (ent.isDirectory()) {
|
|
50
|
+
await visit(full);
|
|
51
|
+
}
|
|
52
|
+
else if (ent.isFile() && matchesCleanTempBasename(ent.name)) {
|
|
53
|
+
out.push(full);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
await visit(rootAbs);
|
|
58
|
+
return out;
|
|
59
|
+
}
|
|
60
|
+
async function promptDeleteConfirmed() {
|
|
61
|
+
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
62
|
+
try {
|
|
63
|
+
const ans = await rl.question(chalk.red("\nDelete these files? (y/n) "));
|
|
64
|
+
return ans === "y";
|
|
65
|
+
}
|
|
66
|
+
finally {
|
|
67
|
+
rl.close();
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Lists `*.log` and `cache.db.backup*.sqlite` under `rootDir`, prints paths like `find -print`,
|
|
72
|
+
* then prompts unless `force` or there are no matches; deletes on exact `y`, or immediately when `force`.
|
|
73
|
+
*/
|
|
74
|
+
export async function runCleanTemp(opts) {
|
|
75
|
+
const rootAbs = path.resolve(opts.rootDir);
|
|
76
|
+
if (!fs.existsSync(rootAbs)) {
|
|
77
|
+
console.error(`Directory not found: ${rootAbs}`);
|
|
78
|
+
process.exitCode = 1;
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
const st = await fs.promises.stat(rootAbs);
|
|
82
|
+
if (!st.isDirectory()) {
|
|
83
|
+
console.error(`Not a directory: ${rootAbs}`);
|
|
84
|
+
process.exitCode = 1;
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
const files = await collectCleanTempFiles(rootAbs);
|
|
88
|
+
for (const abs of files) {
|
|
89
|
+
console.log(formatFindPrintLine(rootAbs, abs));
|
|
90
|
+
}
|
|
91
|
+
if (opts.dryRun) {
|
|
92
|
+
if (files.length > 0) {
|
|
93
|
+
console.log(chalk.gray("Dry run mode: no files will be deleted."));
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
console.log(chalk.green("Dry run mode: no files to delete."));
|
|
97
|
+
}
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
if (files.length === 0) {
|
|
101
|
+
console.log(chalk.green("No files to delete."));
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
const ok = opts.force ? true : await promptDeleteConfirmed();
|
|
105
|
+
if (!ok) {
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
for (const abs of files) {
|
|
109
|
+
try {
|
|
110
|
+
await fs.promises.unlink(abs);
|
|
111
|
+
}
|
|
112
|
+
catch (e) {
|
|
113
|
+
const msg = e instanceof Error ? e.message : String(e);
|
|
114
|
+
console.error(`Failed to delete ${formatFindPrintLine(rootAbs, abs)}: ${msg}`);
|
|
115
|
+
process.exitCode = 1;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
//# sourceMappingURL=clean-temp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clean-temp.js","sourceRoot":"","sources":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AC;QACD,OAAO;IACT,CAAC;IAED,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACvB,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,qBAAqB,CAAC,CAAC,CAAC;QAChD,OAAO;IACT,CAAC;IAED,MAAM,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,qBAAqB,EAAE,CAAC;IAC7D,IAAI,CAAC,EAAE,EAAE,CAAC;QACR,OAAO;IACT,CAAC;IAED,KAAK,MAAM,GAAG,IAAI,KAAK,EAAE,CAAC;QACxB,IAAI,CAAC;YACH,MAAM,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QAChC,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,MAAM,GAAG,GAAG,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;YACvD,OAAO,CAAC,KAAK,CAAC,oBAAoB,mBAAmB,CAAC,OAAO,EAAE,GAAG,CAAC,KAAK,GAAG,EAAE,CAAC,CAAC;YAC/E,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;QACvB,CAAC;IACH,CAAC;AACH,CAAC"}
|
|
@@ -1,11 +1,14 @@
|
|
|
1
|
-
import type { DocSegmentTranslation, I18nConfig, I18nDocTranslateConfig } from "../core/types.js";
|
|
1
|
+
import type { DocSegmentTranslation, DocumentationBlock, I18nConfig, I18nDocTranslateConfig } from "../core/types.js";
|
|
2
2
|
export type { DocSegmentTranslation };
|
|
3
3
|
import { TranslationCache } from "../core/cache.js";
|
|
4
|
+
import type { MarkdownExtractOptions } from "../extractors/markdown-extractor.js";
|
|
4
5
|
import { PlaceholderHandler } from "../processors/placeholder-handler.js";
|
|
5
6
|
import { Glossary } from "../glossary/glossary.js";
|
|
6
7
|
import { OpenRouterClient } from "../api/openrouter.js";
|
|
7
8
|
import type { DocumentBatchResponseFormat } from "../core/prompt-builder.js";
|
|
8
9
|
import { AsyncMutex } from "../utils/concurrency.js";
|
|
10
|
+
/** Same segment-extraction options as `translate-docs` for one documentation block. */
|
|
11
|
+
export declare function buildMarkdownExtractOpts(documentation: DocumentationBlock): MarkdownExtractOptions | undefined;
|
|
9
12
|
/** Batch segment prompt/response shape for `translate-docs --prompt-format`. */
|
|
10
13
|
export type TranslatePromptFormat = "xml" | "json-array" | "json-object";
|
|
11
14
|
export declare function translatePromptFormatToResponseFormat(fmt: TranslatePromptFormat | undefined): DocumentBatchResponseFormat;
|
|
@@ -96,6 +99,39 @@ export declare function jsonFileProjectRelativePath(projectRoot: string, jsonAbs
|
|
|
96
99
|
* Empty input or a path equal to the project root means no filter (translate everything).
|
|
97
100
|
*/
|
|
98
101
|
export declare function normalizePathFilterForProjectRoot(projectRoot: string, raw: string | undefined): string | undefined;
|
|
102
|
+
/**
|
|
103
|
+
* True if `relPosix` (project-relative, forward slashes) is under one of the block's
|
|
104
|
+
* `contentPaths` (file or directory roots).
|
|
105
|
+
*/
|
|
106
|
+
export declare function isProjectRelUnderBlockContentPath(projectRoot: string, relPosix: string, block: {
|
|
107
|
+
contentPaths: string[];
|
|
108
|
+
}): boolean;
|
|
109
|
+
export declare function isProjectRelUnderAnyDocumentationContentPath(projectRoot: string, relPosix: string, documentations: Array<{
|
|
110
|
+
contentPaths: string[];
|
|
111
|
+
}>): boolean;
|
|
112
|
+
/**
|
|
113
|
+
* Expand a normalized project-root `--path` / `--file` to concrete `.md` / `.mdx` paths
|
|
114
|
+
* (single file or all markdown files under a directory).
|
|
115
|
+
*/
|
|
116
|
+
export declare function expandPathFilterToMarkdownPaths(projectRoot: string, pathFilter: string | undefined): string[];
|
|
117
|
+
export interface AugmentMarkdownFromPathFilterResult {
|
|
118
|
+
markdown: string[];
|
|
119
|
+
warnings: string[];
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* When the user passes `--path` / `--file`, include matching markdown that normal discovery
|
|
123
|
+
* skipped (outside `contentPaths`, or under this block but filtered e.g. by `.translate-ignore`).
|
|
124
|
+
* Paths outside every `contentPaths` are only attached to `documentations[0]`.
|
|
125
|
+
*/
|
|
126
|
+
export declare function augmentMarkdownFilesFromPathFilter(projectRoot: string, pathFilter: string | undefined, documentationBlockIndex: number, documentations: Array<{
|
|
127
|
+
contentPaths: string[];
|
|
128
|
+
}>, markdownDiscovered: string[]): AugmentMarkdownFromPathFilterResult;
|
|
129
|
+
/**
|
|
130
|
+
* Locale-independent: read source, extract segments (same options as translation), then refresh
|
|
131
|
+
* `markdown_source_issues` and stderr warnings. Call once per markdown file before parallel
|
|
132
|
+
* per-locale work so diagnostics are not repeated for every locale.
|
|
133
|
+
*/
|
|
134
|
+
export declare function scanAndRecordMarkdownSourceIssuesForTranslate(absSource: string, relPath: string, config: I18nDocTranslateConfig, cache: TranslationCache, opts: TranslateRunOptions): Promise<void>;
|
|
99
135
|
export declare function translateMarkdownFile(absSource: string, relPath: string, locale: string, config: I18nDocTranslateConfig, cache: TranslationCache | null, client: OpenRouterClient | null, glossary: Glossary, opts: TranslateRunOptions, hitKeys: Set<string>, translatedMarkdownRelPaths: ReadonlySet<string>): Promise<{
|
|
100
136
|
skipped: boolean;
|
|
101
137
|
totals: TranslateTotals;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"doc-translate.d.ts","sourceRoot":"","sources":["../../src/cli/doc-translate.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,qBAAqB,EACrB,UAAU,EACV,sBAAsB,EAGvB,MAAM,kBAAkB,CAAC;AAI1B,YAAY,EAAE,qBAAqB,EAAE,CAAC;AAStC,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"doc-translate.d.ts","sourceRoot":"","sources":["../../src/cli/doc-translate.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,qBAAq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