@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.
- package/dist/{apply-Bre-lY9J.js → apply-FAHl1R6T.js} +69 -89
- package/dist/{captured-Bj8bO6vd.js → captured-CTjjDF5o.js} +196 -217
- package/dist/{check-BIKEuu6B.js → check-DwFwOB1d.js} +66 -84
- package/dist/cli.js +2 -3
- package/dist/{collect-Cx4_SKOe.js → collect-CYATDjdo.js} +1 -2
- package/dist/collisions-uMTuq36M.js +215 -0
- package/dist/compile-CEvH-6sY.js +240 -0
- package/dist/{compile-Cc97JaW2.js → compile-DqkofbiO.js} +376 -331
- package/dist/concurrency-BCY_4zcr.js +1 -0
- package/dist/concurrency-Dy2ny50V.js +107 -0
- package/dist/config.d.ts +1 -5
- package/dist/config.js +4 -5
- package/dist/{types-D3QGM8XO.js → diagnostics-1onDF6Ua.js} +26 -26
- package/dist/{dir-zw6bGMKQ.js → dir-TGLYuOZb.js} +34 -37
- package/dist/{duplicates-yuRljQ6h.js → duplicates-CsUXRX2J.js} +10 -27
- package/dist/engine-Bf7nVigL.js +556 -0
- package/dist/engine.d.ts +1 -5
- package/dist/engine.js +297 -168
- package/dist/exchange-DYG9RZoT.js +41 -0
- package/dist/{exclude-Du-Zd_qI.js → exclude-vMnm3lqU.js} +2 -3
- package/dist/{export-C9Sy6UWv.js → export-BYq0gfLd.js} +17 -38
- package/dist/{extract-C3S8btx0.js → extract-CYtuEo8u.js} +114 -82
- package/dist/{formats-9unqj_fZ.js → formats-ChV1LVH_.js} +352 -276
- package/dist/fs-ezCMZeDV.js +52 -0
- package/dist/i18next-1waHziMy.js +1 -0
- package/dist/i18next-D66Icz3L.js +1907 -0
- package/dist/{import-nANvQutw.js → import-BApbQlmm.js} +81 -75
- package/dist/index.d.ts +1 -13
- package/dist/index.js +14 -16
- package/dist/{init-C2ScuW6a.js → init-J7AwwA5e.js} +466 -501
- package/dist/{library-D5CWvTQs.js → library-BfSOBeBd.js} +975 -451
- package/dist/lingui-Ee2farVo.js +902 -0
- package/dist/lint.d.ts +0 -4
- package/dist/lint.js +68 -81
- package/dist/{load-gW-oJt1Q.js → load-BFLLqY8x.js} +272 -147
- package/dist/{load-CQRz4PpM.js → load-CMwhukZ4.js} +1211 -1115
- package/dist/{locales-DX4MOBFE.js → locales-DxLDrx-h.js} +271 -237
- package/dist/{lsp-RMMMc88P.js → lsp-BC7xDGON.js} +4 -5
- package/dist/{match-BGr8EXB3.js → match-BLDcj610.js} +11 -4
- package/dist/{mcp-CHVwBoRP.js → mcp-Cka8ywDF.js} +4 -5
- package/dist/{merge-driver-BTX87aVm.js → merge-driver-B04Apm29.js} +138 -122
- package/dist/migrate-D7TNl6SD.js +2169 -0
- package/dist/migrate-khCY8TE0.js +1 -0
- package/dist/{openai-CTaMDcl-.js → openai-RWw0YlAx.js} +128 -87
- package/dist/{output-DWE3SIUA.js → output-CF9uvk_-.js} +15 -9
- package/dist/parse.d.ts +1 -3
- package/dist/parse.js +7 -8
- package/dist/{pipeline-DbX6rlo5.js → pipeline-B30irGMD.js} +1 -1
- package/dist/{pipeline-C9Dbotkh.js → pipeline-sgl_q_op.js} +387 -359
- package/dist/project-DSzWKU3C.js +544 -0
- package/dist/{pseudo-DRv30iN5.js → pseudo-DNbNNVGP.js} +125 -3
- package/dist/{raw-C4Y6vyGY.js → raw-YsYZMS9n.js} +52 -29
- package/dist/react-intl-tzGIk6G3.js +634 -0
- package/dist/restore-BG_zMpSj.js +199 -0
- package/dist/rewrite-hAcRJwiZ.js +415 -0
- package/dist/{rich-DCUKl5HM.js → rich-ApY1Dm4S.js} +35 -28
- package/dist/rolldown-runtime-C1I3wEg2.js +43 -0
- package/dist/{rolldown-runtime-D7D4PA-g.js → rolldown-runtime-D8jQpDG7.js} +1 -2
- package/dist/run-CFzR3V93.js +647 -0
- package/dist/scan-worker.d.ts +2 -4
- package/dist/scan-worker.js +1 -1
- package/dist/{scoped-BMYpSthj.js → scoped-h3KE8XWW.js} +3 -4
- package/dist/{server-deBOq2vq.js → server-WlxZH0oX.js} +275 -330
- package/dist/{server-Da1Ot9IN.js → server-ceuzzkal.js} +292 -386
- package/dist/server.d.ts +1 -17
- package/dist/server.js +415 -381
- package/dist/{sitemap-DJXzKoza.js → sitemap-796jJKUT.js} +21 -33
- package/dist/{sources-D19czDSA.js → sources-DuOdM02f.js} +712 -373
- package/dist/{status-zr4jY59Y.js → status-CTH3qI-0.js} +30 -30
- package/dist/{stdio-FPOKQAgu.js → stdio-D9kTzyqB.js} +2 -4
- package/dist/{stdio-CVaJfxA7.js → stdio-FWIVU3P4.js} +1 -2
- package/dist/sync-CpL0Qsgw.js +1352 -0
- package/dist/{t-DC-c9zE5.js → t-gvEXx25s.js} +76 -53
- package/dist/test.d.ts +5 -16
- package/dist/test.js +77 -48
- package/dist/translate-BrfVRkjl.js +336 -0
- package/dist/{ts-BaU5yOf0.js → ts-BX6kwig5.js} +25 -14
- package/dist/{types-DtvQ7UdD.js → types-3kwyaCAm.js} +1 -2
- package/dist/{types-DsdWBG0b.d.ts → types-BaG1LboH.d.ts} +2 -6
- package/dist/{types-CgUCkFU1.d.ts → types-Cy2bPdSg.d.ts} +14 -20
- package/dist/types-Ds_vebja.js +41 -0
- package/dist/{units-CQ5Q99RC.js → units-VVLgQ7x7.js} +7 -16
- package/dist/{url-CRfCOhUI.js → url-Bpc6wLea.js} +24 -11
- package/dist/{url-CsBkRaJy.js → url-D2_VlEeH.js} +25 -12
- package/dist/{validate-D6DJepZv.js → validate-PGgMsasz.js} +3 -5
- package/dist/{validate-BxpupdAf.js → validate-zv4-IZyZ.js} +690 -377
- package/dist/{version-Byqi2guX.js → version-BFs370Ce.js} +3 -5
- package/dist/{vite-scan-CT_vsp4g.js → vite-scan-DFKSGVE9.js} +87 -92
- package/dist/vite.d.ts +2 -6
- package/dist/vite.js +6482 -6018
- package/dist/vue-i18n-CBmZqHbG.js +806 -0
- package/dist/{which-BOemZ5Q8.js → which-BpyJyBkX.js} +44 -37
- package/dist/{worker-84U6uYB3.js → worker-BjzVqJVO.js} +454 -608
- package/package.json +5 -5
- package/dist/check-HsmmpJZg.js +0 -1
- package/dist/codec-DuvU2VQy.js +0 -207
- package/dist/collisions-CfpZU8e4.js +0 -217
- package/dist/compile-BaDh0cHG.js +0 -245
- package/dist/concurrency-C9UUWuDC.js +0 -96
- package/dist/concurrency-DONL7t4V.js +0 -1
- package/dist/engine-C2ENBRJe.js +0 -531
- package/dist/i18next-9HAoxwUI.js +0 -1
- package/dist/i18next-BEJgv_S8.js +0 -1596
- package/dist/lingui-zUiCl9Um.js +0 -833
- package/dist/messages-BfjIExyB.js +0 -166
- package/dist/migrate-IpLDMXmq.js +0 -1484
- package/dist/migrate-rCQuOGsf.js +0 -1
- package/dist/project-Bw9UPIdx.js +0 -1046
- package/dist/project-C4GpaN-n.js +0 -381
- package/dist/react-intl-BP0u-D5m.js +0 -519
- package/dist/restore-CiYv-jxS.js +0 -175
- package/dist/rewrite-EsIw_lsq.js +0 -803
- package/dist/run-BEcnBbu-.js +0 -694
- package/dist/runtime-DTMmliT1.js +0 -64
- package/dist/sync-B9V2KFwb.js +0 -658
- package/dist/translate-CQnJfLjO.js +0 -299
- package/dist/types-wSh9fCBY.js +0 -11
- package/dist/vue-i18n-g0iGy6CZ.js +0 -651
|
@@ -1,299 +0,0 @@
|
|
|
1
|
-
import { o as isDiagnosticError } from "./types-D3QGM8XO.js";
|
|
2
|
-
import { a as ownedMessages, n as libraryCoverage, o as catalogLayout } from "./library-D5CWvTQs.js";
|
|
3
|
-
import { a as table, r as plural } from "./output-DWE3SIUA.js";
|
|
4
|
-
import { t as EXIT } from "./types-wSh9fCBY.js";
|
|
5
|
-
import { a as loadCatalogs, f as scan, i as hasErrors, o as loadProject, p as targetLocales, t as CliExit, u as readErrors } from "./project-C4GpaN-n.js";
|
|
6
|
-
import { t as adaptiveConcurrency } from "./concurrency-C9UUWuDC.js";
|
|
7
|
-
import { a as firstRequests, c as runTranslations, i as estimateUsage, n as catalogPersister, o as planTranslations, r as createProvider, s as replayProvider } from "./pipeline-C9Dbotkh.js";
|
|
8
|
-
//#region src/cli/commands/translate.ts
|
|
9
|
-
/**
|
|
10
|
-
* `vi18n translate [--locale l]… [--provider name] [--model id] [--tier t]
|
|
11
|
-
* [--retranslate ai|all] [--dry-run] [--max-cost usd]` (INTERNALS §2.15,
|
|
12
|
-
* PLAN §5.20): plan every locale against the catalogs on disk, estimate,
|
|
13
|
-
* then translate one locale after another, writing each finished batch
|
|
14
|
-
* before the next is paid for. Exit 1 when any item still failed after its
|
|
15
|
-
* retries.
|
|
16
|
-
*
|
|
17
|
-
* `--tier batch` first submits every locale's first requests as Gemini
|
|
18
|
-
* batch jobs and waits for them; their answers then replay into the same
|
|
19
|
-
* per-locale runs, whose retries go out synchronously.
|
|
20
|
-
*/
|
|
21
|
-
async function translate(ctx, flags) {
|
|
22
|
-
const project = await loadProject(ctx);
|
|
23
|
-
const { config, codec } = project;
|
|
24
|
-
const locales = targetLocales(config, flags.locales);
|
|
25
|
-
const scanned = await scan(project);
|
|
26
|
-
ctx.out.report(scanned.diagnostics.filter((d) => d.severity === "error"));
|
|
27
|
-
const loaded = await loadCatalogs(project);
|
|
28
|
-
const unreadable = readErrors(loaded.diagnostics);
|
|
29
|
-
let provider;
|
|
30
|
-
try {
|
|
31
|
-
provider = createProvider(config, {
|
|
32
|
-
...flags.model === null ? {} : { model: flags.model },
|
|
33
|
-
...flags.provider === null ? {} : { provider: flags.provider },
|
|
34
|
-
tier: flags.tier,
|
|
35
|
-
...ctx.io.fetch === void 0 ? {} : { fetch: ctx.io.fetch },
|
|
36
|
-
env: ctx.io.env
|
|
37
|
-
});
|
|
38
|
-
} catch (error) {
|
|
39
|
-
if (isDiagnosticError(error)) throw new CliExit(EXIT.usage, [error.diagnostic]);
|
|
40
|
-
throw error;
|
|
41
|
-
}
|
|
42
|
-
if (typeof provider.apiKeyEnv === "string") ctx.out.addSecret(ctx.io.env[provider.apiKeyEnv]);
|
|
43
|
-
const configured = config.ai.provider;
|
|
44
|
-
if (flags.model !== null && flags.provider === null && configured !== "gemini" && configured.withModel === void 0) ctx.out.note(`vi18n: --model is ignored: ai.provider is a custom provider (${provider.name}, ${provider.model})`);
|
|
45
|
-
const data = {
|
|
46
|
-
dryRun: flags.dryRun,
|
|
47
|
-
provider: provider.name,
|
|
48
|
-
model: provider.model,
|
|
49
|
-
tier: flags.tier,
|
|
50
|
-
locales: [],
|
|
51
|
-
estimate: {
|
|
52
|
-
requests: 0,
|
|
53
|
-
inputTokens: 0,
|
|
54
|
-
outputTokens: 0,
|
|
55
|
-
cost: 0
|
|
56
|
-
}
|
|
57
|
-
};
|
|
58
|
-
if (unreadable.length > 0) {
|
|
59
|
-
ctx.out.report(unreadable);
|
|
60
|
-
return {
|
|
61
|
-
exitCode: EXIT.failure,
|
|
62
|
-
data
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
const plans = /* @__PURE__ */ new Map();
|
|
66
|
-
const coverage = libraryCoverage(loaded.set, scanned.messages, config, codec);
|
|
67
|
-
for (const locale of locales) {
|
|
68
|
-
const plan = planTranslations({
|
|
69
|
-
config,
|
|
70
|
-
codec,
|
|
71
|
-
messages: ownedMessages(scanned.messages, locale, loaded.set.get(locale)?.catalog ?? null, coverage, {
|
|
72
|
-
sourceLocale: config.sourceLocale,
|
|
73
|
-
layout: catalogLayout(config),
|
|
74
|
-
codec
|
|
75
|
-
}),
|
|
76
|
-
catalogs: loaded.set,
|
|
77
|
-
locale,
|
|
78
|
-
retranslate: flags.retranslate
|
|
79
|
-
});
|
|
80
|
-
plans.set(locale, plan);
|
|
81
|
-
const usage = estimateUsage({
|
|
82
|
-
config,
|
|
83
|
-
locale,
|
|
84
|
-
plan
|
|
85
|
-
});
|
|
86
|
-
const estimate = {
|
|
87
|
-
...usage,
|
|
88
|
-
cost: costOf(provider, usage)
|
|
89
|
-
};
|
|
90
|
-
data.locales.push({
|
|
91
|
-
...emptySummary(locale),
|
|
92
|
-
estimate
|
|
93
|
-
});
|
|
94
|
-
addEstimate(data.estimate, estimate);
|
|
95
|
-
}
|
|
96
|
-
if (flags.maxCost !== null && data.estimate.requests > 0) {
|
|
97
|
-
const cost = data.estimate.cost;
|
|
98
|
-
if (cost === null || cost > flags.maxCost) {
|
|
99
|
-
ctx.out.report([{
|
|
100
|
-
code: "ai-cost-limit",
|
|
101
|
-
severity: "error",
|
|
102
|
-
message: cost === null ? `no price for ${provider.model}, so the cost of ${plural(data.estimate.requests, "request")} cannot be checked against --max-cost ${flags.maxCost}; nothing was sent` : `the estimated cost ${usd(cost)} of ${plural(data.estimate.requests, "request")} is over --max-cost ${usd(flags.maxCost)}; nothing was sent${flags.dryRun ? "" : " (see vi18n translate --dry-run)"}`
|
|
103
|
-
}]);
|
|
104
|
-
if (flags.dryRun) printEstimate(ctx, data);
|
|
105
|
-
return {
|
|
106
|
-
exitCode: EXIT.failure,
|
|
107
|
-
data
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
if (flags.dryRun) {
|
|
112
|
-
printEstimate(ctx, data);
|
|
113
|
-
return {
|
|
114
|
-
exitCode: hasErrors(ctx.out.diagnostics) ? EXIT.failure : EXIT.ok,
|
|
115
|
-
data
|
|
116
|
-
};
|
|
117
|
-
}
|
|
118
|
-
if (data.estimate.requests > 0) {
|
|
119
|
-
const missing = provider.missingKey?.() ?? null;
|
|
120
|
-
if (missing !== null) {
|
|
121
|
-
ctx.out.report([missing]);
|
|
122
|
-
return {
|
|
123
|
-
exitCode: EXIT.failure,
|
|
124
|
-
data
|
|
125
|
-
};
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
let failed = false;
|
|
129
|
-
let finished = 0;
|
|
130
|
-
const aborted = () => ctx.io.signal?.aborted === true;
|
|
131
|
-
const interrupted = () => {
|
|
132
|
-
data.interrupted = true;
|
|
133
|
-
data.locales = data.locales.filter((_, index) => index < finished);
|
|
134
|
-
ctx.out.note("vi18n translate: interrupted; finished batches are saved, rerun to translate the rest");
|
|
135
|
-
return {
|
|
136
|
-
exitCode: EXIT.failure,
|
|
137
|
-
data
|
|
138
|
-
};
|
|
139
|
-
};
|
|
140
|
-
let runner = provider;
|
|
141
|
-
if (flags.tier === "batch" && data.estimate.requests > 0) {
|
|
142
|
-
const requests = [];
|
|
143
|
-
for (const locale of locales) requests.push(...firstRequests({
|
|
144
|
-
config,
|
|
145
|
-
locale,
|
|
146
|
-
plan: plans.get(locale) ?? []
|
|
147
|
-
}));
|
|
148
|
-
if (provider.translateBatch === void 0) throw new CliExit(EXIT.usage, [{
|
|
149
|
-
code: "config-invalid",
|
|
150
|
-
severity: "error",
|
|
151
|
-
message: `--tier batch needs a provider with a batch API, not ${provider.name}`
|
|
152
|
-
}]);
|
|
153
|
-
ctx.out.note(`vi18n translate: sending ${plural(requests.length, "request")} as batch jobs; results can take minutes to hours (Ctrl-C cancels)`);
|
|
154
|
-
const states = /* @__PURE__ */ new Map();
|
|
155
|
-
try {
|
|
156
|
-
const answers = await provider.translateBatch(requests, {
|
|
157
|
-
...ctx.io.signal === void 0 ? {} : { signal: ctx.io.signal },
|
|
158
|
-
onProgress: ({ job, state }) => {
|
|
159
|
-
if (states.get(job) === state) return;
|
|
160
|
-
states.set(job, state);
|
|
161
|
-
ctx.out.note(`vi18n translate: ${job}: ${state}`);
|
|
162
|
-
}
|
|
163
|
-
});
|
|
164
|
-
runner = replayProvider(provider, requests, answers);
|
|
165
|
-
} catch (error) {
|
|
166
|
-
if (aborted()) return interrupted();
|
|
167
|
-
if (!isDiagnosticError(error)) throw error;
|
|
168
|
-
ctx.out.report([error.diagnostic]);
|
|
169
|
-
return {
|
|
170
|
-
exitCode: EXIT.failure,
|
|
171
|
-
data
|
|
172
|
-
};
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
const concurrency = adaptiveConcurrency(config.ai.concurrency);
|
|
176
|
-
for (let i = 0; i < locales.length; i++) {
|
|
177
|
-
if (aborted()) return interrupted();
|
|
178
|
-
const locale = locales[i];
|
|
179
|
-
const plan = plans.get(locale);
|
|
180
|
-
const persist = catalogPersister({
|
|
181
|
-
config,
|
|
182
|
-
codec,
|
|
183
|
-
locale,
|
|
184
|
-
messages: scanned.messages,
|
|
185
|
-
catalog: loaded.set.get(locale),
|
|
186
|
-
sourceCatalog: loaded.set.get(config.sourceLocale),
|
|
187
|
-
model: provider.model
|
|
188
|
-
});
|
|
189
|
-
let summary;
|
|
190
|
-
try {
|
|
191
|
-
summary = await runTranslations({
|
|
192
|
-
provider: runner,
|
|
193
|
-
config,
|
|
194
|
-
locale,
|
|
195
|
-
plan,
|
|
196
|
-
persist,
|
|
197
|
-
concurrency,
|
|
198
|
-
...ctx.io.signal === void 0 ? {} : { signal: ctx.io.signal }
|
|
199
|
-
});
|
|
200
|
-
} catch (error) {
|
|
201
|
-
if (aborted()) return interrupted();
|
|
202
|
-
if (!isDiagnosticError(error)) throw error;
|
|
203
|
-
ctx.out.report([{
|
|
204
|
-
...error.diagnostic,
|
|
205
|
-
locale: error.diagnostic.locale ?? locale
|
|
206
|
-
}]);
|
|
207
|
-
return {
|
|
208
|
-
exitCode: EXIT.failure,
|
|
209
|
-
data
|
|
210
|
-
};
|
|
211
|
-
}
|
|
212
|
-
const entry = data.locales[i];
|
|
213
|
-
Object.assign(entry, summary, { estimate: entry.estimate });
|
|
214
|
-
ctx.out.report(summaryDiagnostics(summary));
|
|
215
|
-
if (summary.failed.length > 0) failed = true;
|
|
216
|
-
if (summary.rateLimited !== void 0) ctx.out.note(`vi18n translate: ${locale} was rate-limited ${plural(summary.rateLimited.count, "time")}; requests in flight now ${summary.rateLimited.concurrency} of ${concurrency.max}`);
|
|
217
|
-
finished = i + 1;
|
|
218
|
-
ctx.out.result(`${locale}: ${summary.translated} translated, ${summary.reused} reused, ${summary.failed.length} failed of ${summary.requested} requested (${summary.usage.inputTokens} input / ${summary.usage.outputTokens} output tokens)`);
|
|
219
|
-
}
|
|
220
|
-
return {
|
|
221
|
-
exitCode: failed || hasErrors(ctx.out.diagnostics) ? EXIT.failure : EXIT.ok,
|
|
222
|
-
data
|
|
223
|
-
};
|
|
224
|
-
}
|
|
225
|
-
function emptySummary(locale) {
|
|
226
|
-
return {
|
|
227
|
-
locale,
|
|
228
|
-
requested: 0,
|
|
229
|
-
translated: 0,
|
|
230
|
-
reused: 0,
|
|
231
|
-
identical: [],
|
|
232
|
-
failed: [],
|
|
233
|
-
usage: {
|
|
234
|
-
inputTokens: 0,
|
|
235
|
-
outputTokens: 0
|
|
236
|
-
}
|
|
237
|
-
};
|
|
238
|
-
}
|
|
239
|
-
/** USD from the provider's pinned price table; null when it has none for the model. */
|
|
240
|
-
function costOf(provider, usage) {
|
|
241
|
-
if (usage.inputTokens === 0 && usage.outputTokens === 0) return 0;
|
|
242
|
-
const cost = provider.estimateCost?.(usage) ?? NaN;
|
|
243
|
-
return Number.isFinite(cost) ? cost : null;
|
|
244
|
-
}
|
|
245
|
-
function addEstimate(total, part) {
|
|
246
|
-
total.requests += part.requests;
|
|
247
|
-
total.inputTokens += part.inputTokens;
|
|
248
|
-
total.outputTokens += part.outputTokens;
|
|
249
|
-
total.cost = total.cost === null || part.cost === null ? null : total.cost + part.cost;
|
|
250
|
-
}
|
|
251
|
-
function usd(value) {
|
|
252
|
-
return `$${value < .01 && value > 0 ? value.toFixed(4) : value.toFixed(2)}`;
|
|
253
|
-
}
|
|
254
|
-
function printEstimate(ctx, data) {
|
|
255
|
-
const rows = data.locales.map((l) => [
|
|
256
|
-
l.locale,
|
|
257
|
-
l.estimate.requests,
|
|
258
|
-
l.estimate.inputTokens,
|
|
259
|
-
l.estimate.outputTokens,
|
|
260
|
-
l.estimate.cost === null ? "no price" : usd(l.estimate.cost)
|
|
261
|
-
]);
|
|
262
|
-
const t = data.estimate;
|
|
263
|
-
rows.push([
|
|
264
|
-
"total",
|
|
265
|
-
t.requests,
|
|
266
|
-
t.inputTokens,
|
|
267
|
-
t.outputTokens,
|
|
268
|
-
t.cost === null ? "no price" : usd(t.cost)
|
|
269
|
-
]);
|
|
270
|
-
ctx.out.result(table([
|
|
271
|
-
"locale",
|
|
272
|
-
"requests",
|
|
273
|
-
"input tokens",
|
|
274
|
-
"output tokens",
|
|
275
|
-
"cost"
|
|
276
|
-
], rows));
|
|
277
|
-
const tier = data.tier === "standard" ? "" : `, ${data.tier} tier`;
|
|
278
|
-
ctx.out.result(`dry run with ${data.model}${tier}: nothing was sent (tokens estimated at 4 characters each)`);
|
|
279
|
-
}
|
|
280
|
-
function summaryDiagnostics(summary) {
|
|
281
|
-
const out = [];
|
|
282
|
-
for (const id of summary.identical) out.push({
|
|
283
|
-
code: "ai-identical-output",
|
|
284
|
-
severity: "info",
|
|
285
|
-
message: `the ${summary.locale} translation of ${id} is identical to the source (often right for names and words like "OK"); review it if unexpected`,
|
|
286
|
-
locale: summary.locale,
|
|
287
|
-
id
|
|
288
|
-
});
|
|
289
|
-
for (const failure of summary.failed) out.push({
|
|
290
|
-
code: "ai-validation-failed",
|
|
291
|
-
severity: "error",
|
|
292
|
-
message: `${failure.id} was left untranslated after its retries: ${failure.checks.join("; ")}`,
|
|
293
|
-
locale: summary.locale,
|
|
294
|
-
id: failure.id
|
|
295
|
-
});
|
|
296
|
-
return out;
|
|
297
|
-
}
|
|
298
|
-
//#endregion
|
|
299
|
-
export { translate };
|
package/dist/types-wSh9fCBY.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
//#region src/cli/types.ts
|
|
2
|
-
/** Exit codes of every command. */
|
|
3
|
-
const EXIT = {
|
|
4
|
-
ok: 0,
|
|
5
|
-
/** Errors found, drift, a safety refusal, failed translations. */
|
|
6
|
-
failure: 1,
|
|
7
|
-
/** Bad flags, no config, invalid config. */
|
|
8
|
-
usage: 2
|
|
9
|
-
};
|
|
10
|
-
//#endregion
|
|
11
|
-
export { EXIT as t };
|