ai-i18n-tools 1.3.1 → 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 +18 -12
- package/dist/build-info.generated.d.ts +1 -1
- package/dist/build-info.generated.js +1 -1
- package/dist/cli/clean-temp.d.ts.map +1 -1
- package/dist/cli/clean-temp.js +12 -2
- package/dist/cli/clean-temp.js.map +1 -1
- package/dist/cli/doc-translate.d.ts +27 -0
- package/dist/cli/doc-translate.d.ts.map +1 -1
- package/dist/cli/doc-translate.js +113 -1
- package/dist/cli/doc-translate.js.map +1 -1
- package/dist/cli/index.js +91 -15
- 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 +1 -1
- package/dist/core/cache.d.ts.map +1 -1
- package/dist/core/cache.js +1 -1
- package/dist/core/cache.js.map +1 -1
- package/dist/core/doc-file-tracking.d.ts +1 -1
- package/dist/core/doc-file-tracking.js +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 +2 -2
- package/dist/core/types.d.ts.map +1 -1
- package/dist/core/types.js +4 -4
- package/dist/core/types.js.map +1 -1
- 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 +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -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/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.map +1 -1
- package/dist/processors/markdown-source-diagnostics.js +18 -7
- package/dist/processors/markdown-source-diagnostics.js.map +1 -1
- 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/docs/GETTING_STARTED.md +233 -140
- package/docs/PACKAGE_OVERVIEW.md +25 -14
- package/docs/markdown-mdx-stress-test.md +170 -0
- package/package.json +4 -4
- package/translated-docs/README.de.md +18 -12
- package/translated-docs/README.es.md +18 -12
- package/translated-docs/README.fr.md +19 -13
- package/translated-docs/README.hi.md +18 -12
- package/translated-docs/README.ja.md +19 -13
- package/translated-docs/README.ko.md +18 -12
- package/translated-docs/README.pt-BR.md +18 -12
- package/translated-docs/README.zh-CN.md +18 -12
- package/translated-docs/README.zh-TW.md +18 -12
- package/translated-docs/docs/GETTING_STARTED.de.md +208 -115
- package/translated-docs/docs/GETTING_STARTED.es.md +207 -114
- package/translated-docs/docs/GETTING_STARTED.fr.md +206 -113
- package/translated-docs/docs/GETTING_STARTED.hi.md +209 -116
- package/translated-docs/docs/GETTING_STARTED.ja.md +209 -116
- package/translated-docs/docs/GETTING_STARTED.ko.md +209 -116
- package/translated-docs/docs/GETTING_STARTED.pt-BR.md +208 -115
- package/translated-docs/docs/GETTING_STARTED.zh-CN.md +210 -117
- package/translated-docs/docs/GETTING_STARTED.zh-TW.md +208 -115
- 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 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.
|
|
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,11 +43,11 @@ CLI and toolkit for internationalizing JavaScript/TypeScript applications and do
|
|
|
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
|
|
|
@@ -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:
|
|
@@ -221,17 +222,20 @@ 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
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
|
|
230
|
-
ai-i18n-tools translate-svg
|
|
231
|
-
|
|
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
|
|
232
234
|
ai-i18n-tools lint-source … Run extract, then LLM review of source-locale UI strings (OpenRouter)
|
|
233
|
-
ai-i18n-tools export-ui-xliff
|
|
234
|
-
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
|
|
235
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)
|
|
236
240
|
ai-i18n-tools statistics [--max-columns <n>] Documentation cache + strings.json aggregates (same as editor Statistics)
|
|
237
241
|
ai-i18n-tools editor Open cache/glossary web editor
|
|
@@ -240,7 +244,9 @@ ai-i18n-tools clean-temp [-r|--root <path>] [-f|--force] [--dry-run] List *.lo
|
|
|
240
244
|
ai-i18n-tools glossary-generate Create empty glossary CSV template
|
|
241
245
|
```
|
|
242
246
|
|
|
243
|
-
|
|
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.
|
|
244
250
|
|
|
245
251
|
---
|
|
246
252
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clean-temp.d.ts","sourceRoot":"","sources":["../../src/cli/clean-temp.ts"],"names":[],"mappings":"
|
|
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"}
|
package/dist/cli/clean-temp.js
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import readline from "node:readline/promises";
|
|
4
|
+
import chalk from "chalk";
|
|
4
5
|
/** Basenames matched by `find … \( -name '*.log' -o -name 'cache.db.backup*.sqlite' \)`. */
|
|
5
6
|
export function matchesCleanTempBasename(basename) {
|
|
6
7
|
if (basename.endsWith(".log"))
|
|
7
8
|
return true;
|
|
9
|
+
if (basename.endsWith(".tmp"))
|
|
10
|
+
return true;
|
|
8
11
|
if (basename.startsWith("cache.db.backup") && basename.endsWith(".sqlite"))
|
|
9
12
|
return true;
|
|
10
13
|
return false;
|
|
@@ -15,7 +18,7 @@ export function formatFindPrintLine(rootAbs, fileAbs) {
|
|
|
15
18
|
const norm = rel.split(path.sep).join("/");
|
|
16
19
|
if (norm === "" || norm === ".")
|
|
17
20
|
return "./";
|
|
18
|
-
return
|
|
21
|
+
return `[clean-temp]` + chalk.cyan(` ./${norm}`);
|
|
19
22
|
}
|
|
20
23
|
async function collectCleanTempFiles(rootAbs) {
|
|
21
24
|
const out = [];
|
|
@@ -57,7 +60,7 @@ async function collectCleanTempFiles(rootAbs) {
|
|
|
57
60
|
async function promptDeleteConfirmed() {
|
|
58
61
|
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
59
62
|
try {
|
|
60
|
-
const ans = await rl.question("\nDelete these files? (y/n) ");
|
|
63
|
+
const ans = await rl.question(chalk.red("\nDelete these files? (y/n) "));
|
|
61
64
|
return ans === "y";
|
|
62
65
|
}
|
|
63
66
|
finally {
|
|
@@ -86,9 +89,16 @@ export async function runCleanTemp(opts) {
|
|
|
86
89
|
console.log(formatFindPrintLine(rootAbs, abs));
|
|
87
90
|
}
|
|
88
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
|
+
}
|
|
89
98
|
return;
|
|
90
99
|
}
|
|
91
100
|
if (files.length === 0) {
|
|
101
|
+
console.log(chalk.green("No files to delete."));
|
|
92
102
|
return;
|
|
93
103
|
}
|
|
94
104
|
const ok = opts.force ? true : await promptDeleteConfirmed();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clean-temp.js","sourceRoot":"","sources":["../../src/cli/clean-temp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,QAAQ,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"clean-temp.js","sourceRoot":"","sources":["../../src/cli/clean-temp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,QAAQ,MAAM,wBAAwB,CAAC;AAC9C,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,4FAA4F;AAC5F,MAAM,UAAU,wBAAwB,CAAC,QAAgB;IACvD,IAAI,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC;QAAE,OAAO,IAAI,CAAC;IAC3C,IAAI,QAAQ,CAAC,QAAQ,CA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ED,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"}
|
|
@@ -99,6 +99,33 @@ export declare function jsonFileProjectRelativePath(projectRoot: string, jsonAbs
|
|
|
99
99
|
* Empty input or a path equal to the project root means no filter (translate everything).
|
|
100
100
|
*/
|
|
101
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;
|
|
102
129
|
/**
|
|
103
130
|
* Locale-independent: read source, extract segments (same options as translation), then refresh
|
|
104
131
|
* `markdown_source_issues` and stderr warnings. Call once per markdown file before parallel
|
|
@@ -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,kBAAkB,EAClB,UAAU,EACV,sBAAsB,EAGvB,MAAM,kBAAkB,CAAC;AAI1B,YAAY,EAAE,qBAAqB,EAAE,CAAC;AAStC,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEpD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,qCAAqC,CAAC;AAGlF,OAAO,EAAE,kBAAkB,EAAE,MAAM,sCAAsC,CAAC;AAM1E,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"doc-translate.d.ts","sourceRoot":"","sources":["../../src/cli/doc-translate.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,qBAAqB,EACrB,kBAAkB,EAClB,UAAU,EACV,sBAAsB,EAGvB,MAAM,kBAAkB,CAAC;AAI1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AAM,EAAE,UAAU,EAClB,KAAK,EAAE,gBAAgB,GAAG,IAAI,EAC9B,MAAM,EAAE,gBAAgB,GAAG,IAAI,EAC/B,QAAQ,EAAE,QAAQ,EAClB,IAAI,EAAE,mBAAmB,EACzB,OAAO,EAAE,GAAG,CAAC,MAAM,CAAC,GACnB,OAAO,CAAC;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,eAAe,CAAA;CAAE,CAAC,CAmOxD;AAED,wBAAgB,uCAAuC,CACrD,MAAM,EAAE,sBAAsB,EAC9B,IAAI,EAAE,mBAAmB,EACzB,aAAa,EAAE,MAAM,EAAE,GACtB,MAAM,CAmCR;AAyDD,uDAAuD;AACvD,wBAAsB,YAAY,CAChC,MAAM,EAAE,sBAAsB,EAC9B,IAAI,EAAE,mBAAmB,EACzB,KAAK,EAAE;IACL,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,IAAI,EAAE,MAAM,EAAE,CAAC;CAChB,EACD,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,eAAe,CAAC,CA2T1B"}
|
|
@@ -25,6 +25,7 @@ import { applyMarkdownLanguageListPostProcessing, applyMarkdownPostProcessing, }
|
|
|
25
25
|
import { resolveSvgAssetOutputPath, svgAssetCacheFilepath, svgTranslationFilepathMetadata, } from "../core/svg-asset-paths.js";
|
|
26
26
|
import { ensureDirForFile, hashFileContent, resolveTranslatedOutputPath, writeAtomicUtf8, } from "./helpers.js";
|
|
27
27
|
import { normalizeLocale } from "../core/config.js";
|
|
28
|
+
import { collectFilesByExtension } from "./file-utils.js";
|
|
28
29
|
import { runMapWithConcurrency, AsyncSemaphore, AsyncMutex } from "../utils/concurrency.js";
|
|
29
30
|
import { describeEmphasisPlaceholdersPolicy, resolveMarkdownEmphasisPlaceholders, usesAutomaticEmphasisPlaceholdersForLocale, } from "../core/markdown-emphasis-defaults.js";
|
|
30
31
|
import { collectMarkdownIssuesForSegment } from "../processors/markdown-source-diagnostics.js";
|
|
@@ -59,6 +60,9 @@ function emptyMarkdownProtectShell() {
|
|
|
59
60
|
endMap: [],
|
|
60
61
|
htmlAnchors: [],
|
|
61
62
|
docusaurusHeadingIds: [],
|
|
63
|
+
mdxMap: [],
|
|
64
|
+
jsxAttributeMap: [],
|
|
65
|
+
jsxAttributeText: undefined,
|
|
62
66
|
urlMap: [],
|
|
63
67
|
boldCodeMap: [],
|
|
64
68
|
ilcMap: [],
|
|
@@ -72,8 +76,12 @@ export function protectSegmentForTranslation(raw, glossary, locale, useMarkdownP
|
|
|
72
76
|
if (useMarkdownPlaceholders) {
|
|
73
77
|
const ph = new PlaceholderHandler();
|
|
74
78
|
const st = ph.protectForTranslation(g.text, { emphasis: emphasisPlaceholders });
|
|
79
|
+
let segmentText = st.text;
|
|
80
|
+
if (st.jsxAttributeText) {
|
|
81
|
+
segmentText = `${segmentText}\n${st.jsxAttributeText}`;
|
|
82
|
+
}
|
|
75
83
|
return {
|
|
76
|
-
text:
|
|
84
|
+
text: segmentText,
|
|
77
85
|
state: {
|
|
78
86
|
...st,
|
|
79
87
|
glossaryForceReplacements: glossaryForceReplacements.length > 0 ? glossaryForceReplacements : undefined,
|
|
@@ -243,6 +251,110 @@ export function normalizePathFilterForProjectRoot(projectRoot, raw) {
|
|
|
243
251
|
}
|
|
244
252
|
return norm;
|
|
245
253
|
}
|
|
254
|
+
const DOC_MARKDOWN_EXTENSIONS = [".md", ".mdx"];
|
|
255
|
+
/**
|
|
256
|
+
* True if `relPosix` (project-relative, forward slashes) is under one of the block's
|
|
257
|
+
* `contentPaths` (file or directory roots).
|
|
258
|
+
*/
|
|
259
|
+
export function isProjectRelUnderBlockContentPath(projectRoot, relPosix, block) {
|
|
260
|
+
const r = relPosix.replace(/\\/g, "/");
|
|
261
|
+
for (const cp of block.contentPaths) {
|
|
262
|
+
const rootRel = path
|
|
263
|
+
.relative(projectRoot, path.resolve(projectRoot, cp))
|
|
264
|
+
.split(path.sep)
|
|
265
|
+
.join("/");
|
|
266
|
+
if (rootRel === "" || rootRel === ".") {
|
|
267
|
+
return true;
|
|
268
|
+
}
|
|
269
|
+
if (r === rootRel || r.startsWith(`${rootRel}/`)) {
|
|
270
|
+
return true;
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
return false;
|
|
274
|
+
}
|
|
275
|
+
export function isProjectRelUnderAnyDocumentationContentPath(projectRoot, relPosix, documentations) {
|
|
276
|
+
for (const block of documentations) {
|
|
277
|
+
if (isProjectRelUnderBlockContentPath(projectRoot, relPosix, block)) {
|
|
278
|
+
return true;
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
return false;
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* Expand a normalized project-root `--path` / `--file` to concrete `.md` / `.mdx` paths
|
|
285
|
+
* (single file or all markdown files under a directory).
|
|
286
|
+
*/
|
|
287
|
+
export function expandPathFilterToMarkdownPaths(projectRoot, pathFilter) {
|
|
288
|
+
if (!pathFilter?.trim()) {
|
|
289
|
+
return [];
|
|
290
|
+
}
|
|
291
|
+
const abs = path.resolve(projectRoot, pathFilter);
|
|
292
|
+
if (!fs.existsSync(abs)) {
|
|
293
|
+
return [];
|
|
294
|
+
}
|
|
295
|
+
const st = fs.statSync(abs);
|
|
296
|
+
if (st.isFile()) {
|
|
297
|
+
const ext = path.extname(abs).toLowerCase();
|
|
298
|
+
if (ext === ".md" || ext === ".mdx") {
|
|
299
|
+
return [path.relative(projectRoot, abs).split(path.sep).join("/")];
|
|
300
|
+
}
|
|
301
|
+
return [];
|
|
302
|
+
}
|
|
303
|
+
if (st.isDirectory()) {
|
|
304
|
+
return collectFilesByExtension([abs], [...DOC_MARKDOWN_EXTENSIONS], projectRoot);
|
|
305
|
+
}
|
|
306
|
+
return [];
|
|
307
|
+
}
|
|
308
|
+
/**
|
|
309
|
+
* When the user passes `--path` / `--file`, include matching markdown that normal discovery
|
|
310
|
+
* skipped (outside `contentPaths`, or under this block but filtered e.g. by `.translate-ignore`).
|
|
311
|
+
* Paths outside every `contentPaths` are only attached to `documentations[0]`.
|
|
312
|
+
*/
|
|
313
|
+
export function augmentMarkdownFilesFromPathFilter(projectRoot, pathFilter, documentationBlockIndex, documentations, markdownDiscovered) {
|
|
314
|
+
const warnings = [];
|
|
315
|
+
if (!pathFilter?.trim() || documentations.length === 0) {
|
|
316
|
+
return { markdown: markdownDiscovered, warnings };
|
|
317
|
+
}
|
|
318
|
+
const block = documentations[documentationBlockIndex];
|
|
319
|
+
if (!block) {
|
|
320
|
+
return { markdown: markdownDiscovered, warnings };
|
|
321
|
+
}
|
|
322
|
+
const candidates = expandPathFilterToMarkdownPaths(projectRoot, pathFilter);
|
|
323
|
+
if (candidates.length === 0) {
|
|
324
|
+
return { markdown: markdownDiscovered, warnings };
|
|
325
|
+
}
|
|
326
|
+
const seen = new Set(markdownDiscovered);
|
|
327
|
+
let md = markdownDiscovered;
|
|
328
|
+
for (const rel of candidates) {
|
|
329
|
+
if (seen.has(rel)) {
|
|
330
|
+
continue;
|
|
331
|
+
}
|
|
332
|
+
const abs = path.join(projectRoot, rel);
|
|
333
|
+
if (!fs.existsSync(abs)) {
|
|
334
|
+
continue;
|
|
335
|
+
}
|
|
336
|
+
const underThis = isProjectRelUnderBlockContentPath(projectRoot, rel, block);
|
|
337
|
+
const underAny = isProjectRelUnderAnyDocumentationContentPath(projectRoot, rel, documentations);
|
|
338
|
+
if (underThis) {
|
|
339
|
+
if (!md.includes(rel)) {
|
|
340
|
+
md = [...md, rel];
|
|
341
|
+
seen.add(rel);
|
|
342
|
+
warnings.push(`${rel}: explicit --path/--file was not in the discovered file set (e.g. outside contentPaths or excluded by .translate-ignore); translating with documentations[${documentationBlockIndex}].`);
|
|
343
|
+
}
|
|
344
|
+
continue;
|
|
345
|
+
}
|
|
346
|
+
if (underAny) {
|
|
347
|
+
/* Owned by another documentations[] block; that iteration handles it (or augments there). */
|
|
348
|
+
continue;
|
|
349
|
+
}
|
|
350
|
+
if (documentationBlockIndex === 0) {
|
|
351
|
+
md = [...md, rel];
|
|
352
|
+
seen.add(rel);
|
|
353
|
+
warnings.push(`${rel} is outside every documentations[].contentPaths — translating with documentations[0] output settings.`);
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
return { markdown: [...new Set(md)].sort(), warnings };
|
|
357
|
+
}
|
|
246
358
|
async function withCacheMutex(mutex, fn) {
|
|
247
359
|
if (!mutex) {
|
|
248
360
|
return fn();
|