@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
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
1
|
+
import { r as resolveDuplicates } from "./duplicates-CsUXRX2J.js";
|
|
2
|
+
import { p as tryCanonicalize } from "./validate-zv4-IZyZ.js";
|
|
3
|
+
import { E as entryKey } from "./library-BfSOBeBd.js";
|
|
4
|
+
import { r as entrySource } from "./units-VVLgQ7x7.js";
|
|
5
|
+
import { n as sourceContext } from "./exchange-DYG9RZoT.js";
|
|
6
|
+
import { m as scan, o as loadCatalogs, r as compareText, s as loadProject, t as CliExit, y as localeOrder } from "./project-DSzWKU3C.js";
|
|
7
|
+
import { i as rootRelative, r as plural } from "./output-CF9uvk_-.js";
|
|
8
|
+
import { r as EXIT } from "./types-Ds_vebja.js";
|
|
9
|
+
// src/cli/commands/which.ts
|
|
8
10
|
/**
|
|
9
11
|
* `vi18n which <id|prefix|text>` (PLAN §4.3, §5.19, INTERNALS §2.14): from
|
|
10
12
|
* an id in an `onMissing` report, a log line or a catalog, to the text and
|
|
@@ -17,11 +19,31 @@ import { a as loadCatalogs, f as scan, o as loadProject, t as CliExit } from "./
|
|
|
17
19
|
const LIMIT = 50;
|
|
18
20
|
async function which(ctx, flags) {
|
|
19
21
|
const project = await loadProject(ctx);
|
|
20
|
-
const { config, codec, layout } = project;
|
|
21
22
|
const scanned = await scan(project);
|
|
22
23
|
const loaded = await loadCatalogs(project);
|
|
24
|
+
const known = knownMessages(project, scanned.messages, loaded.set);
|
|
25
|
+
const query = flags.query;
|
|
26
|
+
const found = matching([...known.values()], query, project.codec);
|
|
27
|
+
const data = {
|
|
28
|
+
query,
|
|
29
|
+
matches: found.slice(0, LIMIT),
|
|
30
|
+
more: Math.max(0, found.length - LIMIT)
|
|
31
|
+
};
|
|
32
|
+
if (found.length === 0) {
|
|
33
|
+
ctx.out.note(`vi18n which: no message matches ${JSON.stringify(query)}`);
|
|
34
|
+
throw new CliExit(EXIT.failure, [], data);
|
|
35
|
+
}
|
|
36
|
+
printMatches(ctx, project, data);
|
|
37
|
+
return {
|
|
38
|
+
exitCode: EXIT.ok,
|
|
39
|
+
data
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
/** Every known message: the code's, then catalog entries no code declares, with each locale's entry. */
|
|
43
|
+
function knownMessages(project, messages, set) {
|
|
44
|
+
const { config, codec, layout } = project;
|
|
23
45
|
const known = /* @__PURE__ */ new Map();
|
|
24
|
-
for (const [id, message] of
|
|
46
|
+
for (const [id, message] of messages) known.set(id, {
|
|
25
47
|
id,
|
|
26
48
|
manual: message.manual,
|
|
27
49
|
source: message.canonical,
|
|
@@ -29,10 +51,9 @@ async function which(ctx, flags) {
|
|
|
29
51
|
locations: message.locations.map((location) => ({ ...location })),
|
|
30
52
|
catalogs: []
|
|
31
53
|
});
|
|
32
|
-
const
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
const file = loaded.set.get(locale);
|
|
54
|
+
const context = sourceContext(project, set);
|
|
55
|
+
for (const locale of localeOrder(project)) {
|
|
56
|
+
const file = set.get(locale);
|
|
36
57
|
if (file === void 0 || file.catalog === null) continue;
|
|
37
58
|
const shown = rootRelative(config.root, file.path);
|
|
38
59
|
const seen = /* @__PURE__ */ new Set();
|
|
@@ -42,11 +63,7 @@ async function which(ctx, flags) {
|
|
|
42
63
|
seen.add(key);
|
|
43
64
|
let match = known.get(key);
|
|
44
65
|
if (match === void 0) {
|
|
45
|
-
const source = entrySource(entry, key,
|
|
46
|
-
layout,
|
|
47
|
-
codec,
|
|
48
|
-
sourceIndex
|
|
49
|
-
});
|
|
66
|
+
const source = entrySource(entry, key, context);
|
|
50
67
|
if (source === null) continue;
|
|
51
68
|
match = {
|
|
52
69
|
id: key,
|
|
@@ -67,9 +84,11 @@ async function which(ctx, flags) {
|
|
|
67
84
|
});
|
|
68
85
|
}
|
|
69
86
|
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
87
|
+
return known;
|
|
88
|
+
}
|
|
89
|
+
/** The matches of the first tier that has any, sorted by id. */
|
|
90
|
+
function matching(all, query, codec) {
|
|
91
|
+
const canonical = tryCanonicalize(codec, query);
|
|
73
92
|
const tiers = [
|
|
74
93
|
["id", (match) => match.id === query],
|
|
75
94
|
["text", (match) => canonical !== null && match.source === canonical],
|
|
@@ -84,33 +103,21 @@ async function which(ctx, flags) {
|
|
|
84
103
|
}));
|
|
85
104
|
if (found.length > 0) break;
|
|
86
105
|
}
|
|
87
|
-
found.sort((a, b) => a.id
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
matches: found.slice(0, LIMIT),
|
|
91
|
-
more: Math.max(0, found.length - LIMIT)
|
|
92
|
-
};
|
|
93
|
-
if (found.length === 0) {
|
|
94
|
-
ctx.out.note(`vi18n which: no message matches ${JSON.stringify(query)}`);
|
|
95
|
-
throw new CliExit(EXIT.failure, [], data);
|
|
96
|
-
}
|
|
106
|
+
return found.sort((a, b) => compareText(a.id, b.id));
|
|
107
|
+
}
|
|
108
|
+
function printMatches(ctx, project, data) {
|
|
97
109
|
const lines = [];
|
|
98
110
|
for (const match of data.matches) {
|
|
99
111
|
lines.push(`${match.id} ${match.source}`);
|
|
100
112
|
for (const at of match.locations) lines.push(` ${ctx.out.display(at.file)}:${at.line}:${at.column}`);
|
|
101
|
-
if (match.locations.length === 0) lines.push(config.extraction.keep.includes(match.id) ? " (no code uses it; kept by extraction.keep)" : " (no code uses it; vi18n extract deletes it)");
|
|
113
|
+
if (match.locations.length === 0) lines.push(project.config.extraction.keep.includes(match.id) ? " (no code uses it; kept by extraction.keep)" : " (no code uses it; vi18n extract deletes it)");
|
|
102
114
|
for (const entry of match.catalogs) lines.push(` ${ctx.out.display(entry.file)}:${entry.line} ${entry.locale} ${entry.state}`);
|
|
103
115
|
}
|
|
104
116
|
if (data.more > 0) lines.push(`… and ${plural(data.more, "more match", "more matches")}`);
|
|
105
117
|
ctx.out.result(lines.join("\n"));
|
|
106
|
-
return {
|
|
107
|
-
exitCode: EXIT.ok,
|
|
108
|
-
data
|
|
109
|
-
};
|
|
110
118
|
}
|
|
111
119
|
function stateOf(entry) {
|
|
112
120
|
if (entry.fuzzy && entry.translation !== "") return "fuzzy";
|
|
113
121
|
return entry.translation === "" ? "untranslated" : entry.state;
|
|
114
122
|
}
|
|
115
|
-
//#endregion
|
|
116
123
|
export { which };
|