@menapo/vi18n 0.1.2 → 0.2.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 +19 -0
- package/dist/{apply-FAHl1R6T.js → apply-Bg-3rB2m.js} +4 -4
- package/dist/{captured-CTjjDF5o.js → captured-DfLk50Ji.js} +1 -1
- package/dist/{check-DwFwOB1d.js → check-CunekuYs.js} +16 -7
- package/dist/cli.js +1 -1
- package/dist/{collisions-uMTuq36M.js → collisions-CDSdtLQm.js} +2 -2
- package/dist/{compile-CEvH-6sY.js → compile-hva0qjhZ.js} +6 -6
- package/dist/config.d.ts +1 -1
- package/dist/config.js +2 -2
- package/dist/{diagnostics-1onDF6Ua.js → diagnostics-LgIWyeSp.js} +2 -1
- package/dist/{duplicates-CsUXRX2J.js → duplicates-8cudcHNj.js} +1 -1
- package/dist/{engine-Bf7nVigL.js → engine-ecRD8-IE.js} +11 -11
- package/dist/engine.d.ts +1 -1
- package/dist/{exchange-DYG9RZoT.js → exchange-DjwlrTQ9.js} +3 -3
- package/dist/{exclude-vMnm3lqU.js → exclude-BFETmvde.js} +1 -1
- package/dist/{export-BYq0gfLd.js → export-D2tsqWIr.js} +6 -6
- package/dist/{extract-CYtuEo8u.js → extract-BxYchVmY.js} +7 -7
- package/dist/{formats-ChV1LVH_.js → formats-BaryZ2N7.js} +3 -3
- package/dist/{i18next-D66Icz3L.js → i18next-COO6o0tX.js} +6 -6
- package/dist/i18next-Dr7DCQlQ.js +1 -0
- package/dist/{import-BApbQlmm.js → import-vSC29Cn4.js} +6 -6
- package/dist/index.d.ts +1 -1
- package/dist/{init-J7AwwA5e.js → init-Cc7A-8VX.js} +9 -9
- package/dist/{library-BfSOBeBd.js → library-tp_xqzSY.js} +2 -2
- package/dist/{lingui-Ee2farVo.js → lingui-BnnlqGXT.js} +8 -8
- package/dist/lint.js +7 -6
- package/dist/{load-BFLLqY8x.js → load-BSIeGJ5v.js} +8 -6
- package/dist/{load-CMwhukZ4.js → load-SSrAeJVB.js} +5 -3
- package/dist/{locales-DxLDrx-h.js → locales-D0U-yVRm.js} +4 -4
- package/dist/{lsp-BC7xDGON.js → lsp-DvC11pBZ.js} +2 -2
- package/dist/{mcp-Cka8ywDF.js → mcp-D2zzOTBy.js} +2 -2
- package/dist/{merge-driver-B04Apm29.js → merge-driver-BLI8OtAc.js} +6 -6
- package/dist/migrate-1r43OBfe.js +1 -0
- package/dist/{migrate-D7TNl6SD.js → migrate-ChDGhlC-.js} +11 -11
- package/dist/{openai-RWw0YlAx.js → openai-CLn4puY8.js} +1 -1
- package/dist/{output-CF9uvk_-.js → output-D5tAt8q4.js} +3 -3
- package/dist/parse.d.ts +1 -1
- package/dist/{pipeline-sgl_q_op.js → pipeline-BJSkkRYC.js} +7 -7
- package/dist/{pipeline-B30irGMD.js → pipeline-BeCc441z.js} +1 -1
- package/dist/{project-DSzWKU3C.js → project-B5KIO0q-.js} +9 -9
- package/dist/{pseudo-DNbNNVGP.js → pseudo-B2DUpoLu.js} +2 -1
- package/dist/{react-intl-tzGIk6G3.js → react-intl-C8JehBBL.js} +6 -6
- package/dist/rename-ZVGq9ZG1.js +577 -0
- package/dist/repeated-uuI1tUGg.js +85 -0
- package/dist/{restore-BG_zMpSj.js → restore-xlBIrtRt.js} +8 -8
- package/dist/{rewrite-hAcRJwiZ.js → rewrite-BwzXoBiA.js} +1 -1
- package/dist/{run-CFzR3V93.js → run-CQ9pDLSa.js} +50 -23
- package/dist/scan-worker.d.ts +1 -1
- package/dist/scan-worker.js +1 -1
- package/dist/{server-ceuzzkal.js → server-Br8tAuG2.js} +28 -8
- package/dist/{server-WlxZH0oX.js → server-DJRpUQVZ.js} +793 -12
- package/dist/server.d.ts +1 -1
- package/dist/server.js +7 -1
- package/dist/{sitemap-796jJKUT.js → sitemap-CSAkm6oi.js} +4 -4
- package/dist/{sources-DuOdM02f.js → sources-DNVbYsgs.js} +4 -3
- package/dist/{status-CTH3qI-0.js → status-q6M3rBrh.js} +3 -3
- package/dist/{sync-CpL0Qsgw.js → sync-BNIAwMhR.js} +6 -6
- package/dist/test.d.ts +1 -1
- package/dist/test.js +53 -12
- package/dist/{translate-BrfVRkjl.js → translate-BP4iVhOR.js} +6 -6
- package/dist/{types-BaG1LboH.d.ts → types-B4wNX6PA.d.ts} +4 -2
- package/dist/{types-Cy2bPdSg.d.ts → types-_4UdFhR9.d.ts} +10 -1
- package/dist/{types-Ds_vebja.js → types-xR2exI3L.js} +1 -0
- package/dist/{units-VVLgQ7x7.js → units-DPPfCN7j.js} +3 -3
- package/dist/{validate-zv4-IZyZ.js → validate-CgzaDdOY.js} +2 -2
- package/dist/{version-BFs370Ce.js → version-DC-J5WvV.js} +2 -2
- package/dist/{vite-scan-DFKSGVE9.js → vite-scan-kM8Ta3rO.js} +6 -6
- package/dist/vite.d.ts +1 -1
- package/dist/vite.js +20 -16
- package/dist/{vue-i18n-CBmZqHbG.js → vue-i18n-_uIXlFVh.js} +6 -6
- package/dist/{which-BpyJyBkX.js → which-DFWk_KwN.js} +8 -8
- package/dist/{worker-BjzVqJVO.js → worker-zlhNj4y3.js} +4 -4
- package/package.json +1 -1
- package/dist/i18next-1waHziMy.js +0 -1
- package/dist/migrate-khCY8TE0.js +0 -1
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
// src/core/extract/repeated.ts
|
|
2
|
+
/** The ids' literal call sites: `msg()` declares, the rest translate. */
|
|
3
|
+
const WRITES_TEXT = /* @__PURE__ */ new Set([
|
|
4
|
+
"t",
|
|
5
|
+
"rich",
|
|
6
|
+
"richHtml",
|
|
7
|
+
"richParts",
|
|
8
|
+
"alias",
|
|
9
|
+
"global",
|
|
10
|
+
"translator"
|
|
11
|
+
]);
|
|
12
|
+
/** Whether the occurrence is a literal call site the check counts. */
|
|
13
|
+
function writesText(occurrence) {
|
|
14
|
+
return WRITES_TEXT.has(occurrence.callee) && !occurrence.manual && occurrence.ignored !== true;
|
|
15
|
+
}
|
|
16
|
+
function bySite(a, b) {
|
|
17
|
+
if (a.file !== b.file) return a.file < b.file ? -1 : 1;
|
|
18
|
+
return a.line - b.line || a.column - b.column;
|
|
19
|
+
}
|
|
20
|
+
/** The texts written at `threshold` call sites or more, in the order their first sites appear. */
|
|
21
|
+
function repeatedTexts(occurrences, threshold) {
|
|
22
|
+
const byId = /* @__PURE__ */ new Map();
|
|
23
|
+
for (const occurrence of occurrences) {
|
|
24
|
+
if (!writesText(occurrence)) continue;
|
|
25
|
+
const site = {
|
|
26
|
+
file: occurrence.file,
|
|
27
|
+
line: occurrence.line,
|
|
28
|
+
column: occurrence.column,
|
|
29
|
+
callee: occurrence.callee
|
|
30
|
+
};
|
|
31
|
+
if (occurrence.context !== void 0 || occurrence.maxLength !== void 0) site.annotated = true;
|
|
32
|
+
const known = byId.get(occurrence.id);
|
|
33
|
+
if (known === void 0) byId.set(occurrence.id, {
|
|
34
|
+
id: occurrence.id,
|
|
35
|
+
source: occurrence.source,
|
|
36
|
+
sites: [site]
|
|
37
|
+
});
|
|
38
|
+
else known.sites.push(site);
|
|
39
|
+
}
|
|
40
|
+
const found = [];
|
|
41
|
+
for (const text of byId.values()) {
|
|
42
|
+
if (text.sites.length < threshold) continue;
|
|
43
|
+
text.sites.sort(bySite);
|
|
44
|
+
found.push(text);
|
|
45
|
+
}
|
|
46
|
+
return found.sort((a, b) => bySite(a.sites[0], b.sites[0]));
|
|
47
|
+
}
|
|
48
|
+
/** The text as a message shows it in a sentence: quoted, cut at 40 characters. */
|
|
49
|
+
function quoted(source) {
|
|
50
|
+
const flat = source.replace(/\s+/g, " ").trim();
|
|
51
|
+
return `"${flat.length > 40 ? `${flat.slice(0, 39)}…` : flat}"`;
|
|
52
|
+
}
|
|
53
|
+
/** One warning per site after the first, so the first stays the place the message is declared from. */
|
|
54
|
+
function repeatedDiagnostics(texts) {
|
|
55
|
+
const out = [];
|
|
56
|
+
for (const text of texts) {
|
|
57
|
+
const [first, ...rest] = text.sites;
|
|
58
|
+
const count = text.sites.length;
|
|
59
|
+
const origin = {
|
|
60
|
+
file: first.file,
|
|
61
|
+
message: `first of the ${count} sites`
|
|
62
|
+
};
|
|
63
|
+
if (first.line > 0) Object.assign(origin, {
|
|
64
|
+
line: first.line,
|
|
65
|
+
column: first.column
|
|
66
|
+
});
|
|
67
|
+
for (const site of rest) {
|
|
68
|
+
const diagnostic = {
|
|
69
|
+
code: "extract-repeated-text",
|
|
70
|
+
severity: "warning",
|
|
71
|
+
message: `${quoted(text.source)} is written at ${count} call sites; declare it once with msg() and use t(ref), so one edit changes every site`,
|
|
72
|
+
file: site.file,
|
|
73
|
+
id: text.id,
|
|
74
|
+
related: [origin]
|
|
75
|
+
};
|
|
76
|
+
if (site.line > 0) Object.assign(diagnostic, {
|
|
77
|
+
line: site.line,
|
|
78
|
+
column: site.column
|
|
79
|
+
});
|
|
80
|
+
out.push(diagnostic);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return out;
|
|
84
|
+
}
|
|
85
|
+
export { writesText as i, repeatedDiagnostics as n, repeatedTexts as r, quoted as t };
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { d as parseCatalogBytes } from "./library-
|
|
2
|
-
import {
|
|
3
|
-
import { n as applyRestore } from "./apply-
|
|
4
|
-
import { s as sourceIndexOf } from "./units-
|
|
5
|
-
import { i as rootRelative, o as errorMessage, r as plural } from "./output-
|
|
6
|
-
import { n as sourceContext, t as applyToCatalog } from "./exchange-
|
|
7
|
-
import { f as readErrors, h as targetLocales, o as loadCatalogs, s as loadProject, t as CliExit } from "./project-
|
|
8
|
-
import { r as EXIT } from "./types-
|
|
1
|
+
import { d as parseCatalogBytes } from "./library-tp_xqzSY.js";
|
|
2
|
+
import { p as createCodec, v as parseIdScheme } from "./validate-CgzaDdOY.js";
|
|
3
|
+
import { n as applyRestore } from "./apply-Bg-3rB2m.js";
|
|
4
|
+
import { s as sourceIndexOf } from "./units-DPPfCN7j.js";
|
|
5
|
+
import { i as rootRelative, o as errorMessage, r as plural } from "./output-D5tAt8q4.js";
|
|
6
|
+
import { n as sourceContext, t as applyToCatalog } from "./exchange-DjwlrTQ9.js";
|
|
7
|
+
import { f as readErrors, h as targetLocales, o as loadCatalogs, s as loadProject, t as CliExit } from "./project-B5KIO0q-.js";
|
|
8
|
+
import { r as EXIT } from "./types-xR2exI3L.js";
|
|
9
9
|
import { basename, dirname } from "node:path";
|
|
10
10
|
import { promisify } from "node:util";
|
|
11
11
|
import { execFile } from "node:child_process";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { L as lineRange, O as isConsumed, R as listItemRange, k as isNameFree, o as importLineEdit } from "./migrate-
|
|
1
|
+
import { L as lineRange, O as isConsumed, R as listItemRange, k as isNameFree, o as importLineEdit } from "./migrate-ChDGhlC-.js";
|
|
2
2
|
// src/cli/commands/migrate/rewrite.ts
|
|
3
3
|
/**
|
|
4
4
|
* Planned file edits for the library codemods (INTERNALS §2.14). An edit
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { i as DEFAULT_CONFIG, n as isDiagnosticError } from "./diagnostics-
|
|
2
|
-
import { t as VERSION } from "./version-
|
|
3
|
-
import { t as PROVIDER_PRESETS } from "./openai-
|
|
4
|
-
import { t as EXCHANGE_FORMATS } from "./units-
|
|
5
|
-
import { a as MIGRATIONS, i as LIBRARIES, n as COMMAND_NAMES, r as EXIT, t as CHECK_CATEGORIES } from "./types-
|
|
6
|
-
import { n as createOutput, o as errorMessage } from "./output-
|
|
7
|
-
import { t as CliExit } from "./project-
|
|
1
|
+
import { i as DEFAULT_CONFIG, n as isDiagnosticError } from "./diagnostics-LgIWyeSp.js";
|
|
2
|
+
import { t as VERSION } from "./version-DC-J5WvV.js";
|
|
3
|
+
import { t as PROVIDER_PRESETS } from "./openai-CLn4puY8.js";
|
|
4
|
+
import { t as EXCHANGE_FORMATS } from "./units-DPPfCN7j.js";
|
|
5
|
+
import { a as MIGRATIONS, i as LIBRARIES, n as COMMAND_NAMES, r as EXIT, t as CHECK_CATEGORIES } from "./types-xR2exI3L.js";
|
|
6
|
+
import { n as createOutput, o as errorMessage } from "./output-D5tAt8q4.js";
|
|
7
|
+
import { t as CliExit } from "./project-B5KIO0q-.js";
|
|
8
8
|
import { resolve } from "node:path";
|
|
9
9
|
import { parseArgs } from "node:util";
|
|
10
10
|
// src/cli/args.ts
|
|
@@ -333,6 +333,18 @@ function restoreFlags({ values }) {
|
|
|
333
333
|
dryRun: bool(values["dry-run"])
|
|
334
334
|
};
|
|
335
335
|
}
|
|
336
|
+
function renameFlags({ values, positionals }) {
|
|
337
|
+
if (positionals.length !== 2) throw new UsageError("expected <old> <new>: the text as written in the code, then the text it becomes (quote each: vi18n rename \"Sign in\" \"Log in\")");
|
|
338
|
+
const [from, to] = positionals;
|
|
339
|
+
if (from === to) throw new UsageError("<new> is the same text as <old>; there is nothing to rename");
|
|
340
|
+
return {
|
|
341
|
+
from,
|
|
342
|
+
to,
|
|
343
|
+
write: bool(values.write),
|
|
344
|
+
review: bool(values.review),
|
|
345
|
+
merge: bool(values.merge)
|
|
346
|
+
};
|
|
347
|
+
}
|
|
336
348
|
function whichFlags({ positionals }) {
|
|
337
349
|
const query = positionals.join(" ");
|
|
338
350
|
if (query.trim() === "") throw new UsageError("name an id, the start of one, or source text");
|
|
@@ -476,6 +488,15 @@ const SPECS = {
|
|
|
476
488
|
},
|
|
477
489
|
flags: restoreFlags
|
|
478
490
|
},
|
|
491
|
+
rename: {
|
|
492
|
+
options: {
|
|
493
|
+
write: { type: "boolean" },
|
|
494
|
+
review: { type: "boolean" },
|
|
495
|
+
merge: { type: "boolean" }
|
|
496
|
+
},
|
|
497
|
+
positional: true,
|
|
498
|
+
flags: renameFlags
|
|
499
|
+
},
|
|
479
500
|
which: {
|
|
480
501
|
options: {},
|
|
481
502
|
positional: true,
|
|
@@ -540,6 +561,11 @@ const COMMAND_HELP = {
|
|
|
540
561
|
entry's exact source; reports what changed and what was skipped. --dry-run writes nothing.`,
|
|
541
562
|
restore: `vi18n restore --from <git-rev> [--locale <l>]… [--dry-run]
|
|
542
563
|
Fill empty entries from that revision's catalogs by exact source text or manual id.`,
|
|
564
|
+
rename: `vi18n rename <old> <new> [--write] [--review] [--merge]
|
|
565
|
+
Change a text at every call site and in every catalog, keeping its translations. <old> is the
|
|
566
|
+
text as written in the code; every t(), msg() and rich() with that text changes, a manual id
|
|
567
|
+
stays. Prints the plan; --write applies it (all files or none). --review marks the carried
|
|
568
|
+
translations fuzzy; --merge lets <new> be a message the code already has.`,
|
|
543
569
|
which: `vi18n which <id|prefix|text>
|
|
544
570
|
Print a message's id, source text, call sites and catalog entries.`,
|
|
545
571
|
"merge-driver": `vi18n merge-driver <base> <ours> <theirs> [<path>]
|
|
@@ -565,25 +591,26 @@ function helpText(command, version) {
|
|
|
565
591
|
*/
|
|
566
592
|
/**
|
|
567
593
|
* Each command loads only its own code: every CLI run is a fresh process,
|
|
568
|
-
* and loading
|
|
594
|
+
* and loading every command made `extract` parse the AI, exchange and MF2
|
|
569
595
|
* modules it never calls.
|
|
570
596
|
*/
|
|
571
597
|
const RUNNERS = {
|
|
572
|
-
init: async () => (await import("./init-
|
|
573
|
-
extract: async () => (await import("./extract-
|
|
574
|
-
check: async () => (await import("./check-
|
|
575
|
-
status: async () => (await import("./status-
|
|
576
|
-
compile: async () => (await import("./compile-
|
|
577
|
-
translate: async () => (await import("./translate-
|
|
578
|
-
migrate: async () => (await import("./migrate-
|
|
579
|
-
sitemap: async () => (await import("./sitemap-
|
|
580
|
-
export: async () => (await import("./export-
|
|
581
|
-
import: async () => (await import("./import-
|
|
582
|
-
restore: async () => (await import("./restore-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
598
|
+
init: async () => (await import("./init-Cc7A-8VX.js")).init,
|
|
599
|
+
extract: async () => (await import("./extract-BxYchVmY.js")).extract,
|
|
600
|
+
check: async () => (await import("./check-CunekuYs.js")).check,
|
|
601
|
+
status: async () => (await import("./status-q6M3rBrh.js")).status,
|
|
602
|
+
compile: async () => (await import("./compile-hva0qjhZ.js")).compile,
|
|
603
|
+
translate: async () => (await import("./translate-BP4iVhOR.js")).translate,
|
|
604
|
+
migrate: async () => (await import("./migrate-1r43OBfe.js")).migrate,
|
|
605
|
+
sitemap: async () => (await import("./sitemap-CSAkm6oi.js")).sitemap,
|
|
606
|
+
export: async () => (await import("./export-D2tsqWIr.js")).exportCatalogs,
|
|
607
|
+
import: async () => (await import("./import-vSC29Cn4.js")).importCatalogs,
|
|
608
|
+
restore: async () => (await import("./restore-xlBIrtRt.js")).restore,
|
|
609
|
+
rename: async () => (await import("./rename-ZVGq9ZG1.js")).rename,
|
|
610
|
+
which: async () => (await import("./which-DFWk_KwN.js")).which,
|
|
611
|
+
"merge-driver": async () => (await import("./merge-driver-BLI8OtAc.js")).mergeDriver,
|
|
612
|
+
lsp: async () => (await import("./lsp-DvC11pBZ.js")).lsp,
|
|
613
|
+
mcp: async () => (await import("./mcp-D2zzOTBy.js")).mcp
|
|
587
614
|
};
|
|
588
615
|
async function runCommand(command, ctx, flags) {
|
|
589
616
|
return (await RUNNERS[command]())(ctx, flags);
|
package/dist/scan-worker.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _ as MessageOccurrence, g as MessageCodec, h as Diagnostic, i as ResolvedConfig } from "./types-
|
|
1
|
+
import { _ as MessageOccurrence, g as MessageCodec, h as Diagnostic, i as ResolvedConfig } from "./types-_4UdFhR9.js";
|
|
2
2
|
export interface FileTask {
|
|
3
3
|
/** Absolute path (a realpath from the file walk). */
|
|
4
4
|
file: string;
|
package/dist/scan-worker.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { t as ABORT_CODES, n as WORKER_MARKER, r as scanConfig, i as scanSource } from "./worker-
|
|
1
|
+
export { t as ABORT_CODES, n as WORKER_MARKER, r as scanConfig, i as scanSource } from "./worker-zlhNj4y3.js";
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { o as __toESM, t as __commonJSMin } from "./rolldown-runtime-C1I3wEg2.js";
|
|
2
2
|
import { A as PingRequestSchema, B as isJSONRPCNotification, C as ListResourcesRequestSchema, D as ListToolsRequestSchema, E as ListTasksResultSchema, F as SetLevelRequestSchema, H as isJSONRPCResultResponse, I as TaskStatusNotificationSchema, L as assertCompleteRequestPrompt, M as RELATED_TASK_META_KEY, N as ReadResourceRequestSchema, O as LoggingLevelSchema, P as SUPPORTED_PROTOCOL_VERSIONS, R as assertCompleteRequestResourceTemplate, S as ListResourceTemplatesRequestSchema, T as ListTasksRequestSchema, U as isTaskAugmentedRequestParams, V as isJSONRPCRequest, _ as InitializeRequestSchema, a as CancelledNotificationSchema, b as LATEST_PROTOCOL_VERSION, c as CreateMessageResultWithToolsSchema, d as EmptyResultSchema, f as ErrorCode, g as GetTaskResultSchema, h as GetTaskRequestSchema, i as CancelTaskResultSchema, j as ProgressNotificationSchema, k as McpError, l as CreateTaskResultSchema, m as GetTaskPayloadRequestSchema, n as CallToolResultSchema, o as CompleteRequestSchema, p as GetPromptRequestSchema, r as CancelTaskRequestSchema, s as CreateMessageResultSchema, t as CallToolRequestSchema, u as ElicitResultSchema, v as InitializedNotificationSchema, w as ListRootsResultSchema, x as ListPromptsRequestSchema, z as isJSONRPCErrorResponse } from "./types-3kwyaCAm.js";
|
|
3
|
-
import { n as catalogPersister } from "./pipeline-
|
|
4
|
-
import { l as loadCatalogSet } from "./library-
|
|
5
|
-
import { n as isDiagnosticError } from "./diagnostics-
|
|
6
|
-
import { t as VERSION } from "./version-
|
|
7
|
-
import { S as checkTranslation, m as scan, o as loadCatalogs, p as referencedMessages, s as loadProject, t as CliExit, v as indexCatalogs, x as messageView } from "./project-
|
|
8
|
-
import { n as createOutput } from "./output-
|
|
9
|
-
import { t as run } from "./run-
|
|
10
|
-
import { t as CHECK_CATEGORIES } from "./types-
|
|
3
|
+
import { n as catalogPersister } from "./pipeline-BJSkkRYC.js";
|
|
4
|
+
import { l as loadCatalogSet } from "./library-tp_xqzSY.js";
|
|
5
|
+
import { n as isDiagnosticError } from "./diagnostics-LgIWyeSp.js";
|
|
6
|
+
import { t as VERSION } from "./version-DC-J5WvV.js";
|
|
7
|
+
import { S as checkTranslation, m as scan, o as loadCatalogs, p as referencedMessages, s as loadProject, t as CliExit, v as indexCatalogs, x as messageView } from "./project-B5KIO0q-.js";
|
|
8
|
+
import { n as createOutput } from "./output-D5tAt8q4.js";
|
|
9
|
+
import { t as run } from "./run-CQ9pDLSa.js";
|
|
10
|
+
import { t as CHECK_CATEGORIES } from "./types-xR2exI3L.js";
|
|
11
11
|
import { ZodOptional, z } from "zod";
|
|
12
12
|
import * as z3rt from "zod/v3";
|
|
13
13
|
import { ZodFirstPartyTypeKind } from "zod/v3";
|
|
@@ -10038,6 +10038,7 @@ const INSTRUCTIONS = `vi18n keeps a Vite app's messages in gettext PO or JSON ca
|
|
|
10038
10038
|
- status: progress per locale. check: what fails CI (missing, placeholders, syntax). extract_check / compile_check: whether committed files are up to date.
|
|
10039
10039
|
- get_message: one message by id (ids appear in status, check and catalog files): source, call sites, every locale's translation and state.
|
|
10040
10040
|
- set_translation: write one translation. It must be valid ICU with the source's arguments and tags; pass expected (the translation get_message showed) so a concurrent edit is not overwritten.
|
|
10041
|
+
- rename_dry_run: what changing a text everywhere (vi18n rename) would touch, keeping translations; it writes nothing.
|
|
10041
10042
|
- translate_dry_run: what AI translation of the missing messages would cost; it calls no provider.`;
|
|
10042
10043
|
/** Tool calls one at a time, and a way to wait until none is running or queued. */
|
|
10043
10044
|
var ToolQueue = class {
|
|
@@ -10072,6 +10073,7 @@ function buildMcpServer(options) {
|
|
|
10072
10073
|
const command = (argv) => queue.run(() => runCommand(options, argv));
|
|
10073
10074
|
registerCommandTools(server, command);
|
|
10074
10075
|
registerOutputTools(server, command);
|
|
10076
|
+
registerRenameTool(server, command);
|
|
10075
10077
|
registerMessageTools(server, (body) => queue.run(() => runTool(options, body)));
|
|
10076
10078
|
return {
|
|
10077
10079
|
server,
|
|
@@ -10163,6 +10165,24 @@ function registerCommandTools(server, command) {
|
|
|
10163
10165
|
annotations: READ_ONLY
|
|
10164
10166
|
}, () => command(["extract", "--check"]));
|
|
10165
10167
|
}
|
|
10168
|
+
/** What a rename would change, without changing it: the plan `vi18n rename` prints before `--write`. */
|
|
10169
|
+
function registerRenameTool(server, command) {
|
|
10170
|
+
server.registerTool("rename_dry_run", {
|
|
10171
|
+
title: "Plan a text rename",
|
|
10172
|
+
description: "Lists the call sites and catalog entries `vi18n rename <from> <to>` would change, or why it refuses (unknown text, changed arguments, the new text already a message). Writes nothing: applying it is `vi18n rename --write` in a terminal. Runs `vi18n rename --json` without --write.",
|
|
10173
|
+
inputSchema: {
|
|
10174
|
+
from: z.string().describe("The text as written in the code now"),
|
|
10175
|
+
to: z.string().describe("The text it becomes"),
|
|
10176
|
+
merge: z.boolean().optional().describe("Allow `to` to be a message the code already has")
|
|
10177
|
+
},
|
|
10178
|
+
annotations: READ_ONLY
|
|
10179
|
+
}, (args) => command([
|
|
10180
|
+
"rename",
|
|
10181
|
+
args.from,
|
|
10182
|
+
args.to,
|
|
10183
|
+
...args.merge === true ? ["--merge"] : []
|
|
10184
|
+
]));
|
|
10185
|
+
}
|
|
10166
10186
|
/** The read-only tools over generated output: compiled catalogs and AI translation plans. */
|
|
10167
10187
|
function registerOutputTools(server, command) {
|
|
10168
10188
|
server.registerTool("compile_check", {
|