@menapo/vi18n 0.1.0 → 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/README.md +14 -14
- package/dist/{apply-Bre-lY9J.js → apply-FAHl1R6T.js} +69 -89
- package/dist/{captured-Bj8bO6vd.js → captured-CTjjDF5o.js} +196 -217
- package/dist/{check-DyrAbv73.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-DGsMbcTZ.js → export-BYq0gfLd.js} +17 -38
- package/dist/{extract-Dujlsgnk.js → extract-CYtuEo8u.js} +114 -82
- package/dist/{formats-KPIg-08V.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-Cwdhcywt.js → import-BApbQlmm.js} +81 -75
- package/dist/index.d.ts +1 -13
- package/dist/index.js +14 -16
- package/dist/{init-BecCTvKi.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 +69 -82
- 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-Cq1Nuu-Q.js → lsp-BC7xDGON.js} +4 -5
- package/dist/{match-BGr8EXB3.js → match-BLDcj610.js} +11 -4
- package/dist/{mcp-Cf0T7qPW.js → mcp-Cka8ywDF.js} +4 -5
- package/dist/{merge-driver-CpiiSVIc.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-DsaHKHEt.js → output-CF9uvk_-.js} +15 -9
- package/dist/parse.d.ts +1 -3
- package/dist/parse.js +7 -8
- package/dist/{pipeline-wxS0SApG.js → pipeline-B30irGMD.js} +1 -1
- package/dist/{pipeline-C7g11THL.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-BDkykMjb.js → server-WlxZH0oX.js} +275 -330
- package/dist/{server-qv3mz70d.js → server-ceuzzkal.js} +292 -386
- package/dist/server.d.ts +1 -17
- package/dist/server.js +415 -381
- package/dist/{sitemap-DV3o8QD7.js → sitemap-796jJKUT.js} +21 -33
- package/dist/{sources-D19czDSA.js → sources-DuOdM02f.js} +712 -373
- package/dist/{status-DZArW5aE.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-BlyLGlOa.js → version-BFs370Ce.js} +3 -5
- package/dist/{vite-scan-B_YW4X_a.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-C6PFI1Dm.js → which-BpyJyBkX.js} +44 -37
- package/dist/{worker-84U6uYB3.js → worker-BjzVqJVO.js} +454 -608
- package/package.json +8 -8
- package/dist/check-D34P-S--.js +0 -1
- package/dist/codec-DuvU2VQy.js +0 -207
- package/dist/collisions-CfpZU8e4.js +0 -217
- package/dist/compile-B5Mz6WJm.js +0 -245
- package/dist/concurrency-C9UUWuDC.js +0 -96
- package/dist/concurrency-DONL7t4V.js +0 -1
- package/dist/engine-B7p40M__.js +0 -531
- package/dist/i18next-CrUnKFfh.js +0 -1596
- package/dist/i18next-Rgo-v9l0.js +0 -1
- package/dist/lingui--PcOOYry.js +0 -833
- package/dist/messages-Cxa-5tR0.js +0 -166
- package/dist/migrate-CntqvrW4.js +0 -1
- package/dist/migrate-dPgq9uzy.js +0 -1484
- package/dist/project-Dwx7iPm6.js +0 -381
- package/dist/project-pXipT8iG.js +0 -1046
- package/dist/react-intl-CaBVwJ9u.js +0 -519
- package/dist/restore-Btq66Tid.js +0 -175
- package/dist/rewrite-CiTRAICl.js +0 -803
- package/dist/run-DYD_VXKy.js +0 -694
- package/dist/runtime-DTMmliT1.js +0 -64
- package/dist/sync-CcVzger_.js +0 -658
- package/dist/translate-DZR3MkSA.js +0 -299
- package/dist/types-wSh9fCBY.js +0 -11
- package/dist/vue-i18n-CEMnpv7k.js +0 -651
|
@@ -0,0 +1,336 @@
|
|
|
1
|
+
import { t as adaptiveConcurrency } from "./concurrency-Dy2ny50V.js";
|
|
2
|
+
import { a as firstRequests, c as runTranslations, i as estimateUsage, n as catalogPersister, o as planTranslations, r as createProvider, s as replayProvider } from "./pipeline-sgl_q_op.js";
|
|
3
|
+
import { a as ownedMessages, n as libraryCoverage } from "./library-BfSOBeBd.js";
|
|
4
|
+
import { n as isDiagnosticError } from "./diagnostics-1onDF6Ua.js";
|
|
5
|
+
import { a as table, r as plural } from "./output-CF9uvk_-.js";
|
|
6
|
+
import { a as hasErrors, f as readErrors, g as usageError, h as targetLocales, m as scan, o as loadCatalogs, s as loadProject, t as CliExit } from "./project-DSzWKU3C.js";
|
|
7
|
+
import { r as EXIT } from "./types-Ds_vebja.js";
|
|
8
|
+
// 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 locales = targetLocales(project.config, flags.locales);
|
|
24
|
+
const scanned = await scan(project);
|
|
25
|
+
ctx.out.report(scanned.diagnostics.filter((d) => d.severity === "error"));
|
|
26
|
+
const loaded = await loadCatalogs(project);
|
|
27
|
+
const unreadable = readErrors(loaded.diagnostics);
|
|
28
|
+
const provider = providerFor(ctx, project.config, flags);
|
|
29
|
+
const run = new TranslateRun(ctx, flags, project, {
|
|
30
|
+
messages: scanned.messages,
|
|
31
|
+
set: loaded.set
|
|
32
|
+
});
|
|
33
|
+
run.data.provider = provider.name;
|
|
34
|
+
run.data.model = provider.model;
|
|
35
|
+
if (unreadable.length > 0) {
|
|
36
|
+
ctx.out.report(unreadable);
|
|
37
|
+
return run.result(EXIT.failure);
|
|
38
|
+
}
|
|
39
|
+
run.plan(locales, provider);
|
|
40
|
+
if (!run.withinBudget(provider)) {
|
|
41
|
+
if (flags.dryRun) printEstimate(ctx, run.data);
|
|
42
|
+
return run.result(EXIT.failure);
|
|
43
|
+
}
|
|
44
|
+
if (flags.dryRun) {
|
|
45
|
+
printEstimate(ctx, run.data);
|
|
46
|
+
return run.result(hasErrors(ctx.out.diagnostics) ? EXIT.failure : EXIT.ok);
|
|
47
|
+
}
|
|
48
|
+
if (run.data.estimate.requests > 0) {
|
|
49
|
+
const missing = provider.missingKey?.() ?? null;
|
|
50
|
+
if (missing !== null) {
|
|
51
|
+
ctx.out.report([missing]);
|
|
52
|
+
return run.result(EXIT.failure);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return run.translate(locales, provider);
|
|
56
|
+
}
|
|
57
|
+
/** The provider the flags and config name; its key is redacted from every output. */
|
|
58
|
+
function providerFor(ctx, config, flags) {
|
|
59
|
+
let provider;
|
|
60
|
+
try {
|
|
61
|
+
provider = createProvider(config, {
|
|
62
|
+
...flags.model === null ? {} : { model: flags.model },
|
|
63
|
+
...flags.provider === null ? {} : { provider: flags.provider },
|
|
64
|
+
tier: flags.tier,
|
|
65
|
+
...ctx.io.fetch === void 0 ? {} : { fetch: ctx.io.fetch },
|
|
66
|
+
env: ctx.io.env
|
|
67
|
+
});
|
|
68
|
+
} catch (error) {
|
|
69
|
+
if (isDiagnosticError(error)) throw new CliExit(EXIT.usage, [error.diagnostic]);
|
|
70
|
+
throw error;
|
|
71
|
+
}
|
|
72
|
+
if (typeof provider.apiKeyEnv === "string") ctx.out.addSecret(ctx.io.env[provider.apiKeyEnv]);
|
|
73
|
+
const configured = config.ai.provider;
|
|
74
|
+
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})`);
|
|
75
|
+
return provider;
|
|
76
|
+
}
|
|
77
|
+
/** One `vi18n translate` run: the plans per locale, then the locales translated one after another. */
|
|
78
|
+
var TranslateRun = class {
|
|
79
|
+
data;
|
|
80
|
+
ctx;
|
|
81
|
+
flags;
|
|
82
|
+
project;
|
|
83
|
+
messages;
|
|
84
|
+
set;
|
|
85
|
+
plans = /* @__PURE__ */ new Map();
|
|
86
|
+
/** Locales whose summary is complete. */
|
|
87
|
+
finished = 0;
|
|
88
|
+
constructor(ctx, flags, project, input) {
|
|
89
|
+
this.ctx = ctx;
|
|
90
|
+
this.flags = flags;
|
|
91
|
+
this.project = project;
|
|
92
|
+
this.messages = input.messages;
|
|
93
|
+
this.set = input.set;
|
|
94
|
+
this.data = {
|
|
95
|
+
dryRun: flags.dryRun,
|
|
96
|
+
provider: "",
|
|
97
|
+
model: "",
|
|
98
|
+
tier: flags.tier,
|
|
99
|
+
locales: [],
|
|
100
|
+
estimate: {
|
|
101
|
+
requests: 0,
|
|
102
|
+
inputTokens: 0,
|
|
103
|
+
outputTokens: 0,
|
|
104
|
+
cost: 0
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
result(exitCode) {
|
|
109
|
+
return {
|
|
110
|
+
exitCode,
|
|
111
|
+
data: this.data
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
plan(locales, provider) {
|
|
115
|
+
const { config, codec, layout } = this.project;
|
|
116
|
+
const coverage = libraryCoverage(this.set, this.messages, config, codec);
|
|
117
|
+
for (const locale of locales) {
|
|
118
|
+
const plan = planTranslations({
|
|
119
|
+
config,
|
|
120
|
+
codec,
|
|
121
|
+
messages: ownedMessages(this.messages, locale, this.set.get(locale)?.catalog ?? null, coverage, {
|
|
122
|
+
sourceLocale: config.sourceLocale,
|
|
123
|
+
layout,
|
|
124
|
+
codec
|
|
125
|
+
}),
|
|
126
|
+
catalogs: this.set,
|
|
127
|
+
locale,
|
|
128
|
+
retranslate: this.flags.retranslate
|
|
129
|
+
});
|
|
130
|
+
this.plans.set(locale, plan);
|
|
131
|
+
const usage = estimateUsage({
|
|
132
|
+
config,
|
|
133
|
+
locale,
|
|
134
|
+
plan
|
|
135
|
+
});
|
|
136
|
+
const estimate = {
|
|
137
|
+
...usage,
|
|
138
|
+
cost: costOf(provider, usage)
|
|
139
|
+
};
|
|
140
|
+
this.data.locales.push({
|
|
141
|
+
...emptySummary(locale),
|
|
142
|
+
estimate
|
|
143
|
+
});
|
|
144
|
+
addEstimate(this.data.estimate, estimate);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
/** `--max-cost`: false (reported) when the estimate is over it or has no price. */
|
|
148
|
+
withinBudget(provider) {
|
|
149
|
+
const { maxCost, dryRun } = this.flags;
|
|
150
|
+
const { estimate } = this.data;
|
|
151
|
+
if (maxCost === null || estimate.requests === 0) return true;
|
|
152
|
+
const cost = estimate.cost;
|
|
153
|
+
if (cost !== null && cost <= maxCost) return true;
|
|
154
|
+
this.ctx.out.report([{
|
|
155
|
+
code: "ai-cost-limit",
|
|
156
|
+
severity: "error",
|
|
157
|
+
message: cost === null ? `no price for ${provider.model}, so the cost of ${plural(estimate.requests, "request")} cannot be checked against --max-cost ${maxCost}; nothing was sent` : `the estimated cost ${usd(cost)} of ${plural(estimate.requests, "request")} is over --max-cost ${usd(maxCost)}; nothing was sent${dryRun ? "" : " (see vi18n translate --dry-run)"}`
|
|
158
|
+
}]);
|
|
159
|
+
return false;
|
|
160
|
+
}
|
|
161
|
+
async translate(locales, provider) {
|
|
162
|
+
let runner = provider;
|
|
163
|
+
if (this.flags.tier === "batch" && this.data.estimate.requests > 0) {
|
|
164
|
+
const batched = await this.submitBatch(locales, provider);
|
|
165
|
+
if ("exitCode" in batched) return batched;
|
|
166
|
+
runner = batched.provider;
|
|
167
|
+
}
|
|
168
|
+
const concurrency = adaptiveConcurrency(this.project.config.ai.concurrency);
|
|
169
|
+
let failed = false;
|
|
170
|
+
for (let i = 0; i < locales.length; i++) {
|
|
171
|
+
if (this.aborted()) return this.interrupted();
|
|
172
|
+
const summary = await this.translateLocale(i, locales[i], runner, concurrency);
|
|
173
|
+
if ("exitCode" in summary) return summary;
|
|
174
|
+
if (summary.failed.length > 0) failed = true;
|
|
175
|
+
}
|
|
176
|
+
const exitCode = failed || hasErrors(this.ctx.out.diagnostics) ? EXIT.failure : EXIT.ok;
|
|
177
|
+
return this.result(exitCode);
|
|
178
|
+
}
|
|
179
|
+
/** `--tier batch`: every locale's first requests as batch jobs, replayed into the per-locale runs. */
|
|
180
|
+
async submitBatch(locales, provider) {
|
|
181
|
+
const { config } = this.project;
|
|
182
|
+
const requests = [];
|
|
183
|
+
for (const locale of locales) requests.push(...firstRequests({
|
|
184
|
+
config,
|
|
185
|
+
locale,
|
|
186
|
+
plan: this.plans.get(locale) ?? []
|
|
187
|
+
}));
|
|
188
|
+
if (provider.translateBatch === void 0) throw usageError(`--tier batch needs a provider with a batch API, not ${provider.name}`);
|
|
189
|
+
this.ctx.out.note(`vi18n translate: sending ${plural(requests.length, "request")} as batch jobs; results can take minutes to hours (Ctrl-C cancels)`);
|
|
190
|
+
const states = /* @__PURE__ */ new Map();
|
|
191
|
+
try {
|
|
192
|
+
const answers = await provider.translateBatch(requests, {
|
|
193
|
+
...this.signal(),
|
|
194
|
+
onProgress: ({ job, state }) => {
|
|
195
|
+
if (states.get(job) === state) return;
|
|
196
|
+
states.set(job, state);
|
|
197
|
+
this.ctx.out.note(`vi18n translate: ${job}: ${state}`);
|
|
198
|
+
}
|
|
199
|
+
});
|
|
200
|
+
return { provider: replayProvider(provider, requests, answers) };
|
|
201
|
+
} catch (error) {
|
|
202
|
+
return this.failure(error);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
async translateLocale(index, locale, provider, concurrency) {
|
|
206
|
+
const { config, codec } = this.project;
|
|
207
|
+
const persist = catalogPersister({
|
|
208
|
+
config,
|
|
209
|
+
codec,
|
|
210
|
+
locale,
|
|
211
|
+
messages: this.messages,
|
|
212
|
+
catalog: this.set.get(locale),
|
|
213
|
+
sourceCatalog: this.set.get(config.sourceLocale),
|
|
214
|
+
model: provider.model
|
|
215
|
+
});
|
|
216
|
+
let summary;
|
|
217
|
+
try {
|
|
218
|
+
summary = await runTranslations({
|
|
219
|
+
provider,
|
|
220
|
+
config,
|
|
221
|
+
locale,
|
|
222
|
+
plan: this.plans.get(locale),
|
|
223
|
+
persist,
|
|
224
|
+
concurrency,
|
|
225
|
+
...this.signal()
|
|
226
|
+
});
|
|
227
|
+
} catch (error) {
|
|
228
|
+
return this.failure(error, locale);
|
|
229
|
+
}
|
|
230
|
+
const entry = this.data.locales[index];
|
|
231
|
+
Object.assign(entry, summary, { estimate: entry.estimate });
|
|
232
|
+
this.ctx.out.report(summaryDiagnostics(summary));
|
|
233
|
+
if (summary.rateLimited !== void 0) this.ctx.out.note(`vi18n translate: ${locale} was rate-limited ${plural(summary.rateLimited.count, "time")}; requests in flight now ${summary.rateLimited.concurrency} of ${concurrency.max}`);
|
|
234
|
+
this.finished = index + 1;
|
|
235
|
+
this.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)`);
|
|
236
|
+
return summary;
|
|
237
|
+
}
|
|
238
|
+
/** A provider error ends the run (batches finished before it are already on disk); Ctrl-C is an interruption. */
|
|
239
|
+
failure(error, locale) {
|
|
240
|
+
if (this.aborted()) return this.interrupted();
|
|
241
|
+
if (!isDiagnosticError(error)) throw error;
|
|
242
|
+
const diagnostic = error.diagnostic;
|
|
243
|
+
this.ctx.out.report([locale === void 0 ? diagnostic : {
|
|
244
|
+
...diagnostic,
|
|
245
|
+
locale: diagnostic.locale ?? locale
|
|
246
|
+
}]);
|
|
247
|
+
return this.result(EXIT.failure);
|
|
248
|
+
}
|
|
249
|
+
signal() {
|
|
250
|
+
return this.ctx.io.signal === void 0 ? {} : { signal: this.ctx.io.signal };
|
|
251
|
+
}
|
|
252
|
+
/** A method, not a narrowed property read: the signal flips while awaiting. */
|
|
253
|
+
aborted() {
|
|
254
|
+
return this.ctx.io.signal?.aborted === true;
|
|
255
|
+
}
|
|
256
|
+
interrupted() {
|
|
257
|
+
this.data.interrupted = true;
|
|
258
|
+
this.data.locales = this.data.locales.filter((_, index) => index < this.finished);
|
|
259
|
+
this.ctx.out.note("vi18n translate: interrupted; finished batches are saved, rerun to translate the rest");
|
|
260
|
+
return this.result(EXIT.failure);
|
|
261
|
+
}
|
|
262
|
+
};
|
|
263
|
+
function emptySummary(locale) {
|
|
264
|
+
return {
|
|
265
|
+
locale,
|
|
266
|
+
requested: 0,
|
|
267
|
+
translated: 0,
|
|
268
|
+
reused: 0,
|
|
269
|
+
identical: [],
|
|
270
|
+
failed: [],
|
|
271
|
+
usage: {
|
|
272
|
+
inputTokens: 0,
|
|
273
|
+
outputTokens: 0
|
|
274
|
+
}
|
|
275
|
+
};
|
|
276
|
+
}
|
|
277
|
+
/** USD from the provider's pinned price table; null when it has none for the model. */
|
|
278
|
+
function costOf(provider, usage) {
|
|
279
|
+
if (usage.inputTokens === 0 && usage.outputTokens === 0) return 0;
|
|
280
|
+
const cost = provider.estimateCost?.(usage) ?? NaN;
|
|
281
|
+
return Number.isFinite(cost) ? cost : null;
|
|
282
|
+
}
|
|
283
|
+
function addEstimate(total, part) {
|
|
284
|
+
total.requests += part.requests;
|
|
285
|
+
total.inputTokens += part.inputTokens;
|
|
286
|
+
total.outputTokens += part.outputTokens;
|
|
287
|
+
total.cost = total.cost === null || part.cost === null ? null : total.cost + part.cost;
|
|
288
|
+
}
|
|
289
|
+
function usd(value) {
|
|
290
|
+
return `$${value < .01 && value > 0 ? value.toFixed(4) : value.toFixed(2)}`;
|
|
291
|
+
}
|
|
292
|
+
function printEstimate(ctx, data) {
|
|
293
|
+
const rows = data.locales.map((l) => [
|
|
294
|
+
l.locale,
|
|
295
|
+
l.estimate.requests,
|
|
296
|
+
l.estimate.inputTokens,
|
|
297
|
+
l.estimate.outputTokens,
|
|
298
|
+
l.estimate.cost === null ? "no price" : usd(l.estimate.cost)
|
|
299
|
+
]);
|
|
300
|
+
const t = data.estimate;
|
|
301
|
+
rows.push([
|
|
302
|
+
"total",
|
|
303
|
+
t.requests,
|
|
304
|
+
t.inputTokens,
|
|
305
|
+
t.outputTokens,
|
|
306
|
+
t.cost === null ? "no price" : usd(t.cost)
|
|
307
|
+
]);
|
|
308
|
+
ctx.out.result(table([
|
|
309
|
+
"locale",
|
|
310
|
+
"requests",
|
|
311
|
+
"input tokens",
|
|
312
|
+
"output tokens",
|
|
313
|
+
"cost"
|
|
314
|
+
], rows));
|
|
315
|
+
const tier = data.tier === "standard" ? "" : `, ${data.tier} tier`;
|
|
316
|
+
ctx.out.result(`dry run with ${data.model}${tier}: nothing was sent (tokens estimated at 4 characters each)`);
|
|
317
|
+
}
|
|
318
|
+
function summaryDiagnostics(summary) {
|
|
319
|
+
const out = [];
|
|
320
|
+
for (const id of summary.identical) out.push({
|
|
321
|
+
code: "ai-identical-output",
|
|
322
|
+
severity: "info",
|
|
323
|
+
message: `the ${summary.locale} translation of ${id} is identical to the source (often right for names and words like "OK"); review it if unexpected`,
|
|
324
|
+
locale: summary.locale,
|
|
325
|
+
id
|
|
326
|
+
});
|
|
327
|
+
for (const failure of summary.failed) out.push({
|
|
328
|
+
code: "ai-validation-failed",
|
|
329
|
+
severity: "error",
|
|
330
|
+
message: `${failure.id} was left untranslated after its retries: ${failure.checks.join("; ")}`,
|
|
331
|
+
locale: summary.locale,
|
|
332
|
+
id: failure.id
|
|
333
|
+
});
|
|
334
|
+
return out;
|
|
335
|
+
}
|
|
336
|
+
export { translate };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// ../../node_modules/.pnpm/oxc-parser@0.156.0/node_modules/oxc-parser/src-js/generated/deserialize/ts.js
|
|
2
2
|
let uint8;
|
|
3
3
|
let int32;
|
|
4
4
|
let float64;
|
|
@@ -346,11 +346,10 @@ function deserializeTaggedTemplateExpression(pos) {
|
|
|
346
346
|
return node;
|
|
347
347
|
}
|
|
348
348
|
function deserializeTemplateElement(pos) {
|
|
349
|
-
let tail = deserializeBool(pos + 12), start = deserializeI32(pos) - 1, end = deserializeI32(pos + 4) + 2 - tail
|
|
350
|
-
value.cooked !== null && deserializeBool(pos + 13) && (value.cooked = value.cooked.replace(/\uFFFD(.{4})/g, (_, hex) => String.fromCodePoint(parseInt(hex, 16))));
|
|
349
|
+
let tail = deserializeBool(pos + 12), start = deserializeI32(pos) - 1, end = deserializeI32(pos + 4) + 2 - tail;
|
|
351
350
|
return {
|
|
352
351
|
type: "TemplateElement",
|
|
353
|
-
value,
|
|
352
|
+
value: deserializeTemplateElementValue(pos + 16),
|
|
354
353
|
tail,
|
|
355
354
|
start,
|
|
356
355
|
end
|
|
@@ -359,7 +358,7 @@ function deserializeTemplateElement(pos) {
|
|
|
359
358
|
function deserializeTemplateElementValue(pos) {
|
|
360
359
|
return {
|
|
361
360
|
raw: deserializeStr(pos),
|
|
362
|
-
cooked:
|
|
361
|
+
cooked: deserializeOptionJSStr(pos + 16)
|
|
363
362
|
};
|
|
364
363
|
}
|
|
365
364
|
function deserializeComputedMemberExpression(pos) {
|
|
@@ -2054,16 +2053,14 @@ function deserializeNumericLiteral(pos) {
|
|
|
2054
2053
|
};
|
|
2055
2054
|
}
|
|
2056
2055
|
function deserializeStringLiteral(pos) {
|
|
2057
|
-
let start = deserializeI32(pos), end = deserializeI32(pos + 4)
|
|
2056
|
+
let start = deserializeI32(pos), end = deserializeI32(pos + 4);
|
|
2057
|
+
return {
|
|
2058
2058
|
type: "Literal",
|
|
2059
|
-
value:
|
|
2059
|
+
value: deserializeJSStr(pos + 16),
|
|
2060
2060
|
raw: int32[(pos >> 2) + 8] === 0 && int32[(pos >> 2) + 9] === 0 ? null : sourceText.slice(start, end),
|
|
2061
2061
|
start,
|
|
2062
2062
|
end
|
|
2063
|
-
}
|
|
2064
|
-
deserializeBool(pos + 12) && (value = value.replace(/\uFFFD(.{4})/g, (_, hex) => String.fromCodePoint(parseInt(hex, 16))));
|
|
2065
|
-
node.value = value;
|
|
2066
|
-
return node;
|
|
2063
|
+
};
|
|
2067
2064
|
}
|
|
2068
2065
|
function deserializeBigIntLiteral(pos) {
|
|
2069
2066
|
let start = deserializeI32(pos), end = deserializeI32(pos + 4), bigint = deserializeStr(pos + 16);
|
|
@@ -4082,8 +4079,20 @@ function deserializeBoxTSTypeParameterInstantiation(pos) {
|
|
|
4082
4079
|
function deserializeOptionBoxTSTypeParameterInstantiation(pos) {
|
|
4083
4080
|
return int32[pos >> 2] === 0 && int32[(pos >> 2) + 1] === 0 ? null : deserializeBoxTSTypeParameterInstantiation(pos);
|
|
4084
4081
|
}
|
|
4085
|
-
function
|
|
4086
|
-
|
|
4082
|
+
function deserializeJSStr(pos) {
|
|
4083
|
+
if (uint8[pos + 12] === 0) return deserializeStr(pos);
|
|
4084
|
+
let buffer = uint8, pos32 = pos >> 2, len = int32[pos32 + 2];
|
|
4085
|
+
pos = int32[pos32];
|
|
4086
|
+
let end = pos + len, out = "";
|
|
4087
|
+
for (; pos < end;) {
|
|
4088
|
+
let first = buffer[pos++], codePoint;
|
|
4089
|
+
codePoint = first < 128 ? first : first < 224 ? (first & 31) << 6 | buffer[pos++] & 63 : first < 240 ? (first & 15) << 12 | (buffer[pos++] & 63) << 6 | buffer[pos++] & 63 : (first & 7) << 18 | (buffer[pos++] & 63) << 12 | (buffer[pos++] & 63) << 6 | buffer[pos++] & 63;
|
|
4090
|
+
out += String.fromCodePoint(codePoint);
|
|
4091
|
+
}
|
|
4092
|
+
return out;
|
|
4093
|
+
}
|
|
4094
|
+
function deserializeOptionJSStr(pos) {
|
|
4095
|
+
return uint8[pos + 12] === 2 ? null : deserializeJSStr(pos);
|
|
4087
4096
|
}
|
|
4088
4097
|
function deserializeBoxComputedMemberExpression(pos) {
|
|
4089
4098
|
return deserializeComputedMemberExpression(int32[pos >> 2]);
|
|
@@ -4489,6 +4498,9 @@ function deserializeOptionModuleExportName(pos) {
|
|
|
4489
4498
|
function deserializeF64(pos) {
|
|
4490
4499
|
return float64[pos >> 3];
|
|
4491
4500
|
}
|
|
4501
|
+
function deserializeOptionStr(pos) {
|
|
4502
|
+
return int32[pos >> 2] === 0 && int32[(pos >> 2) + 1] === 0 ? null : deserializeStr(pos);
|
|
4503
|
+
}
|
|
4492
4504
|
function deserializeU8(pos) {
|
|
4493
4505
|
return uint8[pos];
|
|
4494
4506
|
}
|
|
@@ -4859,5 +4871,4 @@ function deserializeVecExportEntry(pos) {
|
|
|
4859
4871
|
}
|
|
4860
4872
|
return arr;
|
|
4861
4873
|
}
|
|
4862
|
-
//#endregion
|
|
4863
4874
|
export { deserialize };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as z from "zod/v4";
|
|
2
|
-
|
|
2
|
+
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.32.1_supports-color@10.2.2_zod@4.6.7/node_modules/@modelcontextprotocol/sdk/dist/esm/types.js
|
|
3
3
|
const LATEST_PROTOCOL_VERSION = "2025-11-25";
|
|
4
4
|
const SUPPORTED_PROTOCOL_VERSIONS = [
|
|
5
5
|
LATEST_PROTOCOL_VERSION,
|
|
@@ -1944,5 +1944,4 @@ var UrlElicitationRequiredError = class extends McpError {
|
|
|
1944
1944
|
return this.data?.elicitations ?? [];
|
|
1945
1945
|
}
|
|
1946
1946
|
};
|
|
1947
|
-
//#endregion
|
|
1948
1947
|
export { PingRequestSchema as A, isJSONRPCNotification as B, ListResourcesRequestSchema as C, ListToolsRequestSchema as D, ListTasksResultSchema as E, SetLevelRequestSchema as F, isJSONRPCResultResponse as H, TaskStatusNotificationSchema as I, assertCompleteRequestPrompt as L, RELATED_TASK_META_KEY as M, ReadResourceRequestSchema as N, LoggingLevelSchema as O, SUPPORTED_PROTOCOL_VERSIONS as P, assertCompleteRequestResourceTemplate as R, ListResourceTemplatesRequestSchema as S, ListTasksRequestSchema as T, isTaskAugmentedRequestParams as U, isJSONRPCRequest as V, InitializeRequestSchema as _, CancelledNotificationSchema as a, LATEST_PROTOCOL_VERSION as b, CreateMessageResultWithToolsSchema as c, EmptyResultSchema as d, ErrorCode as f, GetTaskResultSchema as g, GetTaskRequestSchema as h, CancelTaskResultSchema as i, ProgressNotificationSchema as j, McpError as k, CreateTaskResultSchema as l, GetTaskPayloadRequestSchema as m, CallToolResultSchema as n, CompleteRequestSchema as o, GetPromptRequestSchema as p, CancelTaskRequestSchema as r, CreateMessageResultSchema as s, CallToolRequestSchema as t, ElicitResultSchema as u, InitializedNotificationSchema as v, ListRootsResultSchema as w, ListPromptsRequestSchema as x, JSONRPCMessageSchema as y, isJSONRPCErrorResponse as z };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/runtime/typed.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* Augmented by the generated `vi18n.gen.ts`:
|
|
4
3
|
*
|
|
@@ -106,9 +105,9 @@ type DefaultTags = Register extends {
|
|
|
106
105
|
defaultTags: infer T extends string;
|
|
107
106
|
} ? T : never;
|
|
108
107
|
/** The literal text of a message, `never` for anything typed as a runtime id. */
|
|
109
|
-
type TextOf<M> = M extends string ?
|
|
108
|
+
type TextOf<M> = M extends string ? Literal<M> : M extends {
|
|
110
109
|
readonly message: infer T extends string;
|
|
111
|
-
} ?
|
|
110
|
+
} ? Literal<T> : never;
|
|
112
111
|
type Untyped = [values?: Values];
|
|
113
112
|
type Rich<S extends string, H, N, WithTags extends boolean> = [S] extends [never] ? Untyped : ValuesOf<S> extends (infer A) ? Unreadable extends A ? Untyped : (WithTags extends true ? TagsOf<S, never> : never) extends (infer Tg extends string) ? string extends Tg ? Untyped : Handlers<Tg, H, Args<A, N>> : never : never;
|
|
114
113
|
/** The argument object of a `ValuesOf` result; a plain `{x}` takes nodes too. */
|
|
@@ -216,8 +215,6 @@ type Trim<S extends string> = S extends `${Space}${infer R}` ? Trim<R> : S exten
|
|
|
216
215
|
* it, so marks wait in `Marks` until that is known.
|
|
217
216
|
*/
|
|
218
217
|
type TrimEnd<S extends string, Marks extends string> = S extends `${infer R}${Space}` ? S extends `${R}\u200e` ? TrimEnd<R, `\u200e${Marks}`> : S extends `${R}\u200f` ? TrimEnd<R, `\u200f${Marks}`> : TrimEnd<R, ""> : `${S}${Marks}`;
|
|
219
|
-
//#endregion
|
|
220
|
-
//#region src/runtime/types.d.ts
|
|
221
218
|
/**
|
|
222
219
|
* A compiled message. Plain text stays a string (about 81 % of real messages),
|
|
223
220
|
* everything else is a list of parts. Never a function: the IR has to cross
|
|
@@ -554,5 +551,4 @@ declare global {
|
|
|
554
551
|
*/
|
|
555
552
|
var __VI18N_INLINE__: boolean | undefined;
|
|
556
553
|
}
|
|
557
|
-
//#endregion
|
|
558
554
|
export { Locale as C, ValuesOf as D, RichValuesOf as E, LibraryMessages as S, RichPartsValuesOf as T, TagHandler as _, Message as a, Values as b, MissingHandler as c, RichHtmlFunction as d, RichPart as f, TFunction as g, Scope as h, HtmlTagHandler as i, MissingInfo as l, RuntimeConfig as m, Descriptor as n, MessageKey as o, RichPartsFunction as p, Fmt as r, MessageRef as s, DateInput as t, RichFunction as u, TemporalInput as v, Register as w, DefaultTags as x, Translator as y };
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
/** Options handed to `Intl.NumberFormat` / `Intl.DateTimeFormat` as they are. */
|
|
2
|
+
type IntlOptions = {
|
|
3
|
+
[option: string]: string | number | boolean;
|
|
4
|
+
};
|
|
2
5
|
/** Where a locale may come from, in `routing.strategy` order. */
|
|
3
6
|
type LocaleStrategy = "url" | "cookie" | "header" | "localStorage" | "default";
|
|
4
7
|
/** URL codec strategies (Nuxt i18n names); domains are `routing.domains` on top of `prefix_except_default`. */
|
|
@@ -37,8 +40,6 @@ declare global {
|
|
|
37
40
|
*/
|
|
38
41
|
var __VI18N_INLINE__: boolean | undefined;
|
|
39
42
|
}
|
|
40
|
-
//#endregion
|
|
41
|
-
//#region src/core/types.d.ts
|
|
42
43
|
type Severity = "error" | "warning" | "info";
|
|
43
44
|
/**
|
|
44
45
|
* Every problem vi18n reports has one of these codes. The CLI prints them in
|
|
@@ -104,9 +105,7 @@ interface IcuFormatted {
|
|
|
104
105
|
* Intl options resolved by the parser (FormatJS `formats` tables for
|
|
105
106
|
* keywords, skeleton conversion for `::…`). Null when Intl defaults apply.
|
|
106
107
|
*/
|
|
107
|
-
options:
|
|
108
|
-
[option: string]: string | number | boolean;
|
|
109
|
-
} | null;
|
|
108
|
+
options: IntlOptions | null;
|
|
110
109
|
loc?: IcuLoc;
|
|
111
110
|
}
|
|
112
111
|
/**
|
|
@@ -201,8 +200,6 @@ interface MessageOccurrence {
|
|
|
201
200
|
line: number;
|
|
202
201
|
column: number;
|
|
203
202
|
}
|
|
204
|
-
//#endregion
|
|
205
|
-
//#region src/ai/types.d.ts
|
|
206
203
|
/** Whatever a provider needs to answer one request. One target locale per request. */
|
|
207
204
|
interface ProviderRequest {
|
|
208
205
|
sourceLocale: string;
|
|
@@ -254,10 +251,12 @@ interface ProviderResponse {
|
|
|
254
251
|
id: string;
|
|
255
252
|
translation: string;
|
|
256
253
|
}[];
|
|
257
|
-
usage?:
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
254
|
+
usage?: TokenUsage;
|
|
255
|
+
}
|
|
256
|
+
/** Tokens a request, a run or an estimate counts. */
|
|
257
|
+
interface TokenUsage {
|
|
258
|
+
inputTokens: number;
|
|
259
|
+
outputTokens: number;
|
|
261
260
|
}
|
|
262
261
|
/** What the pipeline passes with each request. */
|
|
263
262
|
interface TranslateOptions {
|
|
@@ -279,10 +278,7 @@ interface TranslationProvider {
|
|
|
279
278
|
* `--dry-run` / `--max-cost`: estimated USD for the given token counts, from a
|
|
280
279
|
* pinned price table; `NaN` when the model has no known price.
|
|
281
280
|
*/
|
|
282
|
-
estimateCost?(usage:
|
|
283
|
-
inputTokens: number;
|
|
284
|
-
outputTokens: number;
|
|
285
|
-
}): number;
|
|
281
|
+
estimateCost?(usage: TokenUsage): number;
|
|
286
282
|
/**
|
|
287
283
|
* The environment variable the key is read from, null when no key is sent.
|
|
288
284
|
* The CLI redacts its value from all output.
|
|
@@ -353,12 +349,11 @@ interface OpenAICompatibleOptions extends Omit<ProviderOptions, "tier"> {
|
|
|
353
349
|
type JsonSchema = {
|
|
354
350
|
[keyword: string]: unknown;
|
|
355
351
|
};
|
|
356
|
-
//#endregion
|
|
357
|
-
//#region src/config/types.d.ts
|
|
358
352
|
/** Severity of a `strict` rule. */
|
|
359
353
|
type Level = "off" | "warn" | "error";
|
|
360
354
|
/** The two generated pseudo-locales (PLAN §4.7, §5.21). */
|
|
361
|
-
|
|
355
|
+
declare const PSEUDO_LOCALES: readonly ["en-XA", "ar-XB"];
|
|
356
|
+
type PseudoLocale = (typeof PSEUDO_LOCALES)[number];
|
|
362
357
|
/** `vi18n.config.ts` as written. Every key is optional except where noted. */
|
|
363
358
|
interface Vi18nConfig {
|
|
364
359
|
/** Default `"en"`. Also the default locale of URL strategies and negotiation. */
|
|
@@ -703,5 +698,4 @@ type TagDefault = string | {
|
|
|
703
698
|
[name: string]: string;
|
|
704
699
|
};
|
|
705
700
|
};
|
|
706
|
-
//#endregion
|
|
707
701
|
export { MessageOccurrence as _, Vi18nConfig as a, OpenAICompatibleOptions as c, ProviderResponse as d, Tier as f, MessageCodec as g, Diagnostic as h, ResolvedConfig as i, ProviderOptions as l, TranslationProvider as m, OutputOptions as n, AiItem as o, TranslateOptions as p, PseudoLocale as r, BatchOptions as s, Level as t, ProviderRequest as u, LocaleStrategy as v, UrlStrategy as y };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// src/cli/types.ts
|
|
2
|
+
const COMMAND_NAMES = [
|
|
3
|
+
"init",
|
|
4
|
+
"extract",
|
|
5
|
+
"check",
|
|
6
|
+
"status",
|
|
7
|
+
"compile",
|
|
8
|
+
"translate",
|
|
9
|
+
"migrate",
|
|
10
|
+
"sitemap",
|
|
11
|
+
"export",
|
|
12
|
+
"import",
|
|
13
|
+
"restore",
|
|
14
|
+
"which",
|
|
15
|
+
"merge-driver",
|
|
16
|
+
"lsp",
|
|
17
|
+
"mcp"
|
|
18
|
+
];
|
|
19
|
+
const CHECK_CATEGORIES = [
|
|
20
|
+
"missing",
|
|
21
|
+
"placeholders",
|
|
22
|
+
"syntax"
|
|
23
|
+
];
|
|
24
|
+
/** The libraries `migrate --from` converts (PLAN §5.19). */
|
|
25
|
+
const LIBRARIES = [
|
|
26
|
+
"i18next",
|
|
27
|
+
"react-intl",
|
|
28
|
+
"lingui",
|
|
29
|
+
"vue-i18n"
|
|
30
|
+
];
|
|
31
|
+
/** What `migrate --from` converts: saas-i18n's key catalogue and the libraries. */
|
|
32
|
+
const MIGRATIONS = ["saas-i18n", ...LIBRARIES];
|
|
33
|
+
/** Exit codes of every command. */
|
|
34
|
+
const EXIT = {
|
|
35
|
+
ok: 0,
|
|
36
|
+
/** Errors found, drift, a safety refusal, failed translations. */
|
|
37
|
+
failure: 1,
|
|
38
|
+
/** Bad flags, no config, invalid config. */
|
|
39
|
+
usage: 2
|
|
40
|
+
};
|
|
41
|
+
export { MIGRATIONS as a, LIBRARIES as i, COMMAND_NAMES as n, EXIT as r, CHECK_CATEGORIES as t };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
1
|
+
import { r as resolveDuplicates } from "./duplicates-CsUXRX2J.js";
|
|
2
|
+
import { A as usableTranslation, E as entryKey, T as entryCanonical } from "./library-BfSOBeBd.js";
|
|
3
|
+
import { p as tryCanonicalize } from "./validate-zv4-IZyZ.js";
|
|
4
|
+
// src/core/exchange/units.ts
|
|
5
5
|
/**
|
|
6
6
|
* Catalog exchange (PLAN §4.4, §5.19, INTERNALS §2.6.9): one format-neutral
|
|
7
7
|
* view of a locale's entries that every export format writes, and the
|
|
@@ -37,14 +37,6 @@ function sourceIndexOf(sourceCatalog, layout, codec) {
|
|
|
37
37
|
}
|
|
38
38
|
return index;
|
|
39
39
|
}
|
|
40
|
-
function canonicalOrNull(text, codec) {
|
|
41
|
-
try {
|
|
42
|
-
return codec.canonicalize(text);
|
|
43
|
-
} catch (error) {
|
|
44
|
-
if (isDiagnosticError(error)) return null;
|
|
45
|
-
throw error;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
40
|
/**
|
|
49
41
|
* The canonical source and label an entry's translation belongs to, or null
|
|
50
42
|
* when the catalog cannot say (an `"id"`-layout entry whose label no known
|
|
@@ -56,7 +48,7 @@ function entrySource(entry, key, context) {
|
|
|
56
48
|
if (entry.label === null) return null;
|
|
57
49
|
for (const text of [context.sourceIndex?.get(key) ?? null, entry.source]) {
|
|
58
50
|
if (text === null) continue;
|
|
59
|
-
const canonical =
|
|
51
|
+
const canonical = tryCanonicalize(codec, text);
|
|
60
52
|
if (canonical !== null && codec.label(canonical) === entry.label) return {
|
|
61
53
|
canonical,
|
|
62
54
|
label: entry.label
|
|
@@ -106,7 +98,7 @@ function exchangeUnits(input) {
|
|
|
106
98
|
manual,
|
|
107
99
|
canonical: source.canonical,
|
|
108
100
|
sourceHash: codec.sourceHash(source.canonical),
|
|
109
|
-
label:
|
|
101
|
+
label: source.label
|
|
110
102
|
}, codec, locale).ok;
|
|
111
103
|
units.push({
|
|
112
104
|
id: key,
|
|
@@ -146,5 +138,4 @@ function parseExchangeKey(raw) {
|
|
|
146
138
|
label: raw.slice(at + 1)
|
|
147
139
|
};
|
|
148
140
|
}
|
|
149
|
-
|
|
150
|
-
export { exchangeKey as a, sourceIndexOf as c, entrySource as i, EXTENSIONS as n, exchangeUnits as o, canonicalOrNull as r, parseExchangeKey as s, EXCHANGE_FORMATS as t };
|
|
141
|
+
export { exchangeUnits as a, exchangeKey as i, EXTENSIONS as n, parseExchangeKey as o, entrySource as r, sourceIndexOf as s, EXCHANGE_FORMATS as t };
|