@menapo/vi18n 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (118) hide show
  1. package/dist/{apply-Bre-lY9J.js → apply-FAHl1R6T.js} +69 -89
  2. package/dist/{captured-Bj8bO6vd.js → captured-CTjjDF5o.js} +196 -217
  3. package/dist/{check-BIKEuu6B.js → check-DwFwOB1d.js} +66 -84
  4. package/dist/cli.js +2 -3
  5. package/dist/{collect-Cx4_SKOe.js → collect-CYATDjdo.js} +1 -2
  6. package/dist/collisions-uMTuq36M.js +215 -0
  7. package/dist/compile-CEvH-6sY.js +240 -0
  8. package/dist/{compile-Cc97JaW2.js → compile-DqkofbiO.js} +376 -331
  9. package/dist/concurrency-BCY_4zcr.js +1 -0
  10. package/dist/concurrency-Dy2ny50V.js +107 -0
  11. package/dist/config.d.ts +1 -5
  12. package/dist/config.js +4 -5
  13. package/dist/{types-D3QGM8XO.js → diagnostics-1onDF6Ua.js} +26 -26
  14. package/dist/{dir-zw6bGMKQ.js → dir-TGLYuOZb.js} +34 -37
  15. package/dist/{duplicates-yuRljQ6h.js → duplicates-CsUXRX2J.js} +10 -27
  16. package/dist/engine-Bf7nVigL.js +556 -0
  17. package/dist/engine.d.ts +1 -5
  18. package/dist/engine.js +297 -168
  19. package/dist/exchange-DYG9RZoT.js +41 -0
  20. package/dist/{exclude-Du-Zd_qI.js → exclude-vMnm3lqU.js} +2 -3
  21. package/dist/{export-C9Sy6UWv.js → export-BYq0gfLd.js} +17 -38
  22. package/dist/{extract-C3S8btx0.js → extract-CYtuEo8u.js} +114 -82
  23. package/dist/{formats-9unqj_fZ.js → formats-ChV1LVH_.js} +352 -276
  24. package/dist/fs-ezCMZeDV.js +52 -0
  25. package/dist/i18next-1waHziMy.js +1 -0
  26. package/dist/i18next-D66Icz3L.js +1907 -0
  27. package/dist/{import-nANvQutw.js → import-BApbQlmm.js} +81 -75
  28. package/dist/index.d.ts +1 -13
  29. package/dist/index.js +14 -16
  30. package/dist/{init-C2ScuW6a.js → init-J7AwwA5e.js} +466 -501
  31. package/dist/{library-D5CWvTQs.js → library-BfSOBeBd.js} +975 -451
  32. package/dist/lingui-Ee2farVo.js +902 -0
  33. package/dist/lint.d.ts +0 -4
  34. package/dist/lint.js +68 -81
  35. package/dist/{load-gW-oJt1Q.js → load-BFLLqY8x.js} +272 -147
  36. package/dist/{load-CQRz4PpM.js → load-CMwhukZ4.js} +1211 -1115
  37. package/dist/{locales-DX4MOBFE.js → locales-DxLDrx-h.js} +271 -237
  38. package/dist/{lsp-RMMMc88P.js → lsp-BC7xDGON.js} +4 -5
  39. package/dist/{match-BGr8EXB3.js → match-BLDcj610.js} +11 -4
  40. package/dist/{mcp-CHVwBoRP.js → mcp-Cka8ywDF.js} +4 -5
  41. package/dist/{merge-driver-BTX87aVm.js → merge-driver-B04Apm29.js} +138 -122
  42. package/dist/migrate-D7TNl6SD.js +2169 -0
  43. package/dist/migrate-khCY8TE0.js +1 -0
  44. package/dist/{openai-CTaMDcl-.js → openai-RWw0YlAx.js} +128 -87
  45. package/dist/{output-DWE3SIUA.js → output-CF9uvk_-.js} +15 -9
  46. package/dist/parse.d.ts +1 -3
  47. package/dist/parse.js +7 -8
  48. package/dist/{pipeline-DbX6rlo5.js → pipeline-B30irGMD.js} +1 -1
  49. package/dist/{pipeline-C9Dbotkh.js → pipeline-sgl_q_op.js} +387 -359
  50. package/dist/project-DSzWKU3C.js +544 -0
  51. package/dist/{pseudo-DRv30iN5.js → pseudo-DNbNNVGP.js} +125 -3
  52. package/dist/{raw-C4Y6vyGY.js → raw-YsYZMS9n.js} +52 -29
  53. package/dist/react-intl-tzGIk6G3.js +634 -0
  54. package/dist/restore-BG_zMpSj.js +199 -0
  55. package/dist/rewrite-hAcRJwiZ.js +415 -0
  56. package/dist/{rich-DCUKl5HM.js → rich-ApY1Dm4S.js} +35 -28
  57. package/dist/rolldown-runtime-C1I3wEg2.js +43 -0
  58. package/dist/{rolldown-runtime-D7D4PA-g.js → rolldown-runtime-D8jQpDG7.js} +1 -2
  59. package/dist/run-CFzR3V93.js +647 -0
  60. package/dist/scan-worker.d.ts +2 -4
  61. package/dist/scan-worker.js +1 -1
  62. package/dist/{scoped-BMYpSthj.js → scoped-h3KE8XWW.js} +3 -4
  63. package/dist/{server-deBOq2vq.js → server-WlxZH0oX.js} +275 -330
  64. package/dist/{server-Da1Ot9IN.js → server-ceuzzkal.js} +292 -386
  65. package/dist/server.d.ts +1 -17
  66. package/dist/server.js +415 -381
  67. package/dist/{sitemap-DJXzKoza.js → sitemap-796jJKUT.js} +21 -33
  68. package/dist/{sources-D19czDSA.js → sources-DuOdM02f.js} +712 -373
  69. package/dist/{status-zr4jY59Y.js → status-CTH3qI-0.js} +30 -30
  70. package/dist/{stdio-FPOKQAgu.js → stdio-D9kTzyqB.js} +2 -4
  71. package/dist/{stdio-CVaJfxA7.js → stdio-FWIVU3P4.js} +1 -2
  72. package/dist/sync-CpL0Qsgw.js +1352 -0
  73. package/dist/{t-DC-c9zE5.js → t-gvEXx25s.js} +76 -53
  74. package/dist/test.d.ts +5 -16
  75. package/dist/test.js +77 -48
  76. package/dist/translate-BrfVRkjl.js +336 -0
  77. package/dist/{ts-BaU5yOf0.js → ts-BX6kwig5.js} +25 -14
  78. package/dist/{types-DtvQ7UdD.js → types-3kwyaCAm.js} +1 -2
  79. package/dist/{types-DsdWBG0b.d.ts → types-BaG1LboH.d.ts} +2 -6
  80. package/dist/{types-CgUCkFU1.d.ts → types-Cy2bPdSg.d.ts} +14 -20
  81. package/dist/types-Ds_vebja.js +41 -0
  82. package/dist/{units-CQ5Q99RC.js → units-VVLgQ7x7.js} +7 -16
  83. package/dist/{url-CRfCOhUI.js → url-Bpc6wLea.js} +24 -11
  84. package/dist/{url-CsBkRaJy.js → url-D2_VlEeH.js} +25 -12
  85. package/dist/{validate-D6DJepZv.js → validate-PGgMsasz.js} +3 -5
  86. package/dist/{validate-BxpupdAf.js → validate-zv4-IZyZ.js} +690 -377
  87. package/dist/{version-Byqi2guX.js → version-BFs370Ce.js} +3 -5
  88. package/dist/{vite-scan-CT_vsp4g.js → vite-scan-DFKSGVE9.js} +87 -92
  89. package/dist/vite.d.ts +2 -6
  90. package/dist/vite.js +6482 -6018
  91. package/dist/vue-i18n-CBmZqHbG.js +806 -0
  92. package/dist/{which-BOemZ5Q8.js → which-BpyJyBkX.js} +44 -37
  93. package/dist/{worker-84U6uYB3.js → worker-BjzVqJVO.js} +454 -608
  94. package/package.json +5 -5
  95. package/dist/check-HsmmpJZg.js +0 -1
  96. package/dist/codec-DuvU2VQy.js +0 -207
  97. package/dist/collisions-CfpZU8e4.js +0 -217
  98. package/dist/compile-BaDh0cHG.js +0 -245
  99. package/dist/concurrency-C9UUWuDC.js +0 -96
  100. package/dist/concurrency-DONL7t4V.js +0 -1
  101. package/dist/engine-C2ENBRJe.js +0 -531
  102. package/dist/i18next-9HAoxwUI.js +0 -1
  103. package/dist/i18next-BEJgv_S8.js +0 -1596
  104. package/dist/lingui-zUiCl9Um.js +0 -833
  105. package/dist/messages-BfjIExyB.js +0 -166
  106. package/dist/migrate-IpLDMXmq.js +0 -1484
  107. package/dist/migrate-rCQuOGsf.js +0 -1
  108. package/dist/project-Bw9UPIdx.js +0 -1046
  109. package/dist/project-C4GpaN-n.js +0 -381
  110. package/dist/react-intl-BP0u-D5m.js +0 -519
  111. package/dist/restore-CiYv-jxS.js +0 -175
  112. package/dist/rewrite-EsIw_lsq.js +0 -803
  113. package/dist/run-BEcnBbu-.js +0 -694
  114. package/dist/runtime-DTMmliT1.js +0 -64
  115. package/dist/sync-B9V2KFwb.js +0 -658
  116. package/dist/translate-CQnJfLjO.js +0 -299
  117. package/dist/types-wSh9fCBY.js +0 -11
  118. package/dist/vue-i18n-g0iGy6CZ.js +0 -651
@@ -0,0 +1,647 @@
1
+ import { i as DEFAULT_CONFIG, n as isDiagnosticError } from "./diagnostics-1onDF6Ua.js";
2
+ import { t as VERSION } from "./version-BFs370Ce.js";
3
+ import { t as PROVIDER_PRESETS } from "./openai-RWw0YlAx.js";
4
+ import { t as EXCHANGE_FORMATS } from "./units-VVLgQ7x7.js";
5
+ import { a as MIGRATIONS, i as LIBRARIES, n as COMMAND_NAMES, r as EXIT, t as CHECK_CATEGORIES } from "./types-Ds_vebja.js";
6
+ import { n as createOutput, o as errorMessage } from "./output-CF9uvk_-.js";
7
+ import { t as CliExit } from "./project-DSzWKU3C.js";
8
+ import { resolve } from "node:path";
9
+ import { parseArgs } from "node:util";
10
+ // src/cli/args.ts
11
+ /**
12
+ * Command-line parsing (INTERNALS §2.14): `node:util` `parseArgs`, strict, so
13
+ * an unknown flag or a stray positional is a usage error (exit 2) instead of
14
+ * a silently different run. Global flags may appear before or after the
15
+ * command name.
16
+ */
17
+ const COMMANDS = COMMAND_NAMES;
18
+ const TIERS = [
19
+ "standard",
20
+ "flex",
21
+ "batch"
22
+ ];
23
+ const GLOBAL = {
24
+ config: { type: "string" },
25
+ json: { type: "boolean" },
26
+ cwd: { type: "string" },
27
+ help: {
28
+ type: "boolean",
29
+ short: "h"
30
+ },
31
+ version: {
32
+ type: "boolean",
33
+ short: "v"
34
+ }
35
+ };
36
+ /** Thrown inside flag conversion; becomes a `usage` result. */
37
+ var UsageError = class extends Error {};
38
+ function isCommand(name) {
39
+ return COMMANDS.includes(name);
40
+ }
41
+ /**
42
+ * The command is the first token that is neither a flag nor the value of a
43
+ * global flag that takes one (`--config x`, `--cwd x`), so `vi18n --cwd app
44
+ * extract` and `vi18n extract --cwd app` mean the same.
45
+ */
46
+ function findCommand(argv) {
47
+ for (let i = 0; i < argv.length; i++) {
48
+ const token = argv[i];
49
+ if (token === "--") return null;
50
+ if (token === "--config" || token === "--cwd") {
51
+ i++;
52
+ continue;
53
+ }
54
+ if (!token.startsWith("-")) return {
55
+ index: i,
56
+ name: token
57
+ };
58
+ }
59
+ return null;
60
+ }
61
+ /** Only global flags: `--help`, `--version`, or nothing to do. */
62
+ function parseWithoutCommand(argv, json) {
63
+ const rest = tryParse(argv, GLOBAL, false);
64
+ if ("error" in rest) return {
65
+ kind: "usage",
66
+ command: null,
67
+ message: rest.error,
68
+ json
69
+ };
70
+ if (rest.values.version === true) return {
71
+ kind: "version",
72
+ command: null,
73
+ json
74
+ };
75
+ if (rest.values.help === true) return {
76
+ kind: "help",
77
+ command: null,
78
+ json
79
+ };
80
+ return {
81
+ kind: "usage",
82
+ command: null,
83
+ message: `missing command; expected one of ${COMMANDS.join(", ")}`,
84
+ json
85
+ };
86
+ }
87
+ function parseCommandLine(argv, cwd) {
88
+ const found = findCommand(argv);
89
+ const json = argv.includes("--json");
90
+ if (found === null) return parseWithoutCommand(argv, json);
91
+ if (!isCommand(found.name)) return {
92
+ kind: "usage",
93
+ command: null,
94
+ message: `unknown command "${found.name}"; expected one of ${COMMANDS.join(", ")}`,
95
+ json
96
+ };
97
+ const command = found.name;
98
+ const spec = SPECS[command];
99
+ const parsed = tryParse([...argv.slice(0, found.index), ...argv.slice(found.index + 1)], {
100
+ ...GLOBAL,
101
+ ...spec.options
102
+ }, spec.positional === true);
103
+ if ("error" in parsed) return {
104
+ kind: "usage",
105
+ command,
106
+ message: parsed.error,
107
+ json
108
+ };
109
+ const { values, positionals } = parsed;
110
+ if (values.version === true) return {
111
+ kind: "version",
112
+ command,
113
+ json
114
+ };
115
+ if (values.help === true) return {
116
+ kind: "help",
117
+ command,
118
+ json
119
+ };
120
+ const global = {
121
+ config: str(values.config),
122
+ json: values.json === true,
123
+ cwd: resolve(cwd, str(values.cwd) ?? ".")
124
+ };
125
+ try {
126
+ const run = runCommand$1(command, {
127
+ values,
128
+ positionals,
129
+ global
130
+ });
131
+ if (run.command === "check" && run.flags.format === "json") return {
132
+ ...run,
133
+ global: {
134
+ ...global,
135
+ json: true
136
+ }
137
+ };
138
+ return run;
139
+ } catch (error) {
140
+ if (error instanceof UsageError) return {
141
+ kind: "usage",
142
+ command,
143
+ message: error.message,
144
+ json: global.json
145
+ };
146
+ throw error;
147
+ }
148
+ }
149
+ function runCommand$1(command, input) {
150
+ const spec = SPECS[command];
151
+ return {
152
+ kind: "run",
153
+ command,
154
+ global: input.global,
155
+ flags: spec.flags(input)
156
+ };
157
+ }
158
+ function tryParse(args, options, allowPositionals) {
159
+ try {
160
+ const { values, positionals } = parseArgs({
161
+ args: [...args],
162
+ options,
163
+ strict: true,
164
+ allowPositionals
165
+ });
166
+ return {
167
+ values,
168
+ positionals
169
+ };
170
+ } catch (error) {
171
+ return { error: errorMessage(error) };
172
+ }
173
+ }
174
+ function str(value) {
175
+ return typeof value === "string" ? value : null;
176
+ }
177
+ function bool(value) {
178
+ return value === true;
179
+ }
180
+ function list(value) {
181
+ if (!Array.isArray(value)) return [];
182
+ return value.filter((item) => typeof item === "string");
183
+ }
184
+ function oneOf(flag, value, allowed) {
185
+ if (value === null) return null;
186
+ if (allowed.includes(value)) return value;
187
+ throw new UsageError(`--${flag} must be one of ${allowed.join(", ")}, not "${value}"`);
188
+ }
189
+ function initFlags({ values }) {
190
+ const locales = (str(values.locales) ?? "").split(",").map((locale) => locale.trim()).filter((locale) => locale !== "");
191
+ return {
192
+ yes: bool(values.yes),
193
+ format: oneOf("format", str(values.format), ["po", "json"]),
194
+ locales,
195
+ sourceLocale: str(values["source-locale"]),
196
+ rich: bool(values.rich)
197
+ };
198
+ }
199
+ function extractFlags({ values }) {
200
+ const flags = {
201
+ check: bool(values.check),
202
+ watch: bool(values.watch),
203
+ yes: bool(values.yes),
204
+ vite: bool(values.vite)
205
+ };
206
+ if (flags.check && flags.watch) throw new UsageError("--check and --watch cannot be combined");
207
+ if (flags.vite && flags.watch) throw new UsageError("--vite and --watch cannot be combined; vite dev keeps the catalogs current");
208
+ return flags;
209
+ }
210
+ function checkFlags({ values, positionals, global }) {
211
+ const categories = [];
212
+ for (const positional of positionals) {
213
+ const category = oneOf("category", positional, CHECK_CATEGORIES);
214
+ if (category !== null && !categories.includes(category)) categories.push(category);
215
+ }
216
+ const format = oneOf("format", str(values.format), [
217
+ "text",
218
+ "github",
219
+ "json"
220
+ ]) ?? "text";
221
+ return {
222
+ categories,
223
+ ci: bool(values.ci),
224
+ format: global.json ? "json" : format
225
+ };
226
+ }
227
+ function compileFlags({ values }) {
228
+ const flags = {
229
+ out: str(values.out),
230
+ assets: str(values.assets),
231
+ strict: bool(values.strict),
232
+ pseudo: bool(values.pseudo),
233
+ check: bool(values.check)
234
+ };
235
+ if (flags.check && flags.out === null) throw new UsageError("--check needs --out <dir>: the directory to compare");
236
+ if (flags.assets !== null && flags.out === null) throw new UsageError("--assets needs --out <dir>: the directory for config.json, sources.json and catalogs.js");
237
+ return flags;
238
+ }
239
+ function maxCostFlag(raw) {
240
+ if (raw === null) return null;
241
+ const maxCost = raw.trim() === "" ? NaN : Number(raw);
242
+ if (!Number.isFinite(maxCost) || maxCost < 0) throw new UsageError(`--max-cost must be a non-negative number of USD, not "${raw}"`);
243
+ return maxCost;
244
+ }
245
+ function translateFlags({ values }) {
246
+ const provider = oneOf("provider", str(values.provider), PROVIDER_PRESETS);
247
+ const model = str(values.model);
248
+ if (provider !== null && provider !== "gemini" && model === null) throw new UsageError(`--provider ${provider} needs --model <id>`);
249
+ const maxCost = maxCostFlag(str(values["max-cost"]));
250
+ return {
251
+ locales: list(values.locale),
252
+ model,
253
+ retranslate: oneOf("retranslate", str(values.retranslate), ["ai", "all"]),
254
+ provider,
255
+ tier: oneOf("tier", str(values.tier), TIERS) ?? "standard",
256
+ dryRun: bool(values["dry-run"]),
257
+ maxCost
258
+ };
259
+ }
260
+ function catalogFlag(raw) {
261
+ const eq = raw.indexOf("=");
262
+ if (eq === -1) return {
263
+ locale: null,
264
+ file: raw
265
+ };
266
+ const locale = raw.slice(0, eq).trim();
267
+ const file = raw.slice(eq + 1).trim();
268
+ if (locale === "" || file === "") throw new UsageError(`--catalog ${raw}: expected <file> or <locale>=<file>`);
269
+ return {
270
+ locale,
271
+ file
272
+ };
273
+ }
274
+ /** saas-i18n reads one key catalogue per locale, the default locale's first. */
275
+ function checkSaasCatalogs(catalogs, keepIds) {
276
+ if (keepIds) throw new UsageError("--keep-ids is for the libraries: saas-i18n keys always become manual ids");
277
+ if (catalogs.length === 0) throw new UsageError("--catalog <file> is required: the default locale's key catalogue");
278
+ for (const entry of catalogs.slice(1)) if (entry.locale === null) throw new UsageError(`--catalog ${entry.file}: only the first --catalog may omit the locale (<locale>=<file>)`);
279
+ }
280
+ function migrateFlags({ values }) {
281
+ const from = oneOf("from", str(values.from), MIGRATIONS);
282
+ if (from === null) throw new UsageError(`--from is required (${MIGRATIONS.join(", ")})`);
283
+ const catalogs = list(values.catalog).map(catalogFlag);
284
+ const keepIds = bool(values["keep-ids"]);
285
+ if (from === "saas-i18n") checkSaasCatalogs(catalogs, keepIds);
286
+ return {
287
+ from,
288
+ catalogs,
289
+ keepIds,
290
+ write: bool(values.write)
291
+ };
292
+ }
293
+ function sitemapFlags({ values, positionals }) {
294
+ const flags = {
295
+ routes: positionals,
296
+ routesFile: str(values.routes),
297
+ baseUrl: str(values["base-url"]),
298
+ out: str(values.out),
299
+ check: bool(values.check)
300
+ };
301
+ if (flags.check && flags.out === null) throw new UsageError("--check needs --out <file>: the sitemap to compare");
302
+ return flags;
303
+ }
304
+ function exportFlags({ values }) {
305
+ const format = oneOf("format", str(values.format), EXCHANGE_FORMATS);
306
+ if (format === null) throw new UsageError(`--format is required: one of ${EXCHANGE_FORMATS.join(", ")}`);
307
+ return {
308
+ format,
309
+ locales: list(values.locale),
310
+ out: str(values.out),
311
+ missing: bool(values.missing),
312
+ ai: bool(values.ai)
313
+ };
314
+ }
315
+ function importFlags({ values, positionals }) {
316
+ if (positionals.length === 0) throw new UsageError("name the file(s) to import");
317
+ const flags = {
318
+ format: oneOf("format", str(values.format), EXCHANGE_FORMATS),
319
+ locale: str(values.locale),
320
+ dryRun: bool(values["dry-run"]),
321
+ files: positionals
322
+ };
323
+ if (flags.locale !== null && positionals.length > 1) throw new UsageError("--locale applies to one file; import the others separately");
324
+ return flags;
325
+ }
326
+ function restoreFlags({ values }) {
327
+ const from = str(values.from);
328
+ if (from === null || from.trim() === "") throw new UsageError("--from <git-rev> is required: the revision to restore from");
329
+ if (from.startsWith("-")) throw new UsageError(`--from ${from}: not a revision`);
330
+ return {
331
+ from,
332
+ locales: list(values.locale),
333
+ dryRun: bool(values["dry-run"])
334
+ };
335
+ }
336
+ function whichFlags({ positionals }) {
337
+ const query = positionals.join(" ");
338
+ if (query.trim() === "") throw new UsageError("name an id, the start of one, or source text");
339
+ return { query };
340
+ }
341
+ function mergeDriverFlags({ positionals }) {
342
+ if (positionals.length < 3 || positionals.length > 4) throw new UsageError("expected <base> <ours> <theirs> [<path>], as git passes %O %A %B %P");
343
+ const [base, ours, theirs, path] = positionals;
344
+ return {
345
+ base,
346
+ ours,
347
+ theirs,
348
+ path: path ?? null
349
+ };
350
+ }
351
+ /** `lsp` and `mcp`: stdout carries the protocol, so it cannot also carry an envelope. */
352
+ function protocolFlags(command) {
353
+ return ({ global }) => {
354
+ if (global.json) throw new UsageError(`--json does not apply: vi18n ${command} speaks its protocol on stdio`);
355
+ return {};
356
+ };
357
+ }
358
+ const SPECS = {
359
+ init: {
360
+ options: {
361
+ yes: {
362
+ type: "boolean",
363
+ short: "y"
364
+ },
365
+ format: { type: "string" },
366
+ locales: { type: "string" },
367
+ "source-locale": { type: "string" },
368
+ rich: { type: "boolean" }
369
+ },
370
+ flags: initFlags
371
+ },
372
+ extract: {
373
+ options: {
374
+ check: { type: "boolean" },
375
+ watch: { type: "boolean" },
376
+ yes: {
377
+ type: "boolean",
378
+ short: "y"
379
+ },
380
+ vite: { type: "boolean" }
381
+ },
382
+ flags: extractFlags
383
+ },
384
+ check: {
385
+ options: {
386
+ ci: { type: "boolean" },
387
+ format: { type: "string" }
388
+ },
389
+ positional: true,
390
+ flags: checkFlags
391
+ },
392
+ status: {
393
+ options: { locale: {
394
+ type: "string",
395
+ multiple: true
396
+ } },
397
+ flags: ({ values }) => ({ locales: list(values.locale) })
398
+ },
399
+ compile: {
400
+ options: {
401
+ out: { type: "string" },
402
+ assets: { type: "string" },
403
+ strict: { type: "boolean" },
404
+ pseudo: { type: "boolean" },
405
+ check: { type: "boolean" }
406
+ },
407
+ flags: compileFlags
408
+ },
409
+ translate: {
410
+ options: {
411
+ locale: {
412
+ type: "string",
413
+ multiple: true
414
+ },
415
+ model: { type: "string" },
416
+ retranslate: { type: "string" },
417
+ provider: { type: "string" },
418
+ tier: { type: "string" },
419
+ "dry-run": { type: "boolean" },
420
+ "max-cost": { type: "string" }
421
+ },
422
+ flags: translateFlags
423
+ },
424
+ migrate: {
425
+ options: {
426
+ from: { type: "string" },
427
+ catalog: {
428
+ type: "string",
429
+ multiple: true
430
+ },
431
+ "keep-ids": { type: "boolean" },
432
+ write: { type: "boolean" }
433
+ },
434
+ flags: migrateFlags
435
+ },
436
+ sitemap: {
437
+ options: {
438
+ routes: { type: "string" },
439
+ "base-url": { type: "string" },
440
+ out: { type: "string" },
441
+ check: { type: "boolean" }
442
+ },
443
+ positional: true,
444
+ flags: sitemapFlags
445
+ },
446
+ export: {
447
+ options: {
448
+ format: { type: "string" },
449
+ locale: {
450
+ type: "string",
451
+ multiple: true
452
+ },
453
+ out: { type: "string" },
454
+ missing: { type: "boolean" },
455
+ ai: { type: "boolean" }
456
+ },
457
+ flags: exportFlags
458
+ },
459
+ import: {
460
+ options: {
461
+ format: { type: "string" },
462
+ locale: { type: "string" },
463
+ "dry-run": { type: "boolean" }
464
+ },
465
+ positional: true,
466
+ flags: importFlags
467
+ },
468
+ restore: {
469
+ options: {
470
+ from: { type: "string" },
471
+ locale: {
472
+ type: "string",
473
+ multiple: true
474
+ },
475
+ "dry-run": { type: "boolean" }
476
+ },
477
+ flags: restoreFlags
478
+ },
479
+ which: {
480
+ options: {},
481
+ positional: true,
482
+ flags: whichFlags
483
+ },
484
+ "merge-driver": {
485
+ options: {},
486
+ positional: true,
487
+ flags: mergeDriverFlags
488
+ },
489
+ lsp: {
490
+ options: {
491
+ stdio: { type: "boolean" },
492
+ clientProcessId: { type: "string" }
493
+ },
494
+ flags: protocolFlags("lsp")
495
+ },
496
+ mcp: {
497
+ options: {},
498
+ flags: protocolFlags("mcp")
499
+ }
500
+ };
501
+ const GLOBAL_HELP = `Global flags:
502
+ --config <path> vi18n.config.ts to use (default: searched upward from the cwd)
503
+ --cwd <dir> run as if started in <dir>
504
+ --json print one JSON object (the command's result) on stdout
505
+ --help, --version`;
506
+ const COMMAND_HELP = {
507
+ init: `vi18n init [--yes] [--format po|json] [--locales en,de] [--source-locale en] [--rich]
508
+ Write vi18n.config.ts, add the plugin to vite.config.*, create the catalogs and vi18n.gen.ts.
509
+ --rich copies a <T> rich-text component for Vue and Svelte into the project (also when configured).`,
510
+ extract: `vi18n extract [--check] [--watch] [--yes] [--vite]
511
+ Sync the catalogs with the code. --check writes nothing and fails on drift; --watch only adds;
512
+ --yes allows clearing or deleting more translations than the safety limit.
513
+ --vite transforms each file through the project's Vite config and plugins instead of reading it,
514
+ for plugins that change code before vi18n sees it (auto-imports, macros).`,
515
+ check: `vi18n check ${CHECK_CATEGORIES.map((c) => `[${c}]`).join(" ")} [--ci] [--format text|github|json]
516
+ Validate catalogs against the code. --ci fails on warnings of the selected categories too.`,
517
+ status: `vi18n status [--json] [--locale <l>]…
518
+ Translation progress per locale, and per bundle when a build report exists.`,
519
+ compile: `vi18n compile [--out <dir>] [--assets <dir>] [--strict] [--pseudo] [--check]
520
+ Compiled JSON per locale plus sources.json and config.json, for code not built by Vite.
521
+ --assets puts the catalogs into a static-assets directory (vi18n/<version>/<locale>/catalog.json)
522
+ and writes <out>/catalogs.js, which reads them through the Workers ASSETS binding.
523
+ --check writes nothing and fails when a file is out of date.`,
524
+ translate: `vi18n translate [--locale <l>]… [--provider ${PROVIDER_PRESETS.join("|")}] [--model <id>] [--tier ${TIERS.join("|")}] [--retranslate ai|all] [--dry-run] [--max-cost <usd>]
525
+ AI-translate the referenced messages that have no translation.
526
+ --provider overrides ai.provider (all but gemini need --model); --tier flex|batch (Gemini) costs half.`,
527
+ migrate: `vi18n migrate --from ${[...LIBRARIES, "saas-i18n"].join("|")} [--catalog [<locale>=]<file|dir>]… [--keep-ids] [--write]
528
+ Rewrite another library's calls into t()/msg()/rich() and its catalogs into vi18n's;
529
+ prints the plan without --write. --keep-ids keeps every key a developer chose as a manual id.`,
530
+ sitemap: `vi18n sitemap [<route>…] [--routes <file>] [--base-url <url>] [--out <file>] [--check]
531
+ Write sitemap.xml: every route in every locale, with hreflang alternates and x-default.
532
+ --base-url is the site's origin and base path (not needed when routing.domains has every locale);
533
+ --routes reads route paths from a file; without --out the sitemap goes to stdout.`,
534
+ export: `vi18n export --format ${EXCHANGE_FORMATS.join("|")} [--locale <l>]… [--out <dir>] [--missing] [--ai]
535
+ Write each locale's catalog in an exchange format for a TMS or translators. --missing keeps the
536
+ entries without a translation that would ship, --ai the AI translations; without --out, one
537
+ locale goes to stdout.`,
538
+ import: `vi18n import [--format ${EXCHANGE_FORMATS.join("|")}] [--locale <l>] [--dry-run] <file>…
539
+ Take translations from exchange files into the catalogs, only where the row's source is the
540
+ entry's exact source; reports what changed and what was skipped. --dry-run writes nothing.`,
541
+ restore: `vi18n restore --from <git-rev> [--locale <l>]… [--dry-run]
542
+ Fill empty entries from that revision's catalogs by exact source text or manual id.`,
543
+ which: `vi18n which <id|prefix|text>
544
+ Print a message's id, source text, call sites and catalog entries.`,
545
+ "merge-driver": `vi18n merge-driver <base> <ours> <theirs> [<path>]
546
+ Git merge driver for catalogs (%O %A %B %P): merges entry by entry and leaves conflict
547
+ markers only where both sides changed one translation differently.`,
548
+ lsp: `vi18n lsp [--stdio]
549
+ Language server for editors: hovers with every locale's translation, diagnostics for missing
550
+ and invalid translations, go to the catalog entry. Speaks LSP on stdin/stdout.`,
551
+ mcp: `vi18n mcp
552
+ Model Context Protocol server for agents: status, check, extract and compile checks, translate
553
+ --dry-run, and reading and writing one translation. Speaks MCP on stdin/stdout.`
554
+ };
555
+ function helpText(command, version) {
556
+ if (command !== null) return `${COMMAND_HELP[command]}\n\n${GLOBAL_HELP}\n`;
557
+ return `vi18n ${version}\n\nUsage:\n${COMMANDS.map((name) => " " + COMMAND_HELP[name].split("\n")[0]).join("\n")}\n\n${GLOBAL_HELP}\n`;
558
+ }
559
+ // src/cli/run.ts
560
+ /**
561
+ * The `vi18n` binary minus the process (INTERNALS §2.14, §3.5): parse argv,
562
+ * run one command, map failures to exit codes, print the `--json` envelope.
563
+ * Tests call `run` in-process with recording `CliIo`s; `bin.ts` wires the
564
+ * real process to it.
565
+ */
566
+ /**
567
+ * Each command loads only its own code: every CLI run is a fresh process,
568
+ * and loading all fifteen made `extract` parse the AI, exchange and MF2
569
+ * modules it never calls.
570
+ */
571
+ const RUNNERS = {
572
+ init: async () => (await import("./init-J7AwwA5e.js")).init,
573
+ extract: async () => (await import("./extract-CYtuEo8u.js")).extract,
574
+ check: async () => (await import("./check-DwFwOB1d.js")).check,
575
+ status: async () => (await import("./status-CTH3qI-0.js")).status,
576
+ compile: async () => (await import("./compile-CEvH-6sY.js")).compile,
577
+ translate: async () => (await import("./translate-BrfVRkjl.js")).translate,
578
+ migrate: async () => (await import("./migrate-khCY8TE0.js")).migrate,
579
+ sitemap: async () => (await import("./sitemap-796jJKUT.js")).sitemap,
580
+ export: async () => (await import("./export-BYq0gfLd.js")).exportCatalogs,
581
+ import: async () => (await import("./import-BApbQlmm.js")).importCatalogs,
582
+ restore: async () => (await import("./restore-BG_zMpSj.js")).restore,
583
+ which: async () => (await import("./which-BpyJyBkX.js")).which,
584
+ "merge-driver": async () => (await import("./merge-driver-B04Apm29.js")).mergeDriver,
585
+ lsp: async () => (await import("./lsp-BC7xDGON.js")).lsp,
586
+ mcp: async () => (await import("./mcp-Cka8ywDF.js")).mcp
587
+ };
588
+ async function runCommand(command, ctx, flags) {
589
+ return (await RUNNERS[command]())(ctx, flags);
590
+ }
591
+ async function run(argv, io) {
592
+ const parsed = parseCommandLine(argv, io.cwd);
593
+ if (parsed.kind === "run") return runParsed(parsed, io);
594
+ if (parsed.kind === "usage") return usage(parsed, io);
595
+ const text = parsed.kind === "version" ? VERSION + "\n" : helpText(parsed.command, VERSION);
596
+ if (parsed.json && parsed.command !== null) createOutput(io, "json").finish(parsed.command, EXIT.ok, parsed.kind === "version" ? { version: VERSION } : { help: text });
597
+ else io.stdout(text);
598
+ return EXIT.ok;
599
+ }
600
+ function usage(parsed, io) {
601
+ const out = createOutput(io, parsed.json ? "json" : "text");
602
+ out.addSecret(io.env[DEFAULT_CONFIG.ai.apiKeyEnv]);
603
+ const hint = parsed.command === null ? "vi18n --help" : `vi18n ${parsed.command} --help`;
604
+ io.stderr(out.redact(`vi18n: ${parsed.message}\nRun ${hint} for usage.\n`));
605
+ if (parsed.command !== null) out.finish(parsed.command, EXIT.usage, { usage: parsed.message });
606
+ return EXIT.usage;
607
+ }
608
+ function outputFormat(parsed) {
609
+ if (parsed.global.json) return "json";
610
+ return parsed.command === "check" ? parsed.flags.format : "text";
611
+ }
612
+ async function runParsed(parsed, io) {
613
+ const commandIo = {
614
+ ...io,
615
+ cwd: parsed.global.cwd
616
+ };
617
+ const out = createOutput(commandIo, outputFormat(parsed));
618
+ out.addSecret(io.env[DEFAULT_CONFIG.ai.apiKeyEnv]);
619
+ const ctx = {
620
+ io: commandIo,
621
+ out,
622
+ global: parsed.global
623
+ };
624
+ let exitCode;
625
+ let data = null;
626
+ try {
627
+ const result = await runCommand(parsed.command, ctx, parsed.flags);
628
+ exitCode = result.exitCode;
629
+ data = result.data;
630
+ } catch (error) {
631
+ if (error instanceof CliExit) {
632
+ out.report(error.diagnostics);
633
+ exitCode = error.exitCode;
634
+ data = error.data;
635
+ } else if (isDiagnosticError(error)) {
636
+ out.report([error.diagnostic]);
637
+ exitCode = error.diagnostic.code.startsWith("config-") ? EXIT.usage : EXIT.failure;
638
+ } else {
639
+ const message = error instanceof Error ? error.stack ?? error.message : String(error);
640
+ io.stderr(out.redact(`vi18n ${parsed.command}: ${message}\n`));
641
+ exitCode = EXIT.failure;
642
+ }
643
+ }
644
+ out.finish(parsed.command, exitCode, data);
645
+ return exitCode;
646
+ }
647
+ export { run as t };
@@ -1,5 +1,4 @@
1
- import { _ as MessageOccurrence, g as MessageCodec, h as Diagnostic, i as ResolvedConfig } from "./types-CgUCkFU1.js";
2
- //#region src/core/extract/worker.d.ts
1
+ import { _ as MessageOccurrence, g as MessageCodec, h as Diagnostic, i as ResolvedConfig } from "./types-Cy2bPdSg.js";
3
2
  export interface FileTask {
4
3
  /** Absolute path (a realpath from the file walk). */
5
4
  file: string;
@@ -58,5 +57,4 @@ export type WorkerResponse = {
58
57
  message: string;
59
58
  stack?: string;
60
59
  };
61
- };
62
- //#endregion
60
+ };
@@ -1 +1 @@
1
- export { t as ABORT_CODES, n as WORKER_MARKER, r as scanConfig, i as scanSource } from "./worker-84U6uYB3.js";
1
+ export { t as ABORT_CODES, n as WORKER_MARKER, r as scanConfig, i as scanSource } from "./worker-BjzVqJVO.js";
@@ -1,6 +1,6 @@
1
- import { C as fTime, S as fSegment, _ as fDuration, b as fPercent, d as fCompare, f as fCurrency, g as fDisplayName, h as fDateRange, l as fCollator, m as fDate, o as formatMessage, p as fCurrencyMinor, t as lookup, u as fCompact, v as fList, w as fUnit, x as fRelative, y as fNumber } from "./t-DC-c9zE5.js";
2
- import { r as richIn } from "./rich-DCUKl5HM.js";
3
- //#region src/runtime/scoped.ts
1
+ import { C as fSegment, S as fRelative, T as fUnit, _ as fDisplayName, b as fNumber, d as fCompact, f as fCompare, g as fDateRange, h as fDate, m as fCurrencyMinor, o as formatMessage, p as fCurrency, t as lookup, u as fCollator, v as fDuration, w as fTime, x as fPercent, y as fList } from "./t-gvEXx25s.js";
2
+ import { r as richIn } from "./rich-ApY1Dm4S.js";
3
+ // src/runtime/scoped.ts
4
4
  /**
5
5
  * The API bound to one scope (INTERNALS §2.11.8): `createTranslator`,
6
6
  * `withLocale` helpers and e-mail jobs render with a fixed locale, zone and
@@ -40,5 +40,4 @@ function createScopedApi(scope) {
40
40
  fmt
41
41
  };
42
42
  }
43
- //#endregion
44
43
  export { createScopedApi as t };