@inline-i18n-multi/cli 0.7.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +37 -6
- package/dist/bin.js +283 -25
- package/dist/bin.js.map +1 -1
- package/dist/index.d.ts +35 -1
- package/dist/index.js +290 -23
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -37,6 +37,26 @@ Check translation consistency across locales:
|
|
|
37
37
|
```bash
|
|
38
38
|
npx inline-i18n validate
|
|
39
39
|
npx inline-i18n validate --locales en ko ja
|
|
40
|
+
npx inline-i18n validate --unused
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### Detect Unused Keys (v0.8.0)
|
|
44
|
+
|
|
45
|
+
Find translation keys defined in dictionaries but never referenced in source code:
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
npx inline-i18n validate --unused
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Example output:
|
|
52
|
+
|
|
53
|
+
```
|
|
54
|
+
Found 2 unused translation key(s):
|
|
55
|
+
|
|
56
|
+
- old.feature.title
|
|
57
|
+
defined in src/locales.ts:5
|
|
58
|
+
- deprecated.banner
|
|
59
|
+
defined in src/locales.ts:12
|
|
40
60
|
```
|
|
41
61
|
|
|
42
62
|
### Strict Mode (v0.7.0)
|
|
@@ -54,14 +74,24 @@ Strict mode detects:
|
|
|
54
74
|
Example output:
|
|
55
75
|
|
|
56
76
|
```
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
77
|
+
ICU type mismatch between translations
|
|
78
|
+
src/Header.tsx:12
|
|
79
|
+
en: {count, plural, one {# item} other {# items}}
|
|
80
|
+
ko: {count, select, male {He} female {She}}
|
|
81
|
+
|
|
82
|
+
Found 1 issue(s)
|
|
83
|
+
```
|
|
61
84
|
|
|
62
|
-
|
|
85
|
+
### Generate Types (v0.8.0)
|
|
86
|
+
|
|
87
|
+
Generate TypeScript type definitions from your translation keys for type-safe `t()` calls:
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
npx inline-i18n typegen --output src/i18n.d.ts
|
|
63
91
|
```
|
|
64
92
|
|
|
93
|
+
This scans your dictionaries and produces a `.d.ts` file with autocomplete-ready key types.
|
|
94
|
+
|
|
65
95
|
### Generate Report
|
|
66
96
|
|
|
67
97
|
Generate a translation coverage report:
|
|
@@ -77,7 +107,8 @@ npx inline-i18n report
|
|
|
77
107
|
--output, -o Output file path
|
|
78
108
|
--locales, -l Comma-separated list of locales
|
|
79
109
|
--format, -f Output format: json, csv (default: json)
|
|
80
|
-
--strict
|
|
110
|
+
--strict Enable strict mode (ICU type consistency check)
|
|
111
|
+
--unused Detect unused translation keys (validate command)
|
|
81
112
|
```
|
|
82
113
|
|
|
83
114
|
## Documentation
|
package/dist/bin.js
CHANGED
|
@@ -148,6 +148,125 @@ function parseFile(filePath) {
|
|
|
148
148
|
});
|
|
149
149
|
return entries;
|
|
150
150
|
}
|
|
151
|
+
function flattenObjectKeys(node, prefix = "") {
|
|
152
|
+
const keys = [];
|
|
153
|
+
if (node.type !== "ObjectExpression" || !node.properties) return keys;
|
|
154
|
+
for (const prop of node.properties) {
|
|
155
|
+
if (prop.type !== "ObjectProperty") continue;
|
|
156
|
+
let propName;
|
|
157
|
+
if (prop.key.type === "Identifier") propName = prop.key.name;
|
|
158
|
+
else if (prop.key.type === "StringLiteral") propName = prop.key.value;
|
|
159
|
+
if (!propName) continue;
|
|
160
|
+
const fullKey = prefix ? `${prefix}.${propName}` : propName;
|
|
161
|
+
if (prop.value.type === "StringLiteral") {
|
|
162
|
+
keys.push(fullKey);
|
|
163
|
+
} else if (prop.value.type === "ObjectExpression") {
|
|
164
|
+
keys.push(...flattenObjectKeys(prop.value, fullKey));
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
return keys;
|
|
168
|
+
}
|
|
169
|
+
function parseDictionaryKeys(filePath) {
|
|
170
|
+
const entries = [];
|
|
171
|
+
const code = fs.readFileSync(filePath, "utf-8");
|
|
172
|
+
let ast;
|
|
173
|
+
try {
|
|
174
|
+
ast = (0, import_parser.parse)(code, {
|
|
175
|
+
sourceType: "module",
|
|
176
|
+
plugins: ["typescript", "jsx"]
|
|
177
|
+
});
|
|
178
|
+
} catch {
|
|
179
|
+
return [];
|
|
180
|
+
}
|
|
181
|
+
(0, import_traverse.default)(ast, {
|
|
182
|
+
CallExpression(nodePath) {
|
|
183
|
+
const { node } = nodePath;
|
|
184
|
+
const { callee } = node;
|
|
185
|
+
if (callee.type !== "Identifier" || callee.name !== "loadDictionaries") return;
|
|
186
|
+
const args = node.arguments;
|
|
187
|
+
const loc = node.loc;
|
|
188
|
+
if (!loc || !args[0] || args[0].type !== "ObjectExpression") return;
|
|
189
|
+
let namespace = "default";
|
|
190
|
+
if (args[1]?.type === "StringLiteral") {
|
|
191
|
+
namespace = args[1].value;
|
|
192
|
+
}
|
|
193
|
+
const dictObj = args[0];
|
|
194
|
+
const allKeys = /* @__PURE__ */ new Set();
|
|
195
|
+
for (const localeProp of dictObj.properties) {
|
|
196
|
+
if (localeProp.type !== "ObjectProperty") continue;
|
|
197
|
+
if (localeProp.value.type !== "ObjectExpression") continue;
|
|
198
|
+
const localeKeys = flattenObjectKeys(localeProp.value);
|
|
199
|
+
for (const key of localeKeys) {
|
|
200
|
+
allKeys.add(key);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
if (allKeys.size > 0) {
|
|
204
|
+
entries.push({
|
|
205
|
+
file: filePath,
|
|
206
|
+
line: loc.start.line,
|
|
207
|
+
namespace,
|
|
208
|
+
keys: [...allKeys]
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
});
|
|
213
|
+
return entries;
|
|
214
|
+
}
|
|
215
|
+
function parseTCalls(filePath) {
|
|
216
|
+
const entries = [];
|
|
217
|
+
const code = fs.readFileSync(filePath, "utf-8");
|
|
218
|
+
let ast;
|
|
219
|
+
try {
|
|
220
|
+
ast = (0, import_parser.parse)(code, {
|
|
221
|
+
sourceType: "module",
|
|
222
|
+
plugins: ["typescript", "jsx"]
|
|
223
|
+
});
|
|
224
|
+
} catch {
|
|
225
|
+
return [];
|
|
226
|
+
}
|
|
227
|
+
(0, import_traverse.default)(ast, {
|
|
228
|
+
CallExpression(nodePath) {
|
|
229
|
+
const { node } = nodePath;
|
|
230
|
+
const { callee } = node;
|
|
231
|
+
if (callee.type !== "Identifier" || callee.name !== "t") return;
|
|
232
|
+
const args = node.arguments;
|
|
233
|
+
const loc = node.loc;
|
|
234
|
+
if (!loc || !args[0] || args[0].type !== "StringLiteral") return;
|
|
235
|
+
entries.push({
|
|
236
|
+
file: filePath,
|
|
237
|
+
line: loc.start.line,
|
|
238
|
+
key: args[0].value
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
});
|
|
242
|
+
return entries;
|
|
243
|
+
}
|
|
244
|
+
async function extractProjectDictionaryKeys(options = {}) {
|
|
245
|
+
const {
|
|
246
|
+
cwd = process.cwd(),
|
|
247
|
+
include = ["**/*.{ts,tsx,js,jsx}"],
|
|
248
|
+
exclude = ["**/node_modules/**", "**/dist/**", "**/.next/**"]
|
|
249
|
+
} = options;
|
|
250
|
+
const files = await (0, import_fast_glob.default)(include, { cwd, ignore: exclude, absolute: true });
|
|
251
|
+
const allEntries = [];
|
|
252
|
+
for (const file of files) {
|
|
253
|
+
allEntries.push(...parseDictionaryKeys(file));
|
|
254
|
+
}
|
|
255
|
+
return allEntries;
|
|
256
|
+
}
|
|
257
|
+
async function extractProjectTCalls(options = {}) {
|
|
258
|
+
const {
|
|
259
|
+
cwd = process.cwd(),
|
|
260
|
+
include = ["**/*.{ts,tsx,js,jsx}"],
|
|
261
|
+
exclude = ["**/node_modules/**", "**/dist/**", "**/.next/**"]
|
|
262
|
+
} = options;
|
|
263
|
+
const files = await (0, import_fast_glob.default)(include, { cwd, ignore: exclude, absolute: true });
|
|
264
|
+
const allEntries = [];
|
|
265
|
+
for (const file of files) {
|
|
266
|
+
allEntries.push(...parseTCalls(file));
|
|
267
|
+
}
|
|
268
|
+
return allEntries;
|
|
269
|
+
}
|
|
151
270
|
async function parseProject(options = {}) {
|
|
152
271
|
const {
|
|
153
272
|
cwd = process.cwd(),
|
|
@@ -204,7 +323,66 @@ Searching for: "${query}"
|
|
|
204
323
|
}
|
|
205
324
|
|
|
206
325
|
// src/commands/validate.ts
|
|
326
|
+
var import_chalk3 = __toESM(require("chalk"));
|
|
327
|
+
|
|
328
|
+
// src/commands/unused.ts
|
|
207
329
|
var import_chalk2 = __toESM(require("chalk"));
|
|
330
|
+
var PLURAL_SUFFIXES = ["_zero", "_one", "_two", "_few", "_many", "_other"];
|
|
331
|
+
async function unused(options = {}) {
|
|
332
|
+
const { cwd } = options;
|
|
333
|
+
console.log(import_chalk2.default.blue("\nDetecting unused translations...\n"));
|
|
334
|
+
const dictEntries = await extractProjectDictionaryKeys({ cwd });
|
|
335
|
+
const tCalls = await extractProjectTCalls({ cwd });
|
|
336
|
+
const usedKeys = /* @__PURE__ */ new Set();
|
|
337
|
+
for (const call of tCalls) {
|
|
338
|
+
usedKeys.add(call.key);
|
|
339
|
+
if (!call.key.includes(":")) {
|
|
340
|
+
usedKeys.add(call.key);
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
const unusedKeys = [];
|
|
344
|
+
for (const entry of dictEntries) {
|
|
345
|
+
for (const key of entry.keys) {
|
|
346
|
+
const fullKey = entry.namespace === "default" ? key : `${entry.namespace}:${key}`;
|
|
347
|
+
if (usedKeys.has(fullKey)) continue;
|
|
348
|
+
let isPluralVariant = false;
|
|
349
|
+
for (const suffix of PLURAL_SUFFIXES) {
|
|
350
|
+
if (key.endsWith(suffix)) {
|
|
351
|
+
const baseKey = key.slice(0, -suffix.length);
|
|
352
|
+
const fullBaseKey = entry.namespace === "default" ? baseKey : `${entry.namespace}:${baseKey}`;
|
|
353
|
+
if (usedKeys.has(fullBaseKey)) {
|
|
354
|
+
isPluralVariant = true;
|
|
355
|
+
break;
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
if (isPluralVariant) continue;
|
|
360
|
+
unusedKeys.push({
|
|
361
|
+
namespace: entry.namespace,
|
|
362
|
+
key: fullKey,
|
|
363
|
+
definedIn: entry.file,
|
|
364
|
+
line: entry.line
|
|
365
|
+
});
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
if (unusedKeys.length === 0) {
|
|
369
|
+
const totalKeys = dictEntries.reduce((sum, e) => sum + e.keys.length, 0);
|
|
370
|
+
console.log(import_chalk2.default.green("No unused translations found!\n"));
|
|
371
|
+
console.log(import_chalk2.default.gray(`Checked ${totalKeys} dictionary key(s) against ${tCalls.length} t() call(s)`));
|
|
372
|
+
return { unusedKeys };
|
|
373
|
+
}
|
|
374
|
+
console.log(import_chalk2.default.yellow(`Found ${unusedKeys.length} unused translation key(s):
|
|
375
|
+
`));
|
|
376
|
+
for (const item of unusedKeys) {
|
|
377
|
+
const relativePath = item.definedIn.replace(process.cwd() + "/", "");
|
|
378
|
+
console.log(` ${import_chalk2.default.red("-")} ${import_chalk2.default.cyan(item.key)}`);
|
|
379
|
+
console.log(import_chalk2.default.gray(` defined in ${relativePath}:${item.line}`));
|
|
380
|
+
}
|
|
381
|
+
console.log();
|
|
382
|
+
return { unusedKeys };
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
// src/commands/validate.ts
|
|
208
386
|
function checkVariableConsistency(entry) {
|
|
209
387
|
const varsByLocale = [];
|
|
210
388
|
for (const [locale, text] of Object.entries(entry.translations)) {
|
|
@@ -268,8 +446,8 @@ function checkICUTypeConsistency(entry) {
|
|
|
268
446
|
};
|
|
269
447
|
}
|
|
270
448
|
async function validate(options = {}) {
|
|
271
|
-
const { cwd, locales, strict } = options;
|
|
272
|
-
console.log(
|
|
449
|
+
const { cwd, locales, strict, unused: checkUnused } = options;
|
|
450
|
+
console.log(import_chalk3.default.blue("\nValidating translations...\n"));
|
|
273
451
|
const entries = await parseProject({ cwd });
|
|
274
452
|
const issues = [];
|
|
275
453
|
const groups = /* @__PURE__ */ new Map();
|
|
@@ -314,44 +492,53 @@ async function validate(options = {}) {
|
|
|
314
492
|
if (issue) issues.push(issue);
|
|
315
493
|
}
|
|
316
494
|
}
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
495
|
+
let unusedCount = 0;
|
|
496
|
+
if (checkUnused) {
|
|
497
|
+
const result = await unused({ cwd });
|
|
498
|
+
unusedCount = result.unusedKeys.length;
|
|
499
|
+
}
|
|
500
|
+
if (issues.length === 0 && unusedCount === 0) {
|
|
501
|
+
console.log(import_chalk3.default.green("All translations are valid!\n"));
|
|
502
|
+
console.log(import_chalk3.default.gray(`Checked ${entries.length} translation(s)`));
|
|
320
503
|
if (strict) {
|
|
321
|
-
console.log(
|
|
504
|
+
console.log(import_chalk3.default.gray("(strict mode enabled)"));
|
|
505
|
+
}
|
|
506
|
+
if (checkUnused) {
|
|
507
|
+
console.log(import_chalk3.default.gray("(unused key detection enabled)"));
|
|
322
508
|
}
|
|
323
509
|
return;
|
|
324
510
|
}
|
|
325
|
-
console.log(
|
|
511
|
+
console.log(import_chalk3.default.red(`Found ${issues.length} issue(s):
|
|
326
512
|
`));
|
|
327
513
|
for (const issue of issues) {
|
|
328
|
-
|
|
329
|
-
console.log(`${icon} ${import_chalk2.default.yellow(issue.message)}`);
|
|
514
|
+
console.log(` ${import_chalk3.default.yellow(issue.message)}`);
|
|
330
515
|
for (const entry of issue.entries) {
|
|
331
516
|
const relativePath = entry.file.replace(process.cwd() + "/", "");
|
|
332
|
-
console.log(
|
|
517
|
+
console.log(import_chalk3.default.gray(` ${relativePath}:${entry.line}`));
|
|
333
518
|
for (const [locale, text] of Object.entries(entry.translations)) {
|
|
334
|
-
console.log(` ${
|
|
519
|
+
console.log(` ${import_chalk3.default.cyan(locale)}: ${text}`);
|
|
335
520
|
}
|
|
336
521
|
}
|
|
337
522
|
if (issue.details && issue.details.length > 0) {
|
|
338
523
|
for (const detail of issue.details) {
|
|
339
|
-
console.log(
|
|
524
|
+
console.log(import_chalk3.default.gray(` \u2192 ${detail}`));
|
|
340
525
|
}
|
|
341
526
|
}
|
|
342
527
|
console.log();
|
|
343
528
|
}
|
|
344
|
-
|
|
529
|
+
if (issues.length > 0 || unusedCount > 0) {
|
|
530
|
+
process.exit(1);
|
|
531
|
+
}
|
|
345
532
|
}
|
|
346
533
|
|
|
347
534
|
// src/commands/coverage.ts
|
|
348
|
-
var
|
|
535
|
+
var import_chalk4 = __toESM(require("chalk"));
|
|
349
536
|
async function coverage(options) {
|
|
350
537
|
const { cwd, locales } = options;
|
|
351
|
-
console.log(
|
|
538
|
+
console.log(import_chalk4.default.blue("\nAnalyzing translation coverage...\n"));
|
|
352
539
|
const entries = await parseProject({ cwd });
|
|
353
540
|
if (entries.length === 0) {
|
|
354
|
-
console.log(
|
|
541
|
+
console.log(import_chalk4.default.yellow("No translations found."));
|
|
355
542
|
return;
|
|
356
543
|
}
|
|
357
544
|
const coverageData = [];
|
|
@@ -370,20 +557,20 @@ async function coverage(options) {
|
|
|
370
557
|
percentage
|
|
371
558
|
});
|
|
372
559
|
}
|
|
373
|
-
console.log(
|
|
560
|
+
console.log(import_chalk4.default.bold("Translation Coverage:\n"));
|
|
374
561
|
const maxLocaleLen = Math.max(...locales.map((l) => l.length), 6);
|
|
375
562
|
console.log(
|
|
376
|
-
|
|
563
|
+
import_chalk4.default.gray(
|
|
377
564
|
`${"Locale".padEnd(maxLocaleLen)} ${"Coverage".padStart(10)} ${"Translated".padStart(12)}`
|
|
378
565
|
)
|
|
379
566
|
);
|
|
380
|
-
console.log(
|
|
567
|
+
console.log(import_chalk4.default.gray("\u2500".repeat(maxLocaleLen + 26)));
|
|
381
568
|
for (const data of coverageData) {
|
|
382
|
-
const color = data.percentage === 100 ?
|
|
569
|
+
const color = data.percentage === 100 ? import_chalk4.default.green : data.percentage >= 80 ? import_chalk4.default.yellow : import_chalk4.default.red;
|
|
383
570
|
const bar = createProgressBar(data.percentage, 10);
|
|
384
571
|
const percentStr = `${data.percentage}%`.padStart(4);
|
|
385
572
|
console.log(
|
|
386
|
-
`${data.locale.padEnd(maxLocaleLen)} ${color(bar)} ${color(percentStr)} ${
|
|
573
|
+
`${data.locale.padEnd(maxLocaleLen)} ${color(bar)} ${color(percentStr)} ${import_chalk4.default.gray(`${data.translated}/${data.total}`)}`
|
|
387
574
|
);
|
|
388
575
|
}
|
|
389
576
|
console.log();
|
|
@@ -391,9 +578,9 @@ async function coverage(options) {
|
|
|
391
578
|
const partiallyCovered = coverageData.filter((d) => d.percentage > 0 && d.percentage < 100).length;
|
|
392
579
|
const notCovered = coverageData.filter((d) => d.percentage === 0).length;
|
|
393
580
|
if (fullyCovered === locales.length) {
|
|
394
|
-
console.log(
|
|
581
|
+
console.log(import_chalk4.default.green("All locales are fully translated!"));
|
|
395
582
|
} else {
|
|
396
|
-
console.log(
|
|
583
|
+
console.log(import_chalk4.default.gray(`Full: ${fullyCovered}, Partial: ${partiallyCovered}, Empty: ${notCovered}`));
|
|
397
584
|
}
|
|
398
585
|
}
|
|
399
586
|
function createProgressBar(percentage, width) {
|
|
@@ -402,17 +589,88 @@ function createProgressBar(percentage, width) {
|
|
|
402
589
|
return "\u2588".repeat(filled) + "\u2591".repeat(empty);
|
|
403
590
|
}
|
|
404
591
|
|
|
592
|
+
// src/commands/typegen.ts
|
|
593
|
+
var fs2 = __toESM(require("fs"));
|
|
594
|
+
var path = __toESM(require("path"));
|
|
595
|
+
var import_chalk5 = __toESM(require("chalk"));
|
|
596
|
+
var PLURAL_SUFFIXES2 = ["_zero", "_one", "_two", "_few", "_many", "_other"];
|
|
597
|
+
async function typegen(options = {}) {
|
|
598
|
+
const { cwd, output = "src/i18n.d.ts" } = options;
|
|
599
|
+
console.log(import_chalk5.default.blue("\nGenerating TypeScript types...\n"));
|
|
600
|
+
const dictEntries = await extractProjectDictionaryKeys({ cwd });
|
|
601
|
+
const allKeys = /* @__PURE__ */ new Set();
|
|
602
|
+
for (const entry of dictEntries) {
|
|
603
|
+
for (const key of entry.keys) {
|
|
604
|
+
const fullKey = entry.namespace === "default" ? key : `${entry.namespace}:${key}`;
|
|
605
|
+
allKeys.add(fullKey);
|
|
606
|
+
for (const suffix of PLURAL_SUFFIXES2) {
|
|
607
|
+
if (key.endsWith(suffix)) {
|
|
608
|
+
const baseKey = key.slice(0, -suffix.length);
|
|
609
|
+
const fullBaseKey = entry.namespace === "default" ? baseKey : `${entry.namespace}:${baseKey}`;
|
|
610
|
+
allKeys.add(fullBaseKey);
|
|
611
|
+
}
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
if (allKeys.size === 0) {
|
|
616
|
+
console.log(import_chalk5.default.yellow("No dictionary keys found. Make sure loadDictionaries() calls are present."));
|
|
617
|
+
return;
|
|
618
|
+
}
|
|
619
|
+
const sortedKeys = [...allKeys].sort();
|
|
620
|
+
const keyUnion = sortedKeys.map((k) => ` | '${k}'`).join("\n");
|
|
621
|
+
const content = `// Auto-generated by inline-i18n typegen
|
|
622
|
+
// Do not edit manually. Re-run: npx inline-i18n typegen
|
|
623
|
+
|
|
624
|
+
import 'inline-i18n-multi'
|
|
625
|
+
|
|
626
|
+
declare module 'inline-i18n-multi' {
|
|
627
|
+
export type TranslationKey =
|
|
628
|
+
${keyUnion}
|
|
629
|
+
|
|
630
|
+
export function t(
|
|
631
|
+
key: TranslationKey,
|
|
632
|
+
vars?: TranslationVars,
|
|
633
|
+
locale?: string
|
|
634
|
+
): string
|
|
635
|
+
|
|
636
|
+
export function hasTranslation(
|
|
637
|
+
key: TranslationKey,
|
|
638
|
+
locale?: string
|
|
639
|
+
): boolean
|
|
640
|
+
}
|
|
641
|
+
`;
|
|
642
|
+
const outputPath = path.resolve(cwd || process.cwd(), output);
|
|
643
|
+
const outputDir = path.dirname(outputPath);
|
|
644
|
+
if (!fs2.existsSync(outputDir)) {
|
|
645
|
+
fs2.mkdirSync(outputDir, { recursive: true });
|
|
646
|
+
}
|
|
647
|
+
fs2.writeFileSync(outputPath, content, "utf-8");
|
|
648
|
+
console.log(import_chalk5.default.green(`Generated ${sortedKeys.length} translation key types`));
|
|
649
|
+
console.log(import_chalk5.default.gray(`Output: ${outputPath}
|
|
650
|
+
`));
|
|
651
|
+
const sample = sortedKeys.slice(0, 5);
|
|
652
|
+
for (const key of sample) {
|
|
653
|
+
console.log(` ${import_chalk5.default.cyan(key)}`);
|
|
654
|
+
}
|
|
655
|
+
if (sortedKeys.length > 5) {
|
|
656
|
+
console.log(import_chalk5.default.gray(` ... and ${sortedKeys.length - 5} more`));
|
|
657
|
+
}
|
|
658
|
+
}
|
|
659
|
+
|
|
405
660
|
// src/bin.ts
|
|
406
661
|
var program = new import_commander.Command();
|
|
407
|
-
program.name("inline-i18n").description("CLI tools for inline-i18n-multi").version("0.
|
|
662
|
+
program.name("inline-i18n").description("CLI tools for inline-i18n-multi").version("0.8.0");
|
|
408
663
|
program.command("find <query>").description("Find translations containing the query text").option("-c, --cwd <path>", "Working directory").action(async (query, options) => {
|
|
409
664
|
await find({ query, cwd: options.cwd });
|
|
410
665
|
});
|
|
411
|
-
program.command("validate").description("Validate translation consistency").option("-c, --cwd <path>", "Working directory").option("-l, --locales <locales...>", "Required locales to check").option("-s, --strict", "Enable strict mode (ICU type consistency check)").action(async (options) => {
|
|
666
|
+
program.command("validate").description("Validate translation consistency").option("-c, --cwd <path>", "Working directory").option("-l, --locales <locales...>", "Required locales to check").option("-s, --strict", "Enable strict mode (ICU type consistency check)").option("-u, --unused", "Detect unused dictionary keys").action(async (options) => {
|
|
412
667
|
await validate(options);
|
|
413
668
|
});
|
|
414
669
|
program.command("coverage").description("Show translation coverage by locale").option("-c, --cwd <path>", "Working directory").option("-l, --locales <locales...>", "Locales to check", ["ko", "en"]).action(async (options) => {
|
|
415
670
|
await coverage(options);
|
|
416
671
|
});
|
|
672
|
+
program.command("typegen").description("Generate TypeScript types for translation keys").option("-c, --cwd <path>", "Working directory").option("-o, --output <path>", "Output file path", "src/i18n.d.ts").action(async (options) => {
|
|
673
|
+
await typegen(options);
|
|
674
|
+
});
|
|
417
675
|
program.parse();
|
|
418
676
|
//# sourceMappingURL=bin.js.map
|
package/dist/bin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/bin.ts","../src/commands/find.ts","../src/parser.ts","../src/commands/validate.ts","../src/commands/coverage.ts"],"sourcesContent":["import { Command } from 'commander'\nimport { find } from './commands/find'\nimport { validate } from './commands/validate'\nimport { coverage } from './commands/coverage'\n\nconst program = new Command()\n\nprogram\n .name('inline-i18n')\n .description('CLI tools for inline-i18n-multi')\n .version('0.7.0')\n\nprogram\n .command('find <query>')\n .description('Find translations containing the query text')\n .option('-c, --cwd <path>', 'Working directory')\n .action(async (query: string, options: { cwd?: string }) => {\n await find({ query, cwd: options.cwd })\n })\n\nprogram\n .command('validate')\n .description('Validate translation consistency')\n .option('-c, --cwd <path>', 'Working directory')\n .option('-l, --locales <locales...>', 'Required locales to check')\n .option('-s, --strict', 'Enable strict mode (ICU type consistency check)')\n .action(async (options: { cwd?: string; locales?: string[]; strict?: boolean }) => {\n await validate(options)\n })\n\nprogram\n .command('coverage')\n .description('Show translation coverage by locale')\n .option('-c, --cwd <path>', 'Working directory')\n .option('-l, --locales <locales...>', 'Locales to check', ['ko', 'en'])\n .action(async (options: { cwd?: string; locales: string[] }) => {\n await coverage(options)\n })\n\nprogram.parse()\n","import chalk from 'chalk'\nimport { parseProject, type TranslationEntry } from '../parser'\n\ninterface FindOptions {\n query: string\n cwd?: string\n}\n\nexport async function find(options: FindOptions): Promise<void> {\n const { query, cwd } = options\n\n console.log(chalk.blue(`\\nSearching for: \"${query}\"\\n`))\n\n const entries = await parseProject({ cwd })\n const results: TranslationEntry[] = []\n\n const lowerQuery = query.toLowerCase()\n\n for (const entry of entries) {\n const values = Object.values(entry.translations)\n const matches = values.some((v) => v.toLowerCase().includes(lowerQuery))\n\n if (matches) {\n results.push(entry)\n }\n }\n\n if (results.length === 0) {\n console.log(chalk.yellow('No results found.'))\n return\n }\n\n console.log(chalk.green(`Found ${results.length} occurrence(s):\\n`))\n\n for (const result of results) {\n const relativePath = result.file.replace(process.cwd() + '/', '')\n console.log(chalk.gray(`${relativePath}:${result.line}:${result.column}`))\n\n for (const [locale, text] of Object.entries(result.translations)) {\n const highlighted = text.replace(\n new RegExp(`(${query})`, 'gi'),\n chalk.yellow('$1')\n )\n console.log(` ${chalk.cyan(locale)}: ${highlighted}`)\n }\n console.log()\n }\n}\n","import { parse } from '@babel/parser'\nimport traverse from '@babel/traverse'\nimport * as fs from 'fs'\nimport fg from 'fast-glob'\n\nexport interface ICUTypeInfo {\n variable: string\n type: string\n}\n\nexport interface TranslationEntry {\n file: string\n line: number\n column: number\n translations: Record<string, string>\n variables: string[]\n /** ICU type information per locale (v0.7.0) */\n icuTypes?: Record<string, ICUTypeInfo[]>\n}\n\ninterface ParseOptions {\n cwd?: string\n include?: string[]\n exclude?: string[]\n}\n\nconst IT_FUNCTION_NAMES = [\n 'it',\n 'it_ja', 'it_zh', 'it_es', 'it_fr', 'it_de',\n 'en_ja', 'en_zh', 'en_es', 'en_fr', 'en_de',\n 'ja_zh', 'ja_es', 'zh_es',\n]\n\nconst PAIR_MAPPING: Record<string, [string, string]> = {\n it: ['ko', 'en'],\n it_ja: ['ko', 'ja'],\n it_zh: ['ko', 'zh'],\n it_es: ['ko', 'es'],\n it_fr: ['ko', 'fr'],\n it_de: ['ko', 'de'],\n en_ja: ['en', 'ja'],\n en_zh: ['en', 'zh'],\n en_es: ['en', 'es'],\n en_fr: ['en', 'fr'],\n en_de: ['en', 'de'],\n ja_zh: ['ja', 'zh'],\n ja_es: ['ja', 'es'],\n zh_es: ['zh', 'es'],\n}\n\nfunction extractVariables(text: string): string[] {\n const matches = text.match(/\\{(\\w+)\\}/g)\n if (!matches) return []\n return matches.map((m) => m.slice(1, -1))\n}\n\nconst ICU_TYPE_PATTERN = /\\{(\\w+),\\s*(\\w+)/g\n\nfunction extractICUTypes(text: string): ICUTypeInfo[] {\n const types: ICUTypeInfo[] = []\n let match: RegExpExecArray | null\n ICU_TYPE_PATTERN.lastIndex = 0\n while ((match = ICU_TYPE_PATTERN.exec(text)) !== null) {\n types.push({ variable: match[1]!, type: match[2]! })\n }\n return types\n}\n\nfunction parseFile(filePath: string): TranslationEntry[] {\n const entries: TranslationEntry[] = []\n const code = fs.readFileSync(filePath, 'utf-8')\n\n let ast\n try {\n ast = parse(code, {\n sourceType: 'module',\n plugins: ['typescript', 'jsx'],\n })\n } catch {\n return []\n }\n\n traverse(ast, {\n CallExpression(nodePath) {\n const { node } = nodePath\n const { callee } = node\n\n if (callee.type !== 'Identifier') return\n if (!IT_FUNCTION_NAMES.includes(callee.name)) return\n\n const funcName = callee.name\n const args = node.arguments\n const loc = node.loc\n\n if (!loc) return\n\n const entry: TranslationEntry = {\n file: filePath,\n line: loc.start.line,\n column: loc.start.column,\n translations: {},\n variables: [],\n }\n\n if (args[0]?.type === 'ObjectExpression') {\n const obj = args[0]\n for (const prop of obj.properties) {\n if (\n prop.type === 'ObjectProperty' &&\n prop.key.type === 'Identifier' &&\n prop.value.type === 'StringLiteral'\n ) {\n entry.translations[prop.key.name] = prop.value.value\n entry.variables.push(...extractVariables(prop.value.value))\n // Extract ICU type info (v0.7.0)\n const types = extractICUTypes(prop.value.value)\n if (types.length > 0) {\n if (!entry.icuTypes) entry.icuTypes = {}\n entry.icuTypes[prop.key.name] = types\n }\n }\n }\n } else if (\n args[0]?.type === 'StringLiteral' &&\n args[1]?.type === 'StringLiteral'\n ) {\n const [lang1, lang2] = PAIR_MAPPING[funcName] || ['ko', 'en']\n entry.translations[lang1] = args[0].value\n entry.translations[lang2] = args[1].value\n entry.variables.push(...extractVariables(args[0].value))\n entry.variables.push(...extractVariables(args[1].value))\n // Extract ICU type info (v0.7.0)\n const types1 = extractICUTypes(args[0].value)\n if (types1.length > 0) {\n if (!entry.icuTypes) entry.icuTypes = {}\n entry.icuTypes[lang1] = types1\n }\n const types2 = extractICUTypes(args[1].value)\n if (types2.length > 0) {\n if (!entry.icuTypes) entry.icuTypes = {}\n entry.icuTypes[lang2] = types2\n }\n }\n\n entry.variables = [...new Set(entry.variables)]\n\n if (Object.keys(entry.translations).length > 0) {\n entries.push(entry)\n }\n },\n })\n\n return entries\n}\n\nexport async function parseProject(options: ParseOptions = {}): Promise<TranslationEntry[]> {\n const {\n cwd = process.cwd(),\n include = ['**/*.{ts,tsx,js,jsx}'],\n exclude = ['**/node_modules/**', '**/dist/**', '**/.next/**'],\n } = options\n\n const files = await fg(include, {\n cwd,\n ignore: exclude,\n absolute: true,\n })\n\n const allEntries: TranslationEntry[] = []\n\n for (const file of files) {\n const entries = parseFile(file)\n allEntries.push(...entries)\n }\n\n return allEntries\n}\n","import chalk from 'chalk'\nimport { parseProject, type TranslationEntry } from '../parser'\n\ninterface ValidateOptions {\n cwd?: string\n locales?: string[]\n strict?: boolean\n}\n\ninterface Issue {\n type: 'inconsistent' | 'missing' | 'variable_mismatch' | 'icu_type_mismatch'\n message: string\n entries: TranslationEntry[]\n details?: string[]\n}\n\nfunction checkVariableConsistency(entry: TranslationEntry): Issue | null {\n const varsByLocale: { locale: string; vars: string[] }[] = []\n\n for (const [locale, text] of Object.entries(entry.translations)) {\n const matches = text.match(/\\{(\\w+)\\}/g) || []\n const varNames = [...new Set(matches.map((v) => v.slice(1, -1)))].sort()\n varsByLocale.push({ locale, vars: varNames })\n }\n\n if (varsByLocale.length < 2) return null\n\n const reference = varsByLocale[0]!\n const details: string[] = []\n\n for (let i = 1; i < varsByLocale.length; i++) {\n const current = varsByLocale[i]!\n const refSet = new Set(reference.vars)\n const curSet = new Set(current.vars)\n\n const onlyInRef = reference.vars.filter((v) => !curSet.has(v))\n const onlyInCur = current.vars.filter((v) => !refSet.has(v))\n\n if (onlyInRef.length > 0) {\n details.push(\n `${reference.locale} has {${onlyInRef.join('}, {')}} missing in ${current.locale}`,\n )\n }\n if (onlyInCur.length > 0) {\n details.push(\n `${current.locale} has {${onlyInCur.join('}, {')}} missing in ${reference.locale}`,\n )\n }\n }\n\n if (details.length === 0) return null\n\n return {\n type: 'variable_mismatch',\n message: 'Variable mismatch between translations',\n entries: [entry],\n details,\n }\n}\n\nfunction checkICUTypeConsistency(entry: TranslationEntry): Issue | null {\n if (!entry.icuTypes) return null\n\n const locales = Object.keys(entry.icuTypes)\n if (locales.length < 2) return null\n\n const details: string[] = []\n const reference = locales[0]!\n const refTypes = entry.icuTypes[reference]!\n\n for (let i = 1; i < locales.length; i++) {\n const locale = locales[i]!\n const curTypes = entry.icuTypes[locale]!\n\n for (const refType of refTypes) {\n const match = curTypes.find((t: { variable: string; type: string }) => t.variable === refType.variable)\n if (match && match.type !== refType.type) {\n details.push(\n `{${refType.variable}} is \"${refType.type}\" in ${reference} but \"${match.type}\" in ${locale}`,\n )\n }\n }\n }\n\n if (details.length === 0) return null\n\n return {\n type: 'icu_type_mismatch',\n message: 'ICU type mismatch between translations',\n entries: [entry],\n details,\n }\n}\n\nexport async function validate(options: ValidateOptions = {}): Promise<void> {\n const { cwd, locales, strict } = options\n\n console.log(chalk.blue('\\nValidating translations...\\n'))\n\n const entries = await parseProject({ cwd })\n const issues: Issue[] = []\n\n // group by first language text (usually ko)\n const groups = new Map<string, TranslationEntry[]>()\n\n for (const entry of entries) {\n const key = Object.values(entry.translations)[0] || ''\n if (!groups.has(key)) {\n groups.set(key, [])\n }\n groups.get(key)!.push(entry)\n }\n\n // check for inconsistent translations\n for (const [key, group] of groups) {\n if (group.length < 2) continue\n\n const translationSets = group.map((e) => JSON.stringify(e.translations))\n const uniqueSets = [...new Set(translationSets)]\n\n if (uniqueSets.length > 1) {\n issues.push({\n type: 'inconsistent',\n message: `Inconsistent translations for \"${key}\"`,\n entries: group,\n })\n }\n }\n\n // check for missing locales\n if (locales && locales.length > 0) {\n for (const entry of entries) {\n const missing = locales.filter((l) => !entry.translations[l])\n\n if (missing.length > 0) {\n issues.push({\n type: 'missing',\n message: `Missing locales: ${missing.join(', ')}`,\n entries: [entry],\n })\n }\n }\n }\n\n // check for variable name consistency (enhanced in v0.7.0)\n for (const entry of entries) {\n const issue = checkVariableConsistency(entry)\n if (issue) issues.push(issue)\n }\n\n // check for ICU type consistency (strict mode, v0.7.0)\n if (strict) {\n for (const entry of entries) {\n const issue = checkICUTypeConsistency(entry)\n if (issue) issues.push(issue)\n }\n }\n\n // print results\n if (issues.length === 0) {\n console.log(chalk.green('✅ All translations are valid!\\n'))\n console.log(chalk.gray(`Checked ${entries.length} translation(s)`))\n if (strict) {\n console.log(chalk.gray('(strict mode enabled)'))\n }\n return\n }\n\n console.log(chalk.red(`❌ Found ${issues.length} issue(s):\\n`))\n\n for (const issue of issues) {\n const icon =\n issue.type === 'inconsistent'\n ? '⚠️'\n : issue.type === 'missing'\n ? '📭'\n : issue.type === 'icu_type_mismatch'\n ? '🔧'\n : '🔀'\n\n console.log(`${icon} ${chalk.yellow(issue.message)}`)\n\n for (const entry of issue.entries) {\n const relativePath = entry.file.replace(process.cwd() + '/', '')\n console.log(chalk.gray(` ${relativePath}:${entry.line}`))\n\n for (const [locale, text] of Object.entries(entry.translations)) {\n console.log(` ${chalk.cyan(locale)}: ${text}`)\n }\n }\n\n if (issue.details && issue.details.length > 0) {\n for (const detail of issue.details) {\n console.log(chalk.gray(` → ${detail}`))\n }\n }\n\n console.log()\n }\n\n process.exit(1)\n}\n","import chalk from 'chalk'\nimport { parseProject } from '../parser'\n\ninterface CoverageOptions {\n cwd?: string\n locales: string[]\n}\n\ninterface LocaleCoverage {\n locale: string\n total: number\n translated: number\n percentage: number\n}\n\nexport async function coverage(options: CoverageOptions): Promise<void> {\n const { cwd, locales } = options\n\n console.log(chalk.blue('\\nAnalyzing translation coverage...\\n'))\n\n const entries = await parseProject({ cwd })\n\n if (entries.length === 0) {\n console.log(chalk.yellow('No translations found.'))\n return\n }\n\n const coverageData: LocaleCoverage[] = []\n\n for (const locale of locales) {\n let translated = 0\n\n for (const entry of entries) {\n if (entry.translations[locale]) {\n translated++\n }\n }\n\n const percentage = Math.round((translated / entries.length) * 100)\n\n coverageData.push({\n locale,\n total: entries.length,\n translated,\n percentage,\n })\n }\n\n // print coverage table\n console.log(chalk.bold('Translation Coverage:\\n'))\n\n const maxLocaleLen = Math.max(...locales.map((l) => l.length), 6)\n\n console.log(\n chalk.gray(\n `${'Locale'.padEnd(maxLocaleLen)} ${'Coverage'.padStart(10)} ${'Translated'.padStart(12)}`\n )\n )\n console.log(chalk.gray('─'.repeat(maxLocaleLen + 26)))\n\n for (const data of coverageData) {\n const color =\n data.percentage === 100 ? chalk.green :\n data.percentage >= 80 ? chalk.yellow : chalk.red\n\n const bar = createProgressBar(data.percentage, 10)\n const percentStr = `${data.percentage}%`.padStart(4)\n\n console.log(\n `${data.locale.padEnd(maxLocaleLen)} ${color(bar)} ${color(percentStr)} ${chalk.gray(`${data.translated}/${data.total}`)}`\n )\n }\n\n console.log()\n\n // summary\n const fullyCovered = coverageData.filter((d) => d.percentage === 100).length\n const partiallyCovered = coverageData.filter((d) => d.percentage > 0 && d.percentage < 100).length\n const notCovered = coverageData.filter((d) => d.percentage === 0).length\n\n if (fullyCovered === locales.length) {\n console.log(chalk.green('✅ All locales are fully translated!'))\n } else {\n console.log(chalk.gray(`Full: ${fullyCovered}, Partial: ${partiallyCovered}, Empty: ${notCovered}`))\n }\n}\n\nfunction createProgressBar(percentage: number, width: number): string {\n const filled = Math.round((percentage / 100) * width)\n const empty = width - filled\n\n return '█'.repeat(filled) + '░'.repeat(empty)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uBAAwB;;;ACAxB,mBAAkB;;;ACAlB,oBAAsB;AACtB,sBAAqB;AACrB,SAAoB;AACpB,uBAAe;AAuBf,IAAM,oBAAoB;AAAA,EACxB;AAAA,EACA;AAAA,EAAS;AAAA,EAAS;AAAA,EAAS;AAAA,EAAS;AAAA,EACpC;AAAA,EAAS;AAAA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AAI,cAAAA,QAAM,MAAM,0CAAqC,CAAC;AAAA,EAChE,OAAO;AACL,YAAQ,IAAI,cAAAA,QAAM,KAAK,SAAS,YAAY,cAAc,gBAAgB,YAAY,UAAU,EAAE,CAAC;AAAA,EACrG;AACF;AAEA,SAAS,kBAAkB,YAAoB,OAAuB;AACpE,QAAM,SAAS,KAAK,MAAO,aAAa,MAAO,KAAK;AACpD,QAAM,QAAQ,QAAQ;AAEtB,SAAO,SAAI,OAAO,MAAM,IAAI,SAAI,OAAO,KAAK;AAC9C;;;AJvFA,IAAM,UAAU,IAAI,yBAAQ;AAE5B,QACG,KAAK,aAAa,EAClB,YAAY,iCAAiC,EAC7C,QAAQ,OAAO;AAElB,QACG,QAAQ,cAAc,EACtB,YAAY,6CAA6C,EACzD,OAAO,oBAAoB,mBAAmB,EAC9C,OAAO,OAAO,OAAe,YAA8B;AAC1D,QAAM,KAAK,EAAE,OAAO,KAAK,QAAQ,IAAI,CAAC;AACxC,CAAC;AAEH,QACG,QAAQ,UAAU,EAClB,YAAY,kCAAkC,EAC9C,OAAO,oBAAoB,mBAAmB,EAC9C,OAAO,8BAA8B,2BAA2B,EAChE,OAAO,gBAAgB,iDAAiD,EACxE,OAAO,OAAO,YAAoE;AACjF,QAAM,SAAS,OAAO;AACxB,CAAC;AAEH,QACG,QAAQ,UAAU,EAClB,YAAY,qCAAqC,EACjD,OAAO,oBAAoB,mBAAmB,EAC9C,OAAO,8BAA8B,oBAAoB,CAAC,MAAM,IAAI,CAAC,EACrE,OAAO,OAAO,YAAiD;AAC9D,QAAM,SAAS,OAAO;AACxB,CAAC;AAEH,QAAQ,MAAM;","names":["traverse","fg","chalk","import_chalk","chalk","import_chalk","chalk"]}
|
|
1
|
+
{"version":3,"sources":["../src/bin.ts","../src/commands/find.ts","../src/parser.ts","../src/commands/validate.ts","../src/commands/unused.ts","../src/commands/coverage.ts","../src/commands/typegen.ts"],"sourcesContent":["import { Command } from 'commander'\nimport { find } from './commands/find'\nimport { validate } from './commands/validate'\nimport { coverage } from './commands/coverage'\nimport { typegen } from './commands/typegen'\n\nconst program = new Command()\n\nprogram\n .name('inline-i18n')\n .description('CLI tools for inline-i18n-multi')\n .version('0.8.0')\n\nprogram\n .command('find <query>')\n .description('Find translations containing the query text')\n .option('-c, --cwd <path>', 'Working directory')\n .action(async (query: string, options: { cwd?: string }) => {\n await find({ query, cwd: options.cwd })\n })\n\nprogram\n .command('validate')\n .description('Validate translation consistency')\n .option('-c, --cwd <path>', 'Working directory')\n .option('-l, --locales <locales...>', 'Required locales to check')\n .option('-s, --strict', 'Enable strict mode (ICU type consistency check)')\n .option('-u, --unused', 'Detect unused dictionary keys')\n .action(async (options: { cwd?: string; locales?: string[]; strict?: boolean; unused?: boolean }) => {\n await validate(options)\n })\n\nprogram\n .command('coverage')\n .description('Show translation coverage by locale')\n .option('-c, --cwd <path>', 'Working directory')\n .option('-l, --locales <locales...>', 'Locales to check', ['ko', 'en'])\n .action(async (options: { cwd?: string; locales: string[] }) => {\n await coverage(options)\n })\n\nprogram\n .command('typegen')\n .description('Generate TypeScript types for translation keys')\n .option('-c, --cwd <path>', 'Working directory')\n .option('-o, --output <path>', 'Output file path', 'src/i18n.d.ts')\n .action(async (options: { cwd?: string; output?: string }) => {\n await typegen(options)\n })\n\nprogram.parse()\n","import chalk from 'chalk'\nimport { parseProject, type TranslationEntry } from '../parser'\n\ninterface FindOptions {\n query: string\n cwd?: string\n}\n\nexport async function find(options: FindOptions): Promise<void> {\n const { query, cwd } = options\n\n console.log(chalk.blue(`\\nSearching for: \"${query}\"\\n`))\n\n const entries = await parseProject({ cwd })\n const results: TranslationEntry[] = []\n\n const lowerQuery = query.toLowerCase()\n\n for (const entry of entries) {\n const values = Object.values(entry.translations)\n const matches = values.some((v) => v.toLowerCase().includes(lowerQuery))\n\n if (matches) {\n results.push(entry)\n }\n }\n\n if (results.length === 0) {\n console.log(chalk.yellow('No results found.'))\n return\n }\n\n console.log(chalk.green(`Found ${results.length} occurrence(s):\\n`))\n\n for (const result of results) {\n const relativePath = result.file.replace(process.cwd() + '/', '')\n console.log(chalk.gray(`${relativePath}:${result.line}:${result.column}`))\n\n for (const [locale, text] of Object.entries(result.translations)) {\n const highlighted = text.replace(\n new RegExp(`(${query})`, 'gi'),\n chalk.yellow('$1')\n )\n console.log(` ${chalk.cyan(locale)}: ${highlighted}`)\n }\n console.log()\n }\n}\n","import { parse } from '@babel/parser'\nimport traverse from '@babel/traverse'\nimport * as fs from 'fs'\nimport fg from 'fast-glob'\n\n// v0.8.0: Dictionary key and t() call extraction\n\nexport interface DictionaryKeyEntry {\n file: string\n line: number\n namespace: string\n keys: string[]\n}\n\nexport interface TCallEntry {\n file: string\n line: number\n key: string\n}\n\nexport interface ICUTypeInfo {\n variable: string\n type: string\n}\n\nexport interface TranslationEntry {\n file: string\n line: number\n column: number\n translations: Record<string, string>\n variables: string[]\n /** ICU type information per locale (v0.7.0) */\n icuTypes?: Record<string, ICUTypeInfo[]>\n}\n\ninterface ParseOptions {\n cwd?: string\n include?: string[]\n exclude?: string[]\n}\n\nconst IT_FUNCTION_NAMES = [\n 'it',\n 'it_ja', 'it_zh', 'it_es', 'it_fr', 'it_de',\n 'en_ja', 'en_zh', 'en_es', 'en_fr', 'en_de',\n 'ja_zh', 'ja_es', 'zh_es',\n]\n\nconst PAIR_MAPPING: Record<string, [string, string]> = {\n it: ['ko', 'en'],\n it_ja: ['ko', 'ja'],\n it_zh: ['ko', 'zh'],\n it_es: ['ko', 'es'],\n it_fr: ['ko', 'fr'],\n it_de: ['ko', 'de'],\n en_ja: ['en', 'ja'],\n en_zh: ['en', 'zh'],\n en_es: ['en', 'es'],\n en_fr: ['en', 'fr'],\n en_de: ['en', 'de'],\n ja_zh: ['ja', 'zh'],\n ja_es: ['ja', 'es'],\n zh_es: ['zh', 'es'],\n}\n\nfunction extractVariables(text: string): string[] {\n const matches = text.match(/\\{(\\w+)\\}/g)\n if (!matches) return []\n return matches.map((m) => m.slice(1, -1))\n}\n\nconst ICU_TYPE_PATTERN = /\\{(\\w+),\\s*(\\w+)/g\n\nfunction extractICUTypes(text: string): ICUTypeInfo[] {\n const types: ICUTypeInfo[] = []\n let match: RegExpExecArray | null\n ICU_TYPE_PATTERN.lastIndex = 0\n while ((match = ICU_TYPE_PATTERN.exec(text)) !== null) {\n types.push({ variable: match[1]!, type: match[2]! })\n }\n return types\n}\n\nfunction parseFile(filePath: string): TranslationEntry[] {\n const entries: TranslationEntry[] = []\n const code = fs.readFileSync(filePath, 'utf-8')\n\n let ast\n try {\n ast = parse(code, {\n sourceType: 'module',\n plugins: ['typescript', 'jsx'],\n })\n } catch {\n return []\n }\n\n traverse(ast, {\n CallExpression(nodePath) {\n const { node } = nodePath\n const { callee } = node\n\n if (callee.type !== 'Identifier') return\n if (!IT_FUNCTION_NAMES.includes(callee.name)) return\n\n const funcName = callee.name\n const args = node.arguments\n const loc = node.loc\n\n if (!loc) return\n\n const entry: TranslationEntry = {\n file: filePath,\n line: loc.start.line,\n column: loc.start.column,\n translations: {},\n variables: [],\n }\n\n if (args[0]?.type === 'ObjectExpression') {\n const obj = args[0]\n for (const prop of obj.properties) {\n if (\n prop.type === 'ObjectProperty' &&\n prop.key.type === 'Identifier' &&\n prop.value.type === 'StringLiteral'\n ) {\n entry.translations[prop.key.name] = prop.value.value\n entry.variables.push(...extractVariables(prop.value.value))\n // Extract ICU type info (v0.7.0)\n const types = extractICUTypes(prop.value.value)\n if (types.length > 0) {\n if (!entry.icuTypes) entry.icuTypes = {}\n entry.icuTypes[prop.key.name] = types\n }\n }\n }\n } else if (\n args[0]?.type === 'StringLiteral' &&\n args[1]?.type === 'StringLiteral'\n ) {\n const [lang1, lang2] = PAIR_MAPPING[funcName] || ['ko', 'en']\n entry.translations[lang1] = args[0].value\n entry.translations[lang2] = args[1].value\n entry.variables.push(...extractVariables(args[0].value))\n entry.variables.push(...extractVariables(args[1].value))\n // Extract ICU type info (v0.7.0)\n const types1 = extractICUTypes(args[0].value)\n if (types1.length > 0) {\n if (!entry.icuTypes) entry.icuTypes = {}\n entry.icuTypes[lang1] = types1\n }\n const types2 = extractICUTypes(args[1].value)\n if (types2.length > 0) {\n if (!entry.icuTypes) entry.icuTypes = {}\n entry.icuTypes[lang2] = types2\n }\n }\n\n entry.variables = [...new Set(entry.variables)]\n\n if (Object.keys(entry.translations).length > 0) {\n entries.push(entry)\n }\n },\n })\n\n return entries\n}\n\n// v0.8.0: Flatten nested ObjectExpression to dot-notation keys\nfunction flattenObjectKeys(\n node: { type: string; properties?: unknown[] },\n prefix: string = '',\n): string[] {\n const keys: string[] = []\n if (node.type !== 'ObjectExpression' || !node.properties) return keys\n\n for (const prop of node.properties as Array<{\n type: string\n key: { type: string; name?: string; value?: string }\n value: { type: string; properties?: unknown[] }\n }>) {\n if (prop.type !== 'ObjectProperty') continue\n\n let propName: string | undefined\n if (prop.key.type === 'Identifier') propName = prop.key.name\n else if (prop.key.type === 'StringLiteral') propName = prop.key.value\n\n if (!propName) continue\n\n const fullKey = prefix ? `${prefix}.${propName}` : propName\n\n if (prop.value.type === 'StringLiteral') {\n keys.push(fullKey)\n } else if (prop.value.type === 'ObjectExpression') {\n keys.push(...flattenObjectKeys(prop.value, fullKey))\n }\n }\n return keys\n}\n\n// v0.8.0: Extract dictionary keys from loadDictionaries() calls\nexport function parseDictionaryKeys(filePath: string): DictionaryKeyEntry[] {\n const entries: DictionaryKeyEntry[] = []\n const code = fs.readFileSync(filePath, 'utf-8')\n\n let ast\n try {\n ast = parse(code, {\n sourceType: 'module',\n plugins: ['typescript', 'jsx'],\n })\n } catch {\n return []\n }\n\n traverse(ast, {\n CallExpression(nodePath) {\n const { node } = nodePath\n const { callee } = node\n\n if (callee.type !== 'Identifier' || callee.name !== 'loadDictionaries') return\n\n const args = node.arguments\n const loc = node.loc\n if (!loc || !args[0] || args[0].type !== 'ObjectExpression') return\n\n // Second argument is optional namespace\n let namespace = 'default'\n if (args[1]?.type === 'StringLiteral') {\n namespace = args[1].value\n }\n\n // First argument: { locale: { key: value } }\n // Collect keys from the first locale's dict (all locales should have same keys)\n const dictObj = args[0]\n const allKeys = new Set<string>()\n\n for (const localeProp of dictObj.properties as Array<{\n type: string\n value: { type: string; properties?: unknown[] }\n }>) {\n if (localeProp.type !== 'ObjectProperty') continue\n if (localeProp.value.type !== 'ObjectExpression') continue\n\n const localeKeys = flattenObjectKeys(localeProp.value)\n for (const key of localeKeys) {\n allKeys.add(key)\n }\n }\n\n if (allKeys.size > 0) {\n entries.push({\n file: filePath,\n line: loc.start.line,\n namespace,\n keys: [...allKeys],\n })\n }\n },\n })\n\n return entries\n}\n\n// v0.8.0: Extract t() call sites\nexport function parseTCalls(filePath: string): TCallEntry[] {\n const entries: TCallEntry[] = []\n const code = fs.readFileSync(filePath, 'utf-8')\n\n let ast\n try {\n ast = parse(code, {\n sourceType: 'module',\n plugins: ['typescript', 'jsx'],\n })\n } catch {\n return []\n }\n\n traverse(ast, {\n CallExpression(nodePath) {\n const { node } = nodePath\n const { callee } = node\n\n if (callee.type !== 'Identifier' || callee.name !== 't') return\n\n const args = node.arguments\n const loc = node.loc\n if (!loc || !args[0] || args[0].type !== 'StringLiteral') return\n\n entries.push({\n file: filePath,\n line: loc.start.line,\n key: args[0].value,\n })\n },\n })\n\n return entries\n}\n\nexport async function extractProjectDictionaryKeys(options: ParseOptions = {}): Promise<DictionaryKeyEntry[]> {\n const {\n cwd = process.cwd(),\n include = ['**/*.{ts,tsx,js,jsx}'],\n exclude = ['**/node_modules/**', '**/dist/**', '**/.next/**'],\n } = options\n\n const files = await fg(include, { cwd, ignore: exclude, absolute: true })\n const allEntries: DictionaryKeyEntry[] = []\n\n for (const file of files) {\n allEntries.push(...parseDictionaryKeys(file))\n }\n\n return allEntries\n}\n\nexport async function extractProjectTCalls(options: ParseOptions = {}): Promise<TCallEntry[]> {\n const {\n cwd = process.cwd(),\n include = ['**/*.{ts,tsx,js,jsx}'],\n exclude = ['**/node_modules/**', '**/dist/**', '**/.next/**'],\n } = options\n\n const files = await fg(include, { cwd, ignore: exclude, absolute: true })\n const allEntries: TCallEntry[] = []\n\n for (const file of files) {\n allEntries.push(...parseTCalls(file))\n }\n\n return allEntries\n}\n\nexport async function parseProject(options: ParseOptions = {}): Promise<TranslationEntry[]> {\n const {\n cwd = process.cwd(),\n include = ['**/*.{ts,tsx,js,jsx}'],\n exclude = ['**/node_modules/**', '**/dist/**', '**/.next/**'],\n } = options\n\n const files = await fg(include, {\n cwd,\n ignore: exclude,\n absolute: true,\n })\n\n const allEntries: TranslationEntry[] = []\n\n for (const file of files) {\n const entries = parseFile(file)\n allEntries.push(...entries)\n }\n\n return allEntries\n}\n","import chalk from 'chalk'\nimport { parseProject, type TranslationEntry } from '../parser'\nimport { unused } from './unused'\n\ninterface ValidateOptions {\n cwd?: string\n locales?: string[]\n strict?: boolean\n unused?: boolean\n}\n\ninterface Issue {\n type: 'inconsistent' | 'missing' | 'variable_mismatch' | 'icu_type_mismatch'\n message: string\n entries: TranslationEntry[]\n details?: string[]\n}\n\nfunction checkVariableConsistency(entry: TranslationEntry): Issue | null {\n const varsByLocale: { locale: string; vars: string[] }[] = []\n\n for (const [locale, text] of Object.entries(entry.translations)) {\n const matches = text.match(/\\{(\\w+)\\}/g) || []\n const varNames = [...new Set(matches.map((v) => v.slice(1, -1)))].sort()\n varsByLocale.push({ locale, vars: varNames })\n }\n\n if (varsByLocale.length < 2) return null\n\n const reference = varsByLocale[0]!\n const details: string[] = []\n\n for (let i = 1; i < varsByLocale.length; i++) {\n const current = varsByLocale[i]!\n const refSet = new Set(reference.vars)\n const curSet = new Set(current.vars)\n\n const onlyInRef = reference.vars.filter((v) => !curSet.has(v))\n const onlyInCur = current.vars.filter((v) => !refSet.has(v))\n\n if (onlyInRef.length > 0) {\n details.push(\n `${reference.locale} has {${onlyInRef.join('}, {')}} missing in ${current.locale}`,\n )\n }\n if (onlyInCur.length > 0) {\n details.push(\n `${current.locale} has {${onlyInCur.join('}, {')}} missing in ${reference.locale}`,\n )\n }\n }\n\n if (details.length === 0) return null\n\n return {\n type: 'variable_mismatch',\n message: 'Variable mismatch between translations',\n entries: [entry],\n details,\n }\n}\n\nfunction checkICUTypeConsistency(entry: TranslationEntry): Issue | null {\n if (!entry.icuTypes) return null\n\n const locales = Object.keys(entry.icuTypes)\n if (locales.length < 2) return null\n\n const details: string[] = []\n const reference = locales[0]!\n const refTypes = entry.icuTypes[reference]!\n\n for (let i = 1; i < locales.length; i++) {\n const locale = locales[i]!\n const curTypes = entry.icuTypes[locale]!\n\n for (const refType of refTypes) {\n const match = curTypes.find((t: { variable: string; type: string }) => t.variable === refType.variable)\n if (match && match.type !== refType.type) {\n details.push(\n `{${refType.variable}} is \"${refType.type}\" in ${reference} but \"${match.type}\" in ${locale}`,\n )\n }\n }\n }\n\n if (details.length === 0) return null\n\n return {\n type: 'icu_type_mismatch',\n message: 'ICU type mismatch between translations',\n entries: [entry],\n details,\n }\n}\n\nexport async function validate(options: ValidateOptions = {}): Promise<void> {\n const { cwd, locales, strict, unused: checkUnused } = options\n\n console.log(chalk.blue('\\nValidating translations...\\n'))\n\n const entries = await parseProject({ cwd })\n const issues: Issue[] = []\n\n // group by first language text (usually ko)\n const groups = new Map<string, TranslationEntry[]>()\n\n for (const entry of entries) {\n const key = Object.values(entry.translations)[0] || ''\n if (!groups.has(key)) {\n groups.set(key, [])\n }\n groups.get(key)!.push(entry)\n }\n\n // check for inconsistent translations\n for (const [key, group] of groups) {\n if (group.length < 2) continue\n\n const translationSets = group.map((e) => JSON.stringify(e.translations))\n const uniqueSets = [...new Set(translationSets)]\n\n if (uniqueSets.length > 1) {\n issues.push({\n type: 'inconsistent',\n message: `Inconsistent translations for \"${key}\"`,\n entries: group,\n })\n }\n }\n\n // check for missing locales\n if (locales && locales.length > 0) {\n for (const entry of entries) {\n const missing = locales.filter((l) => !entry.translations[l])\n\n if (missing.length > 0) {\n issues.push({\n type: 'missing',\n message: `Missing locales: ${missing.join(', ')}`,\n entries: [entry],\n })\n }\n }\n }\n\n // check for variable name consistency (enhanced in v0.7.0)\n for (const entry of entries) {\n const issue = checkVariableConsistency(entry)\n if (issue) issues.push(issue)\n }\n\n // check for ICU type consistency (strict mode, v0.7.0)\n if (strict) {\n for (const entry of entries) {\n const issue = checkICUTypeConsistency(entry)\n if (issue) issues.push(issue)\n }\n }\n\n // unused key detection (v0.8.0)\n let unusedCount = 0\n if (checkUnused) {\n const result = await unused({ cwd })\n unusedCount = result.unusedKeys.length\n }\n\n // print results\n if (issues.length === 0 && unusedCount === 0) {\n console.log(chalk.green('All translations are valid!\\n'))\n console.log(chalk.gray(`Checked ${entries.length} translation(s)`))\n if (strict) {\n console.log(chalk.gray('(strict mode enabled)'))\n }\n if (checkUnused) {\n console.log(chalk.gray('(unused key detection enabled)'))\n }\n return\n }\n\n console.log(chalk.red(`Found ${issues.length} issue(s):\\n`))\n\n for (const issue of issues) {\n console.log(` ${chalk.yellow(issue.message)}`)\n\n for (const entry of issue.entries) {\n const relativePath = entry.file.replace(process.cwd() + '/', '')\n console.log(chalk.gray(` ${relativePath}:${entry.line}`))\n\n for (const [locale, text] of Object.entries(entry.translations)) {\n console.log(` ${chalk.cyan(locale)}: ${text}`)\n }\n }\n\n if (issue.details && issue.details.length > 0) {\n for (const detail of issue.details) {\n console.log(chalk.gray(` → ${detail}`))\n }\n }\n\n console.log()\n }\n\n if (issues.length > 0 || unusedCount > 0) {\n process.exit(1)\n }\n}\n","import chalk from 'chalk'\nimport { extractProjectDictionaryKeys, extractProjectTCalls } from '../parser'\n\ninterface UnusedKey {\n namespace: string\n key: string\n definedIn: string\n line: number\n}\n\nconst PLURAL_SUFFIXES = ['_zero', '_one', '_two', '_few', '_many', '_other']\n\nexport async function unused(options: { cwd?: string } = {}): Promise<{ unusedKeys: UnusedKey[] }> {\n const { cwd } = options\n\n console.log(chalk.blue('\\nDetecting unused translations...\\n'))\n\n const dictEntries = await extractProjectDictionaryKeys({ cwd })\n const tCalls = await extractProjectTCalls({ cwd })\n\n // Build set of used keys (normalized: namespace:key or key for default)\n const usedKeys = new Set<string>()\n for (const call of tCalls) {\n usedKeys.add(call.key)\n // Also add with default namespace if no namespace prefix\n if (!call.key.includes(':')) {\n usedKeys.add(call.key)\n }\n }\n\n // Check each dictionary key against used keys\n const unusedKeys: UnusedKey[] = []\n\n for (const entry of dictEntries) {\n for (const key of entry.keys) {\n const fullKey = entry.namespace === 'default' ? key : `${entry.namespace}:${key}`\n\n // Check if key is directly used\n if (usedKeys.has(fullKey)) continue\n\n // Check if this is a plural suffix variant (e.g. count_one, count_other)\n // and the base key is used via t('items.count', { count: N })\n let isPluralVariant = false\n for (const suffix of PLURAL_SUFFIXES) {\n if (key.endsWith(suffix)) {\n const baseKey = key.slice(0, -suffix.length)\n const fullBaseKey = entry.namespace === 'default' ? baseKey : `${entry.namespace}:${baseKey}`\n if (usedKeys.has(fullBaseKey)) {\n isPluralVariant = true\n break\n }\n }\n }\n if (isPluralVariant) continue\n\n unusedKeys.push({\n namespace: entry.namespace,\n key: fullKey,\n definedIn: entry.file,\n line: entry.line,\n })\n }\n }\n\n // Report results\n if (unusedKeys.length === 0) {\n const totalKeys = dictEntries.reduce((sum, e) => sum + e.keys.length, 0)\n console.log(chalk.green('No unused translations found!\\n'))\n console.log(chalk.gray(`Checked ${totalKeys} dictionary key(s) against ${tCalls.length} t() call(s)`))\n return { unusedKeys }\n }\n\n console.log(chalk.yellow(`Found ${unusedKeys.length} unused translation key(s):\\n`))\n for (const item of unusedKeys) {\n const relativePath = item.definedIn.replace(process.cwd() + '/', '')\n console.log(` ${chalk.red('-')} ${chalk.cyan(item.key)}`)\n console.log(chalk.gray(` defined in ${relativePath}:${item.line}`))\n }\n\n console.log()\n return { unusedKeys }\n}\n","import chalk from 'chalk'\nimport { parseProject } from '../parser'\n\ninterface CoverageOptions {\n cwd?: string\n locales: string[]\n}\n\ninterface LocaleCoverage {\n locale: string\n total: number\n translated: number\n percentage: number\n}\n\nexport async function coverage(options: CoverageOptions): Promise<void> {\n const { cwd, locales } = options\n\n console.log(chalk.blue('\\nAnalyzing translation coverage...\\n'))\n\n const entries = await parseProject({ cwd })\n\n if (entries.length === 0) {\n console.log(chalk.yellow('No translations found.'))\n return\n }\n\n const coverageData: LocaleCoverage[] = []\n\n for (const locale of locales) {\n let translated = 0\n\n for (const entry of entries) {\n if (entry.translations[locale]) {\n translated++\n }\n }\n\n const percentage = Math.round((translated / entries.length) * 100)\n\n coverageData.push({\n locale,\n total: entries.length,\n translated,\n percentage,\n })\n }\n\n // print coverage table\n console.log(chalk.bold('Translation Coverage:\\n'))\n\n const maxLocaleLen = Math.max(...locales.map((l) => l.length), 6)\n\n console.log(\n chalk.gray(\n `${'Locale'.padEnd(maxLocaleLen)} ${'Coverage'.padStart(10)} ${'Translated'.padStart(12)}`\n )\n )\n console.log(chalk.gray('─'.repeat(maxLocaleLen + 26)))\n\n for (const data of coverageData) {\n const color =\n data.percentage === 100 ? chalk.green :\n data.percentage >= 80 ? chalk.yellow : chalk.red\n\n const bar = createProgressBar(data.percentage, 10)\n const percentStr = `${data.percentage}%`.padStart(4)\n\n console.log(\n `${data.locale.padEnd(maxLocaleLen)} ${color(bar)} ${color(percentStr)} ${chalk.gray(`${data.translated}/${data.total}`)}`\n )\n }\n\n console.log()\n\n // summary\n const fullyCovered = coverageData.filter((d) => d.percentage === 100).length\n const partiallyCovered = coverageData.filter((d) => d.percentage > 0 && d.percentage < 100).length\n const notCovered = coverageData.filter((d) => d.percentage === 0).length\n\n if (fullyCovered === locales.length) {\n console.log(chalk.green('All locales are fully translated!'))\n } else {\n console.log(chalk.gray(`Full: ${fullyCovered}, Partial: ${partiallyCovered}, Empty: ${notCovered}`))\n }\n}\n\nfunction createProgressBar(percentage: number, width: number): string {\n const filled = Math.round((percentage / 100) * width)\n const empty = width - filled\n\n return '█'.repeat(filled) + '░'.repeat(empty)\n}\n","import * as fs from 'fs'\nimport * as path from 'path'\nimport chalk from 'chalk'\nimport { extractProjectDictionaryKeys } from '../parser'\n\ninterface TypegenOptions {\n cwd?: string\n output?: string\n}\n\nconst PLURAL_SUFFIXES = ['_zero', '_one', '_two', '_few', '_many', '_other']\n\nexport async function typegen(options: TypegenOptions = {}): Promise<void> {\n const { cwd, output = 'src/i18n.d.ts' } = options\n\n console.log(chalk.blue('\\nGenerating TypeScript types...\\n'))\n\n const dictEntries = await extractProjectDictionaryKeys({ cwd })\n\n // Collect all unique full keys (namespace:key or key)\n const allKeys = new Set<string>()\n\n for (const entry of dictEntries) {\n for (const key of entry.keys) {\n const fullKey = entry.namespace === 'default' ? key : `${entry.namespace}:${key}`\n allKeys.add(fullKey)\n\n // Also add plural base keys (strip _one, _other, etc.)\n for (const suffix of PLURAL_SUFFIXES) {\n if (key.endsWith(suffix)) {\n const baseKey = key.slice(0, -suffix.length)\n const fullBaseKey = entry.namespace === 'default' ? baseKey : `${entry.namespace}:${baseKey}`\n allKeys.add(fullBaseKey)\n }\n }\n }\n }\n\n if (allKeys.size === 0) {\n console.log(chalk.yellow('No dictionary keys found. Make sure loadDictionaries() calls are present.'))\n return\n }\n\n const sortedKeys = [...allKeys].sort()\n\n // Generate the .d.ts content\n const keyUnion = sortedKeys.map(k => ` | '${k}'`).join('\\n')\n\n const content = `// Auto-generated by inline-i18n typegen\n// Do not edit manually. Re-run: npx inline-i18n typegen\n\nimport 'inline-i18n-multi'\n\ndeclare module 'inline-i18n-multi' {\n export type TranslationKey =\n${keyUnion}\n\n export function t(\n key: TranslationKey,\n vars?: TranslationVars,\n locale?: string\n ): string\n\n export function hasTranslation(\n key: TranslationKey,\n locale?: string\n ): boolean\n}\n`\n\n const outputPath = path.resolve(cwd || process.cwd(), output)\n const outputDir = path.dirname(outputPath)\n\n if (!fs.existsSync(outputDir)) {\n fs.mkdirSync(outputDir, { recursive: true })\n }\n\n fs.writeFileSync(outputPath, content, 'utf-8')\n\n console.log(chalk.green(`Generated ${sortedKeys.length} translation key types`))\n console.log(chalk.gray(`Output: ${outputPath}\\n`))\n\n // Show sample\n const sample = sortedKeys.slice(0, 5)\n for (const key of sample) {\n console.log(` ${chalk.cyan(key)}`)\n }\n if (sortedKeys.length > 5) {\n console.log(chalk.gray(` ... and ${sortedKeys.length - 5} more`))\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uBAAwB;;;ACAxB,mBAAkB;;;ACAlB,oBAAsB;AACtB,sBAAqB;AACrB,SAAoB;AACpB,uBAAe;AAsCf,IAAM,oBAAoB;AAAA,EACxB;AAAA,EACA;AAAA,EAAS;AAAA,EAAS;AAAA,EAAS;AAAA,EAAS;AAAA,EACpC;AAAA,EAAS;AAAA,EAAS;AAAA,EAAS;AAAA,EAAS;AAAA,EACpC;AAAA,EAAS;AAAA,EAAS;AACpB;AAEA,IAAM,eAAiD;AAAA,EACrD,IAAI,CAAC,MAAM,IAAI;AAAA,EACf,OAAO,CAAC,MAAM,IAAI;AAAA,EAClB,OAAO,CAAC,MAAM,IAAI;AAAA,EAClB,OAAO,CAAC,MAAM,IAAI;AAAA,EAClB,OAAO,CAAC,MAAM,IAAI;AAAA,EAClB,OAAO,CAAC,MAAM,IAAI;AAAA,EAClB,OAAO,CAAC,MAAM,IAAI;AAAA,EAClB,OAAO,CAAC,MAAM,IAAI;AAAA,EAClB,OAAO,CAAC,MAAM,IAAI;AAAA,EAClB,OAAO,CAAC,MAAM,IAAI;AAAA,EAClB,OAAO,CAAC,MAAM,IAAI;AAAA,EAClB,OAAO,CAAC,MAAM,IAAI;AAAA,EAClB,OAAO,CAAC,MAAM,IAAI;AAAA,EAClB,OAAO,CAAC,MAAM,IAAI;AACpB;AAEA,SAAS,iBAAiB,MAAwB;AAChD,QAAM,UAAU,KAAK,MAAM,YAAY;AACvC,MAAI,CAAC,QAAS,QAAO,CAAC;AACtB,SAAO,QAAQ,IAAI,CAAC,MAAM,EAAE,MAAM,GAAG,EAAE,CAAC;AAC1C;AAEA,IAAM,mBAAmB;AAEzB,SAAS,gBAAgB,MAA6B;AACpD,QAAM,QAAuB,CAAC;AAC9B,MAAI;AACJ,m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O,YAA+C;AAC5D,QAAM,QAAQ,OAAO;AACvB,CAAC;AAEH,QAAQ,MAAM;","names":["traverse","fg","chalk","import_chalk","import_chalk","chalk","chalk","import_chalk","chalk","fs","import_chalk","PLURAL_SUFFIXES","chalk"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
interface DictionaryKeyEntry {
|
|
2
|
+
file: string;
|
|
3
|
+
line: number;
|
|
4
|
+
namespace: string;
|
|
5
|
+
keys: string[];
|
|
6
|
+
}
|
|
7
|
+
interface TCallEntry {
|
|
8
|
+
file: string;
|
|
9
|
+
line: number;
|
|
10
|
+
key: string;
|
|
11
|
+
}
|
|
1
12
|
interface ICUTypeInfo {
|
|
2
13
|
variable: string;
|
|
3
14
|
type: string;
|
|
@@ -16,6 +27,10 @@ interface ParseOptions {
|
|
|
16
27
|
include?: string[];
|
|
17
28
|
exclude?: string[];
|
|
18
29
|
}
|
|
30
|
+
declare function parseDictionaryKeys(filePath: string): DictionaryKeyEntry[];
|
|
31
|
+
declare function parseTCalls(filePath: string): TCallEntry[];
|
|
32
|
+
declare function extractProjectDictionaryKeys(options?: ParseOptions): Promise<DictionaryKeyEntry[]>;
|
|
33
|
+
declare function extractProjectTCalls(options?: ParseOptions): Promise<TCallEntry[]>;
|
|
19
34
|
declare function parseProject(options?: ParseOptions): Promise<TranslationEntry[]>;
|
|
20
35
|
|
|
21
36
|
interface FindOptions {
|
|
@@ -28,6 +43,7 @@ interface ValidateOptions {
|
|
|
28
43
|
cwd?: string;
|
|
29
44
|
locales?: string[];
|
|
30
45
|
strict?: boolean;
|
|
46
|
+
unused?: boolean;
|
|
31
47
|
}
|
|
32
48
|
declare function validate(options?: ValidateOptions): Promise<void>;
|
|
33
49
|
|
|
@@ -37,4 +53,22 @@ interface CoverageOptions {
|
|
|
37
53
|
}
|
|
38
54
|
declare function coverage(options: CoverageOptions): Promise<void>;
|
|
39
55
|
|
|
40
|
-
|
|
56
|
+
interface UnusedKey {
|
|
57
|
+
namespace: string;
|
|
58
|
+
key: string;
|
|
59
|
+
definedIn: string;
|
|
60
|
+
line: number;
|
|
61
|
+
}
|
|
62
|
+
declare function unused(options?: {
|
|
63
|
+
cwd?: string;
|
|
64
|
+
}): Promise<{
|
|
65
|
+
unusedKeys: UnusedKey[];
|
|
66
|
+
}>;
|
|
67
|
+
|
|
68
|
+
interface TypegenOptions {
|
|
69
|
+
cwd?: string;
|
|
70
|
+
output?: string;
|
|
71
|
+
}
|
|
72
|
+
declare function typegen(options?: TypegenOptions): Promise<void>;
|
|
73
|
+
|
|
74
|
+
export { type DictionaryKeyEntry, type TCallEntry, type TranslationEntry, coverage, extractProjectDictionaryKeys, extractProjectTCalls, find, parseDictionaryKeys, parseProject, parseTCalls, typegen, unused, validate };
|
package/dist/index.js
CHANGED
|
@@ -31,8 +31,14 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
31
31
|
var index_exports = {};
|
|
32
32
|
__export(index_exports, {
|
|
33
33
|
coverage: () => coverage,
|
|
34
|
+
extractProjectDictionaryKeys: () => extractProjectDictionaryKeys,
|
|
35
|
+
extractProjectTCalls: () => extractProjectTCalls,
|
|
34
36
|
find: () => find,
|
|
37
|
+
parseDictionaryKeys: () => parseDictionaryKeys,
|
|
35
38
|
parseProject: () => parseProject,
|
|
39
|
+
parseTCalls: () => parseTCalls,
|
|
40
|
+
typegen: () => typegen,
|
|
41
|
+
unused: () => unused,
|
|
36
42
|
validate: () => validate
|
|
37
43
|
});
|
|
38
44
|
module.exports = __toCommonJS(index_exports);
|
|
@@ -156,6 +162,125 @@ function parseFile(filePath) {
|
|
|
156
162
|
});
|
|
157
163
|
return entries;
|
|
158
164
|
}
|
|
165
|
+
function flattenObjectKeys(node, prefix = "") {
|
|
166
|
+
const keys = [];
|
|
167
|
+
if (node.type !== "ObjectExpression" || !node.properties) return keys;
|
|
168
|
+
for (const prop of node.properties) {
|
|
169
|
+
if (prop.type !== "ObjectProperty") continue;
|
|
170
|
+
let propName;
|
|
171
|
+
if (prop.key.type === "Identifier") propName = prop.key.name;
|
|
172
|
+
else if (prop.key.type === "StringLiteral") propName = prop.key.value;
|
|
173
|
+
if (!propName) continue;
|
|
174
|
+
const fullKey = prefix ? `${prefix}.${propName}` : propName;
|
|
175
|
+
if (prop.value.type === "StringLiteral") {
|
|
176
|
+
keys.push(fullKey);
|
|
177
|
+
} else if (prop.value.type === "ObjectExpression") {
|
|
178
|
+
keys.push(...flattenObjectKeys(prop.value, fullKey));
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
return keys;
|
|
182
|
+
}
|
|
183
|
+
function parseDictionaryKeys(filePath) {
|
|
184
|
+
const entries = [];
|
|
185
|
+
const code = fs.readFileSync(filePath, "utf-8");
|
|
186
|
+
let ast;
|
|
187
|
+
try {
|
|
188
|
+
ast = (0, import_parser.parse)(code, {
|
|
189
|
+
sourceType: "module",
|
|
190
|
+
plugins: ["typescript", "jsx"]
|
|
191
|
+
});
|
|
192
|
+
} catch {
|
|
193
|
+
return [];
|
|
194
|
+
}
|
|
195
|
+
(0, import_traverse.default)(ast, {
|
|
196
|
+
CallExpression(nodePath) {
|
|
197
|
+
const { node } = nodePath;
|
|
198
|
+
const { callee } = node;
|
|
199
|
+
if (callee.type !== "Identifier" || callee.name !== "loadDictionaries") return;
|
|
200
|
+
const args = node.arguments;
|
|
201
|
+
const loc = node.loc;
|
|
202
|
+
if (!loc || !args[0] || args[0].type !== "ObjectExpression") return;
|
|
203
|
+
let namespace = "default";
|
|
204
|
+
if (args[1]?.type === "StringLiteral") {
|
|
205
|
+
namespace = args[1].value;
|
|
206
|
+
}
|
|
207
|
+
const dictObj = args[0];
|
|
208
|
+
const allKeys = /* @__PURE__ */ new Set();
|
|
209
|
+
for (const localeProp of dictObj.properties) {
|
|
210
|
+
if (localeProp.type !== "ObjectProperty") continue;
|
|
211
|
+
if (localeProp.value.type !== "ObjectExpression") continue;
|
|
212
|
+
const localeKeys = flattenObjectKeys(localeProp.value);
|
|
213
|
+
for (const key of localeKeys) {
|
|
214
|
+
allKeys.add(key);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
if (allKeys.size > 0) {
|
|
218
|
+
entries.push({
|
|
219
|
+
file: filePath,
|
|
220
|
+
line: loc.start.line,
|
|
221
|
+
namespace,
|
|
222
|
+
keys: [...allKeys]
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
});
|
|
227
|
+
return entries;
|
|
228
|
+
}
|
|
229
|
+
function parseTCalls(filePath) {
|
|
230
|
+
const entries = [];
|
|
231
|
+
const code = fs.readFileSync(filePath, "utf-8");
|
|
232
|
+
let ast;
|
|
233
|
+
try {
|
|
234
|
+
ast = (0, import_parser.parse)(code, {
|
|
235
|
+
sourceType: "module",
|
|
236
|
+
plugins: ["typescript", "jsx"]
|
|
237
|
+
});
|
|
238
|
+
} catch {
|
|
239
|
+
return [];
|
|
240
|
+
}
|
|
241
|
+
(0, import_traverse.default)(ast, {
|
|
242
|
+
CallExpression(nodePath) {
|
|
243
|
+
const { node } = nodePath;
|
|
244
|
+
const { callee } = node;
|
|
245
|
+
if (callee.type !== "Identifier" || callee.name !== "t") return;
|
|
246
|
+
const args = node.arguments;
|
|
247
|
+
const loc = node.loc;
|
|
248
|
+
if (!loc || !args[0] || args[0].type !== "StringLiteral") return;
|
|
249
|
+
entries.push({
|
|
250
|
+
file: filePath,
|
|
251
|
+
line: loc.start.line,
|
|
252
|
+
key: args[0].value
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
});
|
|
256
|
+
return entries;
|
|
257
|
+
}
|
|
258
|
+
async function extractProjectDictionaryKeys(options = {}) {
|
|
259
|
+
const {
|
|
260
|
+
cwd = process.cwd(),
|
|
261
|
+
include = ["**/*.{ts,tsx,js,jsx}"],
|
|
262
|
+
exclude = ["**/node_modules/**", "**/dist/**", "**/.next/**"]
|
|
263
|
+
} = options;
|
|
264
|
+
const files = await (0, import_fast_glob.default)(include, { cwd, ignore: exclude, absolute: true });
|
|
265
|
+
const allEntries = [];
|
|
266
|
+
for (const file of files) {
|
|
267
|
+
allEntries.push(...parseDictionaryKeys(file));
|
|
268
|
+
}
|
|
269
|
+
return allEntries;
|
|
270
|
+
}
|
|
271
|
+
async function extractProjectTCalls(options = {}) {
|
|
272
|
+
const {
|
|
273
|
+
cwd = process.cwd(),
|
|
274
|
+
include = ["**/*.{ts,tsx,js,jsx}"],
|
|
275
|
+
exclude = ["**/node_modules/**", "**/dist/**", "**/.next/**"]
|
|
276
|
+
} = options;
|
|
277
|
+
const files = await (0, import_fast_glob.default)(include, { cwd, ignore: exclude, absolute: true });
|
|
278
|
+
const allEntries = [];
|
|
279
|
+
for (const file of files) {
|
|
280
|
+
allEntries.push(...parseTCalls(file));
|
|
281
|
+
}
|
|
282
|
+
return allEntries;
|
|
283
|
+
}
|
|
159
284
|
async function parseProject(options = {}) {
|
|
160
285
|
const {
|
|
161
286
|
cwd = process.cwd(),
|
|
@@ -213,7 +338,66 @@ Searching for: "${query}"
|
|
|
213
338
|
}
|
|
214
339
|
|
|
215
340
|
// src/commands/validate.ts
|
|
341
|
+
var import_chalk3 = __toESM(require("chalk"));
|
|
342
|
+
|
|
343
|
+
// src/commands/unused.ts
|
|
216
344
|
var import_chalk2 = __toESM(require("chalk"));
|
|
345
|
+
var PLURAL_SUFFIXES = ["_zero", "_one", "_two", "_few", "_many", "_other"];
|
|
346
|
+
async function unused(options = {}) {
|
|
347
|
+
const { cwd } = options;
|
|
348
|
+
console.log(import_chalk2.default.blue("\nDetecting unused translations...\n"));
|
|
349
|
+
const dictEntries = await extractProjectDictionaryKeys({ cwd });
|
|
350
|
+
const tCalls = await extractProjectTCalls({ cwd });
|
|
351
|
+
const usedKeys = /* @__PURE__ */ new Set();
|
|
352
|
+
for (const call of tCalls) {
|
|
353
|
+
usedKeys.add(call.key);
|
|
354
|
+
if (!call.key.includes(":")) {
|
|
355
|
+
usedKeys.add(call.key);
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
const unusedKeys = [];
|
|
359
|
+
for (const entry of dictEntries) {
|
|
360
|
+
for (const key of entry.keys) {
|
|
361
|
+
const fullKey = entry.namespace === "default" ? key : `${entry.namespace}:${key}`;
|
|
362
|
+
if (usedKeys.has(fullKey)) continue;
|
|
363
|
+
let isPluralVariant = false;
|
|
364
|
+
for (const suffix of PLURAL_SUFFIXES) {
|
|
365
|
+
if (key.endsWith(suffix)) {
|
|
366
|
+
const baseKey = key.slice(0, -suffix.length);
|
|
367
|
+
const fullBaseKey = entry.namespace === "default" ? baseKey : `${entry.namespace}:${baseKey}`;
|
|
368
|
+
if (usedKeys.has(fullBaseKey)) {
|
|
369
|
+
isPluralVariant = true;
|
|
370
|
+
break;
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
if (isPluralVariant) continue;
|
|
375
|
+
unusedKeys.push({
|
|
376
|
+
namespace: entry.namespace,
|
|
377
|
+
key: fullKey,
|
|
378
|
+
definedIn: entry.file,
|
|
379
|
+
line: entry.line
|
|
380
|
+
});
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
if (unusedKeys.length === 0) {
|
|
384
|
+
const totalKeys = dictEntries.reduce((sum, e) => sum + e.keys.length, 0);
|
|
385
|
+
console.log(import_chalk2.default.green("No unused translations found!\n"));
|
|
386
|
+
console.log(import_chalk2.default.gray(`Checked ${totalKeys} dictionary key(s) against ${tCalls.length} t() call(s)`));
|
|
387
|
+
return { unusedKeys };
|
|
388
|
+
}
|
|
389
|
+
console.log(import_chalk2.default.yellow(`Found ${unusedKeys.length} unused translation key(s):
|
|
390
|
+
`));
|
|
391
|
+
for (const item of unusedKeys) {
|
|
392
|
+
const relativePath = item.definedIn.replace(process.cwd() + "/", "");
|
|
393
|
+
console.log(` ${import_chalk2.default.red("-")} ${import_chalk2.default.cyan(item.key)}`);
|
|
394
|
+
console.log(import_chalk2.default.gray(` defined in ${relativePath}:${item.line}`));
|
|
395
|
+
}
|
|
396
|
+
console.log();
|
|
397
|
+
return { unusedKeys };
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
// src/commands/validate.ts
|
|
217
401
|
function checkVariableConsistency(entry) {
|
|
218
402
|
const varsByLocale = [];
|
|
219
403
|
for (const [locale, text] of Object.entries(entry.translations)) {
|
|
@@ -277,8 +461,8 @@ function checkICUTypeConsistency(entry) {
|
|
|
277
461
|
};
|
|
278
462
|
}
|
|
279
463
|
async function validate(options = {}) {
|
|
280
|
-
const { cwd, locales, strict } = options;
|
|
281
|
-
console.log(
|
|
464
|
+
const { cwd, locales, strict, unused: checkUnused } = options;
|
|
465
|
+
console.log(import_chalk3.default.blue("\nValidating translations...\n"));
|
|
282
466
|
const entries = await parseProject({ cwd });
|
|
283
467
|
const issues = [];
|
|
284
468
|
const groups = /* @__PURE__ */ new Map();
|
|
@@ -323,44 +507,53 @@ async function validate(options = {}) {
|
|
|
323
507
|
if (issue) issues.push(issue);
|
|
324
508
|
}
|
|
325
509
|
}
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
510
|
+
let unusedCount = 0;
|
|
511
|
+
if (checkUnused) {
|
|
512
|
+
const result = await unused({ cwd });
|
|
513
|
+
unusedCount = result.unusedKeys.length;
|
|
514
|
+
}
|
|
515
|
+
if (issues.length === 0 && unusedCount === 0) {
|
|
516
|
+
console.log(import_chalk3.default.green("All translations are valid!\n"));
|
|
517
|
+
console.log(import_chalk3.default.gray(`Checked ${entries.length} translation(s)`));
|
|
329
518
|
if (strict) {
|
|
330
|
-
console.log(
|
|
519
|
+
console.log(import_chalk3.default.gray("(strict mode enabled)"));
|
|
520
|
+
}
|
|
521
|
+
if (checkUnused) {
|
|
522
|
+
console.log(import_chalk3.default.gray("(unused key detection enabled)"));
|
|
331
523
|
}
|
|
332
524
|
return;
|
|
333
525
|
}
|
|
334
|
-
console.log(
|
|
526
|
+
console.log(import_chalk3.default.red(`Found ${issues.length} issue(s):
|
|
335
527
|
`));
|
|
336
528
|
for (const issue of issues) {
|
|
337
|
-
|
|
338
|
-
console.log(`${icon} ${import_chalk2.default.yellow(issue.message)}`);
|
|
529
|
+
console.log(` ${import_chalk3.default.yellow(issue.message)}`);
|
|
339
530
|
for (const entry of issue.entries) {
|
|
340
531
|
const relativePath = entry.file.replace(process.cwd() + "/", "");
|
|
341
|
-
console.log(
|
|
532
|
+
console.log(import_chalk3.default.gray(` ${relativePath}:${entry.line}`));
|
|
342
533
|
for (const [locale, text] of Object.entries(entry.translations)) {
|
|
343
|
-
console.log(` ${
|
|
534
|
+
console.log(` ${import_chalk3.default.cyan(locale)}: ${text}`);
|
|
344
535
|
}
|
|
345
536
|
}
|
|
346
537
|
if (issue.details && issue.details.length > 0) {
|
|
347
538
|
for (const detail of issue.details) {
|
|
348
|
-
console.log(
|
|
539
|
+
console.log(import_chalk3.default.gray(` \u2192 ${detail}`));
|
|
349
540
|
}
|
|
350
541
|
}
|
|
351
542
|
console.log();
|
|
352
543
|
}
|
|
353
|
-
|
|
544
|
+
if (issues.length > 0 || unusedCount > 0) {
|
|
545
|
+
process.exit(1);
|
|
546
|
+
}
|
|
354
547
|
}
|
|
355
548
|
|
|
356
549
|
// src/commands/coverage.ts
|
|
357
|
-
var
|
|
550
|
+
var import_chalk4 = __toESM(require("chalk"));
|
|
358
551
|
async function coverage(options) {
|
|
359
552
|
const { cwd, locales } = options;
|
|
360
|
-
console.log(
|
|
553
|
+
console.log(import_chalk4.default.blue("\nAnalyzing translation coverage...\n"));
|
|
361
554
|
const entries = await parseProject({ cwd });
|
|
362
555
|
if (entries.length === 0) {
|
|
363
|
-
console.log(
|
|
556
|
+
console.log(import_chalk4.default.yellow("No translations found."));
|
|
364
557
|
return;
|
|
365
558
|
}
|
|
366
559
|
const coverageData = [];
|
|
@@ -379,20 +572,20 @@ async function coverage(options) {
|
|
|
379
572
|
percentage
|
|
380
573
|
});
|
|
381
574
|
}
|
|
382
|
-
console.log(
|
|
575
|
+
console.log(import_chalk4.default.bold("Translation Coverage:\n"));
|
|
383
576
|
const maxLocaleLen = Math.max(...locales.map((l) => l.length), 6);
|
|
384
577
|
console.log(
|
|
385
|
-
|
|
578
|
+
import_chalk4.default.gray(
|
|
386
579
|
`${"Locale".padEnd(maxLocaleLen)} ${"Coverage".padStart(10)} ${"Translated".padStart(12)}`
|
|
387
580
|
)
|
|
388
581
|
);
|
|
389
|
-
console.log(
|
|
582
|
+
console.log(import_chalk4.default.gray("\u2500".repeat(maxLocaleLen + 26)));
|
|
390
583
|
for (const data of coverageData) {
|
|
391
|
-
const color = data.percentage === 100 ?
|
|
584
|
+
const color = data.percentage === 100 ? import_chalk4.default.green : data.percentage >= 80 ? import_chalk4.default.yellow : import_chalk4.default.red;
|
|
392
585
|
const bar = createProgressBar(data.percentage, 10);
|
|
393
586
|
const percentStr = `${data.percentage}%`.padStart(4);
|
|
394
587
|
console.log(
|
|
395
|
-
`${data.locale.padEnd(maxLocaleLen)} ${color(bar)} ${color(percentStr)} ${
|
|
588
|
+
`${data.locale.padEnd(maxLocaleLen)} ${color(bar)} ${color(percentStr)} ${import_chalk4.default.gray(`${data.translated}/${data.total}`)}`
|
|
396
589
|
);
|
|
397
590
|
}
|
|
398
591
|
console.log();
|
|
@@ -400,9 +593,9 @@ async function coverage(options) {
|
|
|
400
593
|
const partiallyCovered = coverageData.filter((d) => d.percentage > 0 && d.percentage < 100).length;
|
|
401
594
|
const notCovered = coverageData.filter((d) => d.percentage === 0).length;
|
|
402
595
|
if (fullyCovered === locales.length) {
|
|
403
|
-
console.log(
|
|
596
|
+
console.log(import_chalk4.default.green("All locales are fully translated!"));
|
|
404
597
|
} else {
|
|
405
|
-
console.log(
|
|
598
|
+
console.log(import_chalk4.default.gray(`Full: ${fullyCovered}, Partial: ${partiallyCovered}, Empty: ${notCovered}`));
|
|
406
599
|
}
|
|
407
600
|
}
|
|
408
601
|
function createProgressBar(percentage, width) {
|
|
@@ -410,11 +603,85 @@ function createProgressBar(percentage, width) {
|
|
|
410
603
|
const empty = width - filled;
|
|
411
604
|
return "\u2588".repeat(filled) + "\u2591".repeat(empty);
|
|
412
605
|
}
|
|
606
|
+
|
|
607
|
+
// src/commands/typegen.ts
|
|
608
|
+
var fs2 = __toESM(require("fs"));
|
|
609
|
+
var path = __toESM(require("path"));
|
|
610
|
+
var import_chalk5 = __toESM(require("chalk"));
|
|
611
|
+
var PLURAL_SUFFIXES2 = ["_zero", "_one", "_two", "_few", "_many", "_other"];
|
|
612
|
+
async function typegen(options = {}) {
|
|
613
|
+
const { cwd, output = "src/i18n.d.ts" } = options;
|
|
614
|
+
console.log(import_chalk5.default.blue("\nGenerating TypeScript types...\n"));
|
|
615
|
+
const dictEntries = await extractProjectDictionaryKeys({ cwd });
|
|
616
|
+
const allKeys = /* @__PURE__ */ new Set();
|
|
617
|
+
for (const entry of dictEntries) {
|
|
618
|
+
for (const key of entry.keys) {
|
|
619
|
+
const fullKey = entry.namespace === "default" ? key : `${entry.namespace}:${key}`;
|
|
620
|
+
allKeys.add(fullKey);
|
|
621
|
+
for (const suffix of PLURAL_SUFFIXES2) {
|
|
622
|
+
if (key.endsWith(suffix)) {
|
|
623
|
+
const baseKey = key.slice(0, -suffix.length);
|
|
624
|
+
const fullBaseKey = entry.namespace === "default" ? baseKey : `${entry.namespace}:${baseKey}`;
|
|
625
|
+
allKeys.add(fullBaseKey);
|
|
626
|
+
}
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
}
|
|
630
|
+
if (allKeys.size === 0) {
|
|
631
|
+
console.log(import_chalk5.default.yellow("No dictionary keys found. Make sure loadDictionaries() calls are present."));
|
|
632
|
+
return;
|
|
633
|
+
}
|
|
634
|
+
const sortedKeys = [...allKeys].sort();
|
|
635
|
+
const keyUnion = sortedKeys.map((k) => ` | '${k}'`).join("\n");
|
|
636
|
+
const content = `// Auto-generated by inline-i18n typegen
|
|
637
|
+
// Do not edit manually. Re-run: npx inline-i18n typegen
|
|
638
|
+
|
|
639
|
+
import 'inline-i18n-multi'
|
|
640
|
+
|
|
641
|
+
declare module 'inline-i18n-multi' {
|
|
642
|
+
export type TranslationKey =
|
|
643
|
+
${keyUnion}
|
|
644
|
+
|
|
645
|
+
export function t(
|
|
646
|
+
key: TranslationKey,
|
|
647
|
+
vars?: TranslationVars,
|
|
648
|
+
locale?: string
|
|
649
|
+
): string
|
|
650
|
+
|
|
651
|
+
export function hasTranslation(
|
|
652
|
+
key: TranslationKey,
|
|
653
|
+
locale?: string
|
|
654
|
+
): boolean
|
|
655
|
+
}
|
|
656
|
+
`;
|
|
657
|
+
const outputPath = path.resolve(cwd || process.cwd(), output);
|
|
658
|
+
const outputDir = path.dirname(outputPath);
|
|
659
|
+
if (!fs2.existsSync(outputDir)) {
|
|
660
|
+
fs2.mkdirSync(outputDir, { recursive: true });
|
|
661
|
+
}
|
|
662
|
+
fs2.writeFileSync(outputPath, content, "utf-8");
|
|
663
|
+
console.log(import_chalk5.default.green(`Generated ${sortedKeys.length} translation key types`));
|
|
664
|
+
console.log(import_chalk5.default.gray(`Output: ${outputPath}
|
|
665
|
+
`));
|
|
666
|
+
const sample = sortedKeys.slice(0, 5);
|
|
667
|
+
for (const key of sample) {
|
|
668
|
+
console.log(` ${import_chalk5.default.cyan(key)}`);
|
|
669
|
+
}
|
|
670
|
+
if (sortedKeys.length > 5) {
|
|
671
|
+
console.log(import_chalk5.default.gray(` ... and ${sortedKeys.length - 5} more`));
|
|
672
|
+
}
|
|
673
|
+
}
|
|
413
674
|
// Annotate the CommonJS export names for ESM import in node:
|
|
414
675
|
0 && (module.exports = {
|
|
415
676
|
coverage,
|
|
677
|
+
extractProjectDictionaryKeys,
|
|
678
|
+
extractProjectTCalls,
|
|
416
679
|
find,
|
|
680
|
+
parseDictionaryKeys,
|
|
417
681
|
parseProject,
|
|
682
|
+
parseTCalls,
|
|
683
|
+
typegen,
|
|
684
|
+
unused,
|
|
418
685
|
validate
|
|
419
686
|
});
|
|
420
687
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/parser.ts","../src/commands/find.ts","../src/commands/validate.ts","../src/commands/coverage.ts"],"sourcesContent":["export { parseProject, type TranslationEntry } from './parser'\nexport { find } from './commands/find'\nexport { validate } from './commands/validate'\nexport { coverage } from './commands/coverage'\n","import { parse } from '@babel/parser'\nimport traverse from '@babel/traverse'\nimport * as fs from 'fs'\nimport fg from 'fast-glob'\n\nexport interface ICUTypeInfo {\n variable: string\n type: string\n}\n\nexport interface TranslationEntry {\n file: string\n line: number\n column: number\n translations: Record<string, string>\n variables: string[]\n /** ICU type information per locale (v0.7.0) */\n icuTypes?: Record<string, ICUTypeInfo[]>\n}\n\ninterface ParseOptions {\n cwd?: string\n include?: string[]\n exclude?: string[]\n}\n\nconst IT_FUNCTION_NAMES = [\n 'it',\n 'it_ja', 'it_zh', 'it_es', 'it_fr', 'it_de',\n 'en_ja', 'en_zh', 'en_es', 'en_fr', 'en_de',\n 'ja_zh', 'ja_es', 'zh_es',\n]\n\nconst PAIR_MAPPING: Record<string, [string, string]> = {\n it: ['ko', 'en'],\n it_ja: ['ko', 'ja'],\n it_zh: ['ko', 'zh'],\n it_es: ['ko', 'es'],\n it_fr: ['ko', 'fr'],\n it_de: ['ko', 'de'],\n en_ja: ['en', 'ja'],\n en_zh: ['en', 'zh'],\n en_es: ['en', 'es'],\n en_fr: ['en', 'fr'],\n en_de: ['en', 'de'],\n ja_zh: ['ja', 'zh'],\n ja_es: ['ja', 'es'],\n zh_es: ['zh', 'es'],\n}\n\nfunction extractVariables(text: string): string[] {\n const matches = text.match(/\\{(\\w+)\\}/g)\n if (!matches) return []\n return matches.map((m) => m.slice(1, -1))\n}\n\nconst ICU_TYPE_PATTERN = /\\{(\\w+),\\s*(\\w+)/g\n\nfunction extractICUTypes(text: string): ICUTypeInfo[] {\n const types: ICUTypeInfo[] = []\n let match: RegExpExecArray | null\n ICU_TYPE_PATTERN.lastIndex = 0\n while ((match = ICU_TYPE_PATTERN.exec(text)) !== null) {\n types.push({ variable: match[1]!, type: match[2]! })\n }\n return types\n}\n\nfunction parseFile(filePath: string): TranslationEntry[] {\n const entries: TranslationEntry[] = []\n const code = fs.readFileSync(filePath, 'utf-8')\n\n let ast\n try {\n ast = parse(code, {\n sourceType: 'module',\n plugins: ['typescript', 'jsx'],\n })\n } catch {\n return []\n }\n\n traverse(ast, {\n CallExpression(nodePath) {\n const { node } = nodePath\n const { callee } = node\n\n if (callee.type !== 'Identifier') return\n if (!IT_FUNCTION_NAMES.includes(callee.name)) return\n\n const funcName = callee.name\n const args = node.arguments\n const loc = node.loc\n\n if (!loc) return\n\n const entry: TranslationEntry = {\n file: filePath,\n line: loc.start.line,\n column: loc.start.column,\n translations: {},\n variables: [],\n }\n\n if (args[0]?.type === 'ObjectExpression') {\n const obj = args[0]\n for (const prop of obj.properties) {\n if (\n prop.type === 'ObjectProperty' &&\n prop.key.type === 'Identifier' &&\n prop.value.type === 'StringLiteral'\n ) {\n entry.translations[prop.key.name] = prop.value.value\n entry.variables.push(...extractVariables(prop.value.value))\n // Extract ICU type info (v0.7.0)\n const types = extractICUTypes(prop.value.value)\n if (types.length > 0) {\n if (!entry.icuTypes) entry.icuTypes = {}\n entry.icuTypes[prop.key.name] = types\n }\n }\n }\n } else if (\n args[0]?.type === 'StringLiteral' &&\n args[1]?.type === 'StringLiteral'\n ) {\n const [lang1, lang2] = PAIR_MAPPING[funcName] || ['ko', 'en']\n entry.translations[lang1] = args[0].value\n entry.translations[lang2] = args[1].value\n entry.variables.push(...extractVariables(args[0].value))\n entry.variables.push(...extractVariables(args[1].value))\n // Extract ICU type info (v0.7.0)\n const types1 = extractICUTypes(args[0].value)\n if (types1.length > 0) {\n if (!entry.icuTypes) entry.icuTypes = {}\n entry.icuTypes[lang1] = types1\n }\n const types2 = extractICUTypes(args[1].value)\n if (types2.length > 0) {\n if (!entry.icuTypes) entry.icuTypes = {}\n entry.icuTypes[lang2] = types2\n }\n }\n\n entry.variables = [...new Set(entry.variables)]\n\n if (Object.keys(entry.translations).length > 0) {\n entries.push(entry)\n }\n },\n })\n\n return entries\n}\n\nexport async function parseProject(options: ParseOptions = {}): Promise<TranslationEntry[]> {\n const {\n cwd = process.cwd(),\n include = ['**/*.{ts,tsx,js,jsx}'],\n exclude = ['**/node_modules/**', '**/dist/**', '**/.next/**'],\n } = options\n\n const files = await fg(include, {\n cwd,\n ignore: exclude,\n absolute: true,\n })\n\n const allEntries: TranslationEntry[] = []\n\n for (const file of files) {\n const entries = parseFile(file)\n allEntries.push(...entries)\n }\n\n return allEntries\n}\n","import chalk from 'chalk'\nimport { parseProject, type TranslationEntry } from '../parser'\n\ninterface FindOptions {\n query: string\n cwd?: string\n}\n\nexport async function find(options: FindOptions): Promise<void> {\n const { query, cwd } = options\n\n console.log(chalk.blue(`\\nSearching for: \"${query}\"\\n`))\n\n const entries = await parseProject({ cwd })\n const results: TranslationEntry[] = []\n\n const lowerQuery = query.toLowerCase()\n\n for (const entry of entries) {\n const values = Object.values(entry.translations)\n const matches = values.some((v) => v.toLowerCase().includes(lowerQuery))\n\n if (matches) {\n results.push(entry)\n }\n }\n\n if (results.length === 0) {\n console.log(chalk.yellow('No results found.'))\n return\n }\n\n console.log(chalk.green(`Found ${results.length} occurrence(s):\\n`))\n\n for (const result of results) {\n const relativePath = result.file.replace(process.cwd() + '/', '')\n console.log(chalk.gray(`${relativePath}:${result.line}:${result.column}`))\n\n for (const [locale, text] of Object.entries(result.translations)) {\n const highlighted = text.replace(\n new RegExp(`(${query})`, 'gi'),\n chalk.yellow('$1')\n )\n console.log(` ${chalk.cyan(locale)}: ${highlighted}`)\n }\n console.log()\n }\n}\n","import chalk from 'chalk'\nimport { parseProject, type TranslationEntry } from '../parser'\n\ninterface ValidateOptions {\n cwd?: string\n locales?: string[]\n strict?: boolean\n}\n\ninterface Issue {\n type: 'inconsistent' | 'missing' | 'variable_mismatch' | 'icu_type_mismatch'\n message: string\n entries: TranslationEntry[]\n details?: string[]\n}\n\nfunction checkVariableConsistency(entry: TranslationEntry): Issue | null {\n const varsByLocale: { locale: string; vars: string[] }[] = []\n\n for (const [locale, text] of Object.entries(entry.translations)) {\n const matches = text.match(/\\{(\\w+)\\}/g) || []\n const varNames = [...new Set(matches.map((v) => v.slice(1, -1)))].sort()\n varsByLocale.push({ locale, vars: varNames })\n }\n\n if (varsByLocale.length < 2) return null\n\n const reference = varsByLocale[0]!\n const details: string[] = []\n\n for (let i = 1; i < varsByLocale.length; i++) {\n const current = varsByLocale[i]!\n const refSet = new Set(reference.vars)\n const curSet = new Set(current.vars)\n\n const onlyInRef = reference.vars.filter((v) => !curSet.has(v))\n const onlyInCur = current.vars.filter((v) => !refSet.has(v))\n\n if (onlyInRef.length > 0) {\n details.push(\n `${reference.locale} has {${onlyInRef.join('}, {')}} missing in ${current.locale}`,\n )\n }\n if (onlyInCur.length > 0) {\n details.push(\n `${current.locale} has {${onlyInCur.join('}, {')}} missing in ${reference.locale}`,\n )\n }\n }\n\n if (details.length === 0) return null\n\n return {\n type: 'variable_mismatch',\n message: 'Variable mismatch between translations',\n entries: [entry],\n details,\n }\n}\n\nfunction checkICUTypeConsistency(entry: TranslationEntry): Issue | null {\n if (!entry.icuTypes) return null\n\n const locales = Object.keys(entry.icuTypes)\n if (locales.length < 2) return null\n\n const details: string[] = []\n const reference = locales[0]!\n const refTypes = entry.icuTypes[reference]!\n\n for (let i = 1; i < locales.length; i++) {\n const locale = locales[i]!\n const curTypes = entry.icuTypes[locale]!\n\n for (const refType of refTypes) {\n const match = curTypes.find((t: { variable: string; type: string }) => t.variable === refType.variable)\n if (match && match.type !== refType.type) {\n details.push(\n `{${refType.variable}} is \"${refType.type}\" in ${reference} but \"${match.type}\" in ${locale}`,\n )\n }\n }\n }\n\n if (details.length === 0) return null\n\n return {\n type: 'icu_type_mismatch',\n message: 'ICU type mismatch between translations',\n entries: [entry],\n details,\n }\n}\n\nexport async function validate(options: ValidateOptions = {}): Promise<void> {\n const { cwd, locales, strict } = options\n\n console.log(chalk.blue('\\nValidating translations...\\n'))\n\n const entries = await parseProject({ cwd })\n const issues: Issue[] = []\n\n // group by first language text (usually ko)\n const groups = new Map<string, TranslationEntry[]>()\n\n for (const entry of entries) {\n const key = Object.values(entry.translations)[0] || ''\n if (!groups.has(key)) {\n groups.set(key, [])\n }\n groups.get(key)!.push(entry)\n }\n\n // check for inconsistent translations\n for (const [key, group] of groups) {\n if (group.length < 2) continue\n\n const translationSets = group.map((e) => JSON.stringify(e.translations))\n const uniqueSets = [...new Set(translationSets)]\n\n if (uniqueSets.length > 1) {\n issues.push({\n type: 'inconsistent',\n message: `Inconsistent translations for \"${key}\"`,\n entries: group,\n })\n }\n }\n\n // check for missing locales\n if (locales && locales.length > 0) {\n for (const entry of entries) {\n const missing = locales.filter((l) => !entry.translations[l])\n\n if (missing.length > 0) {\n issues.push({\n type: 'missing',\n message: `Missing locales: ${missing.join(', ')}`,\n entries: [entry],\n })\n }\n }\n }\n\n // check for variable name consistency (enhanced in v0.7.0)\n for (const entry of entries) {\n const issue = checkVariableConsistency(entry)\n if (issue) issues.push(issue)\n }\n\n // check for ICU type consistency (strict mode, v0.7.0)\n if (strict) {\n for (const entry of entries) {\n const issue = checkICUTypeConsistency(entry)\n if (issue) issues.push(issue)\n }\n }\n\n // print results\n if (issues.length === 0) {\n console.log(chalk.green('✅ All translations are valid!\\n'))\n console.log(chalk.gray(`Checked ${entries.length} translation(s)`))\n if (strict) {\n console.log(chalk.gray('(strict mode enabled)'))\n }\n return\n }\n\n console.log(chalk.red(`❌ Found ${issues.length} issue(s):\\n`))\n\n for (const issue of issues) {\n const icon =\n issue.type === 'inconsistent'\n ? '⚠️'\n : issue.type === 'missing'\n ? '📭'\n : issue.type === 'icu_type_mismatch'\n ? '🔧'\n : '🔀'\n\n console.log(`${icon} ${chalk.yellow(issue.message)}`)\n\n for (const entry of issue.entries) {\n const relativePath = entry.file.replace(process.cwd() + '/', '')\n console.log(chalk.gray(` ${relativePath}:${entry.line}`))\n\n for (const [locale, text] of Object.entries(entry.translations)) {\n console.log(` ${chalk.cyan(locale)}: ${text}`)\n }\n }\n\n if (issue.details && issue.details.length > 0) {\n for (const detail of issue.details) {\n console.log(chalk.gray(` → ${detail}`))\n }\n }\n\n console.log()\n }\n\n process.exit(1)\n}\n","import chalk from 'chalk'\nimport { parseProject } from '../parser'\n\ninterface CoverageOptions {\n cwd?: string\n locales: string[]\n}\n\ninterface LocaleCoverage {\n locale: string\n total: number\n translated: number\n percentage: number\n}\n\nexport async function coverage(options: CoverageOptions): Promise<void> {\n const { cwd, locales } = options\n\n console.log(chalk.blue('\\nAnalyzing translation coverage...\\n'))\n\n const entries = await parseProject({ cwd })\n\n if (entries.length === 0) {\n console.log(chalk.yellow('No translations found.'))\n return\n }\n\n const coverageData: LocaleCoverage[] = []\n\n for (const locale of locales) {\n let translated = 0\n\n for (const entry of entries) {\n if (entry.translations[locale]) {\n translated++\n }\n }\n\n const percentage = Math.round((translated / entries.length) * 100)\n\n coverageData.push({\n locale,\n total: entries.length,\n translated,\n percentage,\n })\n }\n\n // print coverage table\n console.log(chalk.bold('Translation Coverage:\\n'))\n\n const maxLocaleLen = Math.max(...locales.map((l) => l.length), 6)\n\n console.log(\n chalk.gray(\n `${'Locale'.padEnd(maxLocaleLen)} ${'Coverage'.padStart(10)} ${'Translated'.padStart(12)}`\n )\n )\n console.log(chalk.gray('─'.repeat(maxLocaleLen + 26)))\n\n for (const data of coverageData) {\n const color =\n data.percentage === 100 ? chalk.green :\n data.percentage >= 80 ? chalk.yellow : chalk.red\n\n const bar = createProgressBar(data.percentage, 10)\n const percentStr = `${data.percentage}%`.padStart(4)\n\n console.log(\n `${data.locale.padEnd(maxLocaleLen)} ${color(bar)} ${color(percentStr)} ${chalk.gray(`${data.translated}/${data.total}`)}`\n )\n }\n\n console.log()\n\n // summary\n const fullyCovered = coverageData.filter((d) => d.percentage === 100).length\n const partiallyCovered = coverageData.filter((d) => d.percentage > 0 && d.percentage < 100).length\n const notCovered = coverageData.filter((d) => d.percentage === 0).length\n\n if (fullyCovered === locales.length) {\n console.log(chalk.green('✅ All locales are fully translated!'))\n } else {\n console.log(chalk.gray(`Full: ${fullyCovered}, Partial: ${partiallyCovered}, Empty: ${notCovered}`))\n }\n}\n\nfunction createProgressBar(percentage: number, width: number): string {\n const filled = Math.round((percentage / 100) * width)\n const empty = width - filled\n\n return '█'.repeat(filled) + '░'.repeat(empty)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,oBAAsB;AACtB,sBAAqB;AACrB,SAAoB;AACpB,uBAAe;AAuBf,IAAM,oBAAoB;AAAA,EACxB;AAAA,EACA;AAAA,EAAS;AAAA,EAAS;AAAA,EAAS;AAAA,EAAS;AAAA,EACpC;AAAA,EAAS;AAAA,EAAS;AAAA,EAAS;AAAA,EAAS;AAAA,EACpC;AAAA,EAAS;AAAA,EAAS;AACpB;AAEA,IAAM,eAAiD;AAAA,EACrD,IAAI,CAAC,MAAM,IAAI;AAAA,EACf,OAAO,CAAC,MAAM,IAAI;AAAA,EAClB,OAAO,CAAC,MAAM,IAAI;AAAA,EAClB,OAAO,CAAC,MAAM,IAAI;AAAA,EAClB,OAAO,CAAC,MAAM,IAAI;AAAA,EAClB,OAAO,CAAC,MAAM,IAAI;AAAA,EAClB,OAAO,CAAC,MAAM,IAAI;AAAA,EAClB,OAAO,CAAC,MAAM,IAAI;AAAA,EAClB,OAAO,CAAC,MAAM,IAAI;AAAA,EAClB,OAAO,CAAC,MAAM,IAAI;AAAA,EAClB,OAAO,CAAC,MAAM,IAAI;AAAA,EAClB,OAAO,CAAC,MAAM,IAAI;AAAA,EAClB,OAAO,CAAC,MAAM,IAAI;AAAA,EAClB,OAAO,CAAC,MAAM,IAAI;AACpB;AAEA,SAAS,iBAAiB,MAAwB;AAChD,QAAM,UAAU,KAAK,MAAM,YAAY;AACvC,MAAI,CAAC,QAAS,QAA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;AACjD,UAAM,aAAa,GAAG,KAAK,UAAU,IAAI,SAAS,CAAC;AAEnD,YAAQ;AAAA,MACN,GAAG,KAAK,OAAO,OAAO,YAAY,CAAC,KAAK,MAAM,GAAG,CAAC,IAAI,MAAM,UAAU,CAAC,KAAK,cAAAA,QAAM,KAAK,GAAG,KAAK,UAAU,IAAI,KAAK,KAAK,EAAE,CAAC;AAAA,IAC5H;AAAA,EACF;AAEA,UAAQ,IAAI;AAGZ,QAAM,eAAe,aAAa,OAAO,CAAC,MAAM,EAAE,eAAe,GAAG,EAAE;AACtE,QAAM,mBAAmB,aAAa,OAAO,CAAC,MAAM,EAAE,aAAa,KAAK,EAAE,aAAa,GAAG,EAAE;AAC5F,QAAM,aAAa,aAAa,OAAO,CAAC,MAAM,EAAE,eAAe,CAAC,EAAE;AAElE,MAAI,iBAAiB,QAAQ,QAAQ;AACnC,YAAQ,IAAI,cAAAA,QAAM,MAAM,0CAAqC,CAAC;AAAA,EAChE,OAAO;AACL,YAAQ,IAAI,cAAAA,QAAM,KAAK,SAAS,YAAY,cAAc,gBAAgB,YAAY,UAAU,EAAE,CAAC;AAAA,EACrG;AACF;AAEA,SAAS,kBAAkB,YAAoB,OAAuB;AACpE,QAAM,SAAS,KAAK,MAAO,aAAa,MAAO,KAAK;AACpD,QAAM,QAAQ,QAAQ;AAEtB,SAAO,SAAI,OAAO,MAAM,IAAI,SAAI,OAAO,KAAK;AAC9C;","names":["traverse","fg","chalk","import_chalk","chalk","import_chalk","chalk"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/parser.ts","../src/commands/find.ts","../src/commands/validate.ts","../src/commands/unused.ts","../src/commands/coverage.ts","../src/commands/typegen.ts"],"sourcesContent":["export {\n parseProject,\n parseDictionaryKeys,\n parseTCalls,\n extractProjectDictionaryKeys,\n extractProjectTCalls,\n type TranslationEntry,\n type DictionaryKeyEntry,\n type TCallEntry,\n} from './parser'\nexport { find } from './commands/find'\nexport { validate } from './commands/validate'\nexport { coverage } from './commands/coverage'\nexport { unused } from './commands/unused'\nexport { typegen } from './commands/typegen'\n","import { parse } from '@babel/parser'\nimport traverse from '@babel/traverse'\nimport * as fs from 'fs'\nimport fg from 'fast-glob'\n\n// v0.8.0: Dictionary key and t() call extraction\n\nexport interface DictionaryKeyEntry {\n file: string\n line: number\n namespace: string\n keys: string[]\n}\n\nexport interface TCallEntry {\n file: string\n line: number\n key: string\n}\n\nexport interface ICUTypeInfo {\n variable: string\n type: string\n}\n\nexport interface TranslationEntry {\n file: string\n line: number\n column: number\n translations: Record<string, string>\n variables: string[]\n /** ICU type information per locale (v0.7.0) */\n icuTypes?: Record<string, ICUTypeInfo[]>\n}\n\ninterface ParseOptions {\n cwd?: string\n include?: string[]\n exclude?: string[]\n}\n\nconst IT_FUNCTION_NAMES = [\n 'it',\n 'it_ja', 'it_zh', 'it_es', 'it_fr', 'it_de',\n 'en_ja', 'en_zh', 'en_es', 'en_fr', 'en_de',\n 'ja_zh', 'ja_es', 'zh_es',\n]\n\nconst PAIR_MAPPING: Record<string, [string, string]> = {\n it: ['ko', 'en'],\n it_ja: ['ko', 'ja'],\n it_zh: ['ko', 'zh'],\n it_es: ['ko', 'es'],\n it_fr: ['ko', 'fr'],\n it_de: ['ko', 'de'],\n en_ja: ['en', 'ja'],\n en_zh: ['en', 'zh'],\n en_es: ['en', 'es'],\n en_fr: ['en', 'fr'],\n en_de: ['en', 'de'],\n ja_zh: ['ja', 'zh'],\n ja_es: ['ja', 'es'],\n zh_es: ['zh', 'es'],\n}\n\nfunction extractVariables(text: string): string[] {\n const matches = text.match(/\\{(\\w+)\\}/g)\n if (!matches) return []\n return matches.map((m) => m.slice(1, -1))\n}\n\nconst ICU_TYPE_PATTERN = /\\{(\\w+),\\s*(\\w+)/g\n\nfunction extractICUTypes(text: string): ICUTypeInfo[] {\n const types: ICUTypeInfo[] = []\n let match: RegExpExecArray | null\n ICU_TYPE_PATTERN.lastIndex = 0\n while ((match = ICU_TYPE_PATTERN.exec(text)) !== null) {\n types.push({ variable: match[1]!, type: match[2]! })\n }\n return types\n}\n\nfunction parseFile(filePath: string): TranslationEntry[] {\n const entries: TranslationEntry[] = []\n const code = fs.readFileSync(filePath, 'utf-8')\n\n let ast\n try {\n ast = parse(code, {\n sourceType: 'module',\n plugins: ['typescript', 'jsx'],\n })\n } catch {\n return []\n }\n\n traverse(ast, {\n CallExpression(nodePath) {\n const { node } = nodePath\n const { callee } = node\n\n if (callee.type !== 'Identifier') return\n if (!IT_FUNCTION_NAMES.includes(callee.name)) return\n\n const funcName = callee.name\n const args = node.arguments\n const loc = node.loc\n\n if (!loc) return\n\n const entry: TranslationEntry = {\n file: filePath,\n line: loc.start.line,\n column: loc.start.column,\n translations: {},\n variables: [],\n }\n\n if (args[0]?.type === 'ObjectExpression') {\n const obj = args[0]\n for (const prop of obj.properties) {\n if (\n prop.type === 'ObjectProperty' &&\n prop.key.type === 'Identifier' &&\n prop.value.type === 'StringLiteral'\n ) {\n entry.translations[prop.key.name] = prop.value.value\n entry.variables.push(...extractVariables(prop.value.value))\n // Extract ICU type info (v0.7.0)\n const types = extractICUTypes(prop.value.value)\n if (types.length > 0) {\n if (!entry.icuTypes) entry.icuTypes = {}\n entry.icuTypes[prop.key.name] = types\n }\n }\n }\n } else if (\n args[0]?.type === 'StringLiteral' &&\n args[1]?.type === 'StringLiteral'\n ) {\n const [lang1, lang2] = PAIR_MAPPING[funcName] || ['ko', 'en']\n entry.translations[lang1] = args[0].value\n entry.translations[lang2] = args[1].value\n entry.variables.push(...extractVariables(args[0].value))\n entry.variables.push(...extractVariables(args[1].value))\n // Extract ICU type info (v0.7.0)\n const types1 = extractICUTypes(args[0].value)\n if (types1.length > 0) {\n if (!entry.icuTypes) entry.icuTypes = {}\n entry.icuTypes[lang1] = types1\n }\n const types2 = extractICUTypes(args[1].value)\n if (types2.length > 0) {\n if (!entry.icuTypes) entry.icuTypes = {}\n entry.icuTypes[lang2] = types2\n }\n }\n\n entry.variables = [...new Set(entry.variables)]\n\n if (Object.keys(entry.translations).length > 0) {\n entries.push(entry)\n }\n },\n })\n\n return entries\n}\n\n// v0.8.0: Flatten nested ObjectExpression to dot-notation keys\nfunction flattenObjectKeys(\n node: { type: string; properties?: unknown[] },\n prefix: string = '',\n): string[] {\n const keys: string[] = []\n if (node.type !== 'ObjectExpression' || !node.properties) return keys\n\n for (const prop of node.properties as Array<{\n type: string\n key: { type: string; name?: string; value?: string }\n value: { type: string; properties?: unknown[] }\n }>) {\n if (prop.type !== 'ObjectProperty') continue\n\n let propName: string | undefined\n if (prop.key.type === 'Identifier') propName = prop.key.name\n else if (prop.key.type === 'StringLiteral') propName = prop.key.value\n\n if (!propName) continue\n\n const fullKey = prefix ? `${prefix}.${propName}` : propName\n\n if (prop.value.type === 'StringLiteral') {\n keys.push(fullKey)\n } else if (prop.value.type === 'ObjectExpression') {\n keys.push(...flattenObjectKeys(prop.value, fullKey))\n }\n }\n return keys\n}\n\n// v0.8.0: Extract dictionary keys from loadDictionaries() calls\nexport function parseDictionaryKeys(filePath: string): DictionaryKeyEntry[] {\n const entries: DictionaryKeyEntry[] = []\n const code = fs.readFileSync(filePath, 'utf-8')\n\n let ast\n try {\n ast = parse(code, {\n sourceType: 'module',\n plugins: ['typescript', 'jsx'],\n })\n } catch {\n return []\n }\n\n traverse(ast, {\n CallExpression(nodePath) {\n const { node } = nodePath\n const { callee } = node\n\n if (callee.type !== 'Identifier' || callee.name !== 'loadDictionaries') return\n\n const args = node.arguments\n const loc = node.loc\n if (!loc || !args[0] || args[0].type !== 'ObjectExpression') return\n\n // Second argument is optional namespace\n let namespace = 'default'\n if (args[1]?.type === 'StringLiteral') {\n namespace = args[1].value\n }\n\n // First argument: { locale: { key: value } }\n // Collect keys from the first locale's dict (all locales should have same keys)\n const dictObj = args[0]\n const allKeys = new Set<string>()\n\n for (const localeProp of dictObj.properties as Array<{\n type: string\n value: { type: string; properties?: unknown[] }\n }>) {\n if (localeProp.type !== 'ObjectProperty') continue\n if (localeProp.value.type !== 'ObjectExpression') continue\n\n const localeKeys = flattenObjectKeys(localeProp.value)\n for (const key of localeKeys) {\n allKeys.add(key)\n }\n }\n\n if (allKeys.size > 0) {\n entries.push({\n file: filePath,\n line: loc.start.line,\n namespace,\n keys: [...allKeys],\n })\n }\n },\n })\n\n return entries\n}\n\n// v0.8.0: Extract t() call sites\nexport function parseTCalls(filePath: string): TCallEntry[] {\n const entries: TCallEntry[] = []\n const code = fs.readFileSync(filePath, 'utf-8')\n\n let ast\n try {\n ast = parse(code, {\n sourceType: 'module',\n plugins: ['typescript', 'jsx'],\n })\n } catch {\n return []\n }\n\n traverse(ast, {\n CallExpression(nodePath) {\n const { node } = nodePath\n const { callee } = node\n\n if (callee.type !== 'Identifier' || callee.name !== 't') return\n\n const args = node.arguments\n const loc = node.loc\n if (!loc || !args[0] || args[0].type !== 'StringLiteral') return\n\n entries.push({\n file: filePath,\n line: loc.start.line,\n key: args[0].value,\n })\n },\n })\n\n return entries\n}\n\nexport async function extractProjectDictionaryKeys(options: ParseOptions = {}): Promise<DictionaryKeyEntry[]> {\n const {\n cwd = process.cwd(),\n include = ['**/*.{ts,tsx,js,jsx}'],\n exclude = ['**/node_modules/**', '**/dist/**', '**/.next/**'],\n } = options\n\n const files = await fg(include, { cwd, ignore: exclude, absolute: true })\n const allEntries: DictionaryKeyEntry[] = []\n\n for (const file of files) {\n allEntries.push(...parseDictionaryKeys(file))\n }\n\n return allEntries\n}\n\nexport async function extractProjectTCalls(options: ParseOptions = {}): Promise<TCallEntry[]> {\n const {\n cwd = process.cwd(),\n include = ['**/*.{ts,tsx,js,jsx}'],\n exclude = ['**/node_modules/**', '**/dist/**', '**/.next/**'],\n } = options\n\n const files = await fg(include, { cwd, ignore: exclude, absolute: true })\n const allEntries: TCallEntry[] = []\n\n for (const file of files) {\n allEntries.push(...parseTCalls(file))\n }\n\n return allEntries\n}\n\nexport async function parseProject(options: ParseOptions = {}): Promise<TranslationEntry[]> {\n const {\n cwd = process.cwd(),\n include = ['**/*.{ts,tsx,js,jsx}'],\n exclude = ['**/node_modules/**', '**/dist/**', '**/.next/**'],\n } = options\n\n const files = await fg(include, {\n cwd,\n ignore: exclude,\n absolute: true,\n })\n\n const allEntries: TranslationEntry[] = []\n\n for (const file of files) {\n const entries = parseFile(file)\n allEntries.push(...entries)\n }\n\n return allEntries\n}\n","import chalk from 'chalk'\nimport { parseProject, type TranslationEntry } from '../parser'\n\ninterface FindOptions {\n query: string\n cwd?: string\n}\n\nexport async function find(options: FindOptions): Promise<void> {\n const { query, cwd } = options\n\n console.log(chalk.blue(`\\nSearching for: \"${query}\"\\n`))\n\n const entries = await parseProject({ cwd })\n const results: TranslationEntry[] = []\n\n const lowerQuery = query.toLowerCase()\n\n for (const entry of entries) {\n const values = Object.values(entry.translations)\n const matches = values.some((v) => v.toLowerCase().includes(lowerQuery))\n\n if (matches) {\n results.push(entry)\n }\n }\n\n if (results.length === 0) {\n console.log(chalk.yellow('No results found.'))\n return\n }\n\n console.log(chalk.green(`Found ${results.length} occurrence(s):\\n`))\n\n for (const result of results) {\n const relativePath = result.file.replace(process.cwd() + '/', '')\n console.log(chalk.gray(`${relativePath}:${result.line}:${result.column}`))\n\n for (const [locale, text] of Object.entries(result.translations)) {\n const highlighted = text.replace(\n new RegExp(`(${query})`, 'gi'),\n chalk.yellow('$1')\n )\n console.log(` ${chalk.cyan(locale)}: ${highlighted}`)\n }\n console.log()\n }\n}\n","import chalk from 'chalk'\nimport { parseProject, type TranslationEntry } from '../parser'\nimport { unused } from './unused'\n\ninterface ValidateOptions {\n cwd?: string\n locales?: string[]\n strict?: boolean\n unused?: boolean\n}\n\ninterface Issue {\n type: 'inconsistent' | 'missing' | 'variable_mismatch' | 'icu_type_mismatch'\n message: string\n entries: TranslationEntry[]\n details?: string[]\n}\n\nfunction checkVariableConsistency(entry: TranslationEntry): Issue | null {\n const varsByLocale: { locale: string; vars: string[] }[] = []\n\n for (const [locale, text] of Object.entries(entry.translations)) {\n const matches = text.match(/\\{(\\w+)\\}/g) || []\n const varNames = [...new Set(matches.map((v) => v.slice(1, -1)))].sort()\n varsByLocale.push({ locale, vars: varNames })\n }\n\n if (varsByLocale.length < 2) return null\n\n const reference = varsByLocale[0]!\n const details: string[] = []\n\n for (let i = 1; i < varsByLocale.length; i++) {\n const current = varsByLocale[i]!\n const refSet = new Set(reference.vars)\n const curSet = new Set(current.vars)\n\n const onlyInRef = reference.vars.filter((v) => !curSet.has(v))\n const onlyInCur = current.vars.filter((v) => !refSet.has(v))\n\n if (onlyInRef.length > 0) {\n details.push(\n `${reference.locale} has {${onlyInRef.join('}, {')}} missing in ${current.locale}`,\n )\n }\n if (onlyInCur.length > 0) {\n details.push(\n `${current.locale} has {${onlyInCur.join('}, {')}} missing in ${reference.locale}`,\n )\n }\n }\n\n if (details.length === 0) return null\n\n return {\n type: 'variable_mismatch',\n message: 'Variable mismatch between translations',\n entries: [entry],\n details,\n }\n}\n\nfunction checkICUTypeConsistency(entry: TranslationEntry): Issue | null {\n if (!entry.icuTypes) return null\n\n const locales = Object.keys(entry.icuTypes)\n if (locales.length < 2) return null\n\n const details: string[] = []\n const reference = locales[0]!\n const refTypes = entry.icuTypes[reference]!\n\n for (let i = 1; i < locales.length; i++) {\n const locale = locales[i]!\n const curTypes = entry.icuTypes[locale]!\n\n for (const refType of refTypes) {\n const match = curTypes.find((t: { variable: string; type: string }) => t.variable === refType.variable)\n if (match && match.type !== refType.type) {\n details.push(\n `{${refType.variable}} is \"${refType.type}\" in ${reference} but \"${match.type}\" in ${locale}`,\n )\n }\n }\n }\n\n if (details.length === 0) return null\n\n return {\n type: 'icu_type_mismatch',\n message: 'ICU type mismatch between translations',\n entries: [entry],\n details,\n }\n}\n\nexport async function validate(options: ValidateOptions = {}): Promise<void> {\n const { cwd, locales, strict, unused: checkUnused } = options\n\n console.log(chalk.blue('\\nValidating translations...\\n'))\n\n const entries = await parseProject({ cwd })\n const issues: Issue[] = []\n\n // group by first language text (usually ko)\n const groups = new Map<string, TranslationEntry[]>()\n\n for (const entry of entries) {\n const key = Object.values(entry.translations)[0] || ''\n if (!groups.has(key)) {\n groups.set(key, [])\n }\n groups.get(key)!.push(entry)\n }\n\n // check for inconsistent translations\n for (const [key, group] of groups) {\n if (group.length < 2) continue\n\n const translationSets = group.map((e) => JSON.stringify(e.translations))\n const uniqueSets = [...new Set(translationSets)]\n\n if (uniqueSets.length > 1) {\n issues.push({\n type: 'inconsistent',\n message: `Inconsistent translations for \"${key}\"`,\n entries: group,\n })\n }\n }\n\n // check for missing locales\n if (locales && locales.length > 0) {\n for (const entry of entries) {\n const missing = locales.filter((l) => !entry.translations[l])\n\n if (missing.length > 0) {\n issues.push({\n type: 'missing',\n message: `Missing locales: ${missing.join(', ')}`,\n entries: [entry],\n })\n }\n }\n }\n\n // check for variable name consistency (enhanced in v0.7.0)\n for (const entry of entries) {\n const issue = checkVariableConsistency(entry)\n if (issue) issues.push(issue)\n }\n\n // check for ICU type consistency (strict mode, v0.7.0)\n if (strict) {\n for (const entry of entries) {\n const issue = checkICUTypeConsistency(entry)\n if (issue) issues.push(issue)\n }\n }\n\n // unused key detection (v0.8.0)\n let unusedCount = 0\n if (checkUnused) {\n const result = await unused({ cwd })\n unusedCount = result.unusedKeys.length\n }\n\n // print results\n if (issues.length === 0 && unusedCount === 0) {\n console.log(chalk.green('All translations are valid!\\n'))\n console.log(chalk.gray(`Checked ${entries.length} translation(s)`))\n if (strict) {\n console.log(chalk.gray('(strict mode enabled)'))\n }\n if (checkUnused) {\n console.log(chalk.gray('(unused key detection enabled)'))\n }\n return\n }\n\n console.log(chalk.red(`Found ${issues.length} issue(s):\\n`))\n\n for (const issue of issues) {\n console.log(` ${chalk.yellow(issue.message)}`)\n\n for (const entry of issue.entries) {\n const relativePath = entry.file.replace(process.cwd() + '/', '')\n console.log(chalk.gray(` ${relativePath}:${entry.line}`))\n\n for (const [locale, text] of Object.entries(entry.translations)) {\n console.log(` ${chalk.cyan(locale)}: ${text}`)\n }\n }\n\n if (issue.details && issue.details.length > 0) {\n for (const detail of issue.details) {\n console.log(chalk.gray(` → ${detail}`))\n }\n }\n\n console.log()\n }\n\n if (issues.length > 0 || unusedCount > 0) {\n process.exit(1)\n }\n}\n","import chalk from 'chalk'\nimport { extractProjectDictionaryKeys, extractProjectTCalls } from '../parser'\n\ninterface UnusedKey {\n namespace: string\n key: string\n definedIn: string\n line: number\n}\n\nconst PLURAL_SUFFIXES = ['_zero', '_one', '_two', '_few', '_many', '_other']\n\nexport async function unused(options: { cwd?: string } = {}): Promise<{ unusedKeys: UnusedKey[] }> {\n const { cwd } = options\n\n console.log(chalk.blue('\\nDetecting unused translations...\\n'))\n\n const dictEntries = await extractProjectDictionaryKeys({ cwd })\n const tCalls = await extractProjectTCalls({ cwd })\n\n // Build set of used keys (normalized: namespace:key or key for default)\n const usedKeys = new Set<string>()\n for (const call of tCalls) {\n usedKeys.add(call.key)\n // Also add with default namespace if no namespace prefix\n if (!call.key.includes(':')) {\n usedKeys.add(call.key)\n }\n }\n\n // Check each dictionary key against used keys\n const unusedKeys: UnusedKey[] = []\n\n for (const entry of dictEntries) {\n for (const key of entry.keys) {\n const fullKey = entry.namespace === 'default' ? key : `${entry.namespace}:${key}`\n\n // Check if key is directly used\n if (usedKeys.has(fullKey)) continue\n\n // Check if this is a plural suffix variant (e.g. count_one, count_other)\n // and the base key is used via t('items.count', { count: N })\n let isPluralVariant = false\n for (const suffix of PLURAL_SUFFIXES) {\n if (key.endsWith(suffix)) {\n const baseKey = key.slice(0, -suffix.length)\n const fullBaseKey = entry.namespace === 'default' ? baseKey : `${entry.namespace}:${baseKey}`\n if (usedKeys.has(fullBaseKey)) {\n isPluralVariant = true\n break\n }\n }\n }\n if (isPluralVariant) continue\n\n unusedKeys.push({\n namespace: entry.namespace,\n key: fullKey,\n definedIn: entry.file,\n line: entry.line,\n })\n }\n }\n\n // Report results\n if (unusedKeys.length === 0) {\n const totalKeys = dictEntries.reduce((sum, e) => sum + e.keys.length, 0)\n console.log(chalk.green('No unused translations found!\\n'))\n console.log(chalk.gray(`Checked ${totalKeys} dictionary key(s) against ${tCalls.length} t() call(s)`))\n return { unusedKeys }\n }\n\n console.log(chalk.yellow(`Found ${unusedKeys.length} unused translation key(s):\\n`))\n for (const item of unusedKeys) {\n const relativePath = item.definedIn.replace(process.cwd() + '/', '')\n console.log(` ${chalk.red('-')} ${chalk.cyan(item.key)}`)\n console.log(chalk.gray(` defined in ${relativePath}:${item.line}`))\n }\n\n console.log()\n return { unusedKeys }\n}\n","import chalk from 'chalk'\nimport { parseProject } from '../parser'\n\ninterface CoverageOptions {\n cwd?: string\n locales: string[]\n}\n\ninterface LocaleCoverage {\n locale: string\n total: number\n translated: number\n percentage: number\n}\n\nexport async function coverage(options: CoverageOptions): Promise<void> {\n const { cwd, locales } = options\n\n console.log(chalk.blue('\\nAnalyzing translation coverage...\\n'))\n\n const entries = await parseProject({ cwd })\n\n if (entries.length === 0) {\n console.log(chalk.yellow('No translations found.'))\n return\n }\n\n const coverageData: LocaleCoverage[] = []\n\n for (const locale of locales) {\n let translated = 0\n\n for (const entry of entries) {\n if (entry.translations[locale]) {\n translated++\n }\n }\n\n const percentage = Math.round((translated / entries.length) * 100)\n\n coverageData.push({\n locale,\n total: entries.length,\n translated,\n percentage,\n })\n }\n\n // print coverage table\n console.log(chalk.bold('Translation Coverage:\\n'))\n\n const maxLocaleLen = Math.max(...locales.map((l) => l.length), 6)\n\n console.log(\n chalk.gray(\n `${'Locale'.padEnd(maxLocaleLen)} ${'Coverage'.padStart(10)} ${'Translated'.padStart(12)}`\n )\n )\n console.log(chalk.gray('─'.repeat(maxLocaleLen + 26)))\n\n for (const data of coverageData) {\n const color =\n data.percentage === 100 ? chalk.green :\n data.percentage >= 80 ? chalk.yellow : chalk.red\n\n const bar = createProgressBar(data.percentage, 10)\n const percentStr = `${data.percentage}%`.padStart(4)\n\n console.log(\n `${data.locale.padEnd(maxLocaleLen)} ${color(bar)} ${color(percentStr)} ${chalk.gray(`${data.translated}/${data.total}`)}`\n )\n }\n\n console.log()\n\n // summary\n const fullyCovered = coverageData.filter((d) => d.percentage === 100).length\n const partiallyCovered = coverageData.filter((d) => d.percentage > 0 && d.percentage < 100).length\n const notCovered = coverageData.filter((d) => d.percentage === 0).length\n\n if (fullyCovered === locales.length) {\n console.log(chalk.green('All locales are fully translated!'))\n } else {\n console.log(chalk.gray(`Full: ${fullyCovered}, Partial: ${partiallyCovered}, Empty: ${notCovered}`))\n }\n}\n\nfunction createProgressBar(percentage: number, width: number): string {\n const filled = Math.round((percentage / 100) * width)\n const empty = width - filled\n\n return '█'.repeat(filled) + '░'.repeat(empty)\n}\n","import * as fs from 'fs'\nimport * as path from 'path'\nimport chalk from 'chalk'\nimport { extractProjectDictionaryKeys } from '../parser'\n\ninterface TypegenOptions {\n cwd?: string\n output?: string\n}\n\nconst PLURAL_SUFFIXES = ['_zero', '_one', '_two', '_few', '_many', '_other']\n\nexport async function typegen(options: TypegenOptions = {}): Promise<void> {\n const { cwd, output = 'src/i18n.d.ts' } = options\n\n console.log(chalk.blue('\\nGenerating TypeScript types...\\n'))\n\n const dictEntries = await extractProjectDictionaryKeys({ cwd })\n\n // Collect all unique full keys (namespace:key or key)\n const allKeys = new Set<string>()\n\n for (const entry of dictEntries) {\n for (const key of entry.keys) {\n const fullKey = entry.namespace === 'default' ? key : `${entry.namespace}:${key}`\n allKeys.add(fullKey)\n\n // Also add plural base keys (strip _one, _other, etc.)\n for (const suffix of PLURAL_SUFFIXES) {\n if (key.endsWith(suffix)) {\n const baseKey = key.slice(0, -suffix.length)\n const fullBaseKey = entry.namespace === 'default' ? baseKey : `${entry.namespace}:${baseKey}`\n allKeys.add(fullBaseKey)\n }\n }\n }\n }\n\n if (allKeys.size === 0) {\n console.log(chalk.yellow('No dictionary keys found. Make sure loadDictionaries() calls are present.'))\n return\n }\n\n const sortedKeys = [...allKeys].sort()\n\n // Generate the .d.ts content\n const keyUnion = sortedKeys.map(k => ` | '${k}'`).join('\\n')\n\n const content = `// Auto-generated by inline-i18n typegen\n// Do not edit manually. Re-run: npx inline-i18n typegen\n\nimport 'inline-i18n-multi'\n\ndeclare module 'inline-i18n-multi' {\n export type TranslationKey =\n${keyUnion}\n\n export function t(\n key: TranslationKey,\n vars?: TranslationVars,\n locale?: string\n ): string\n\n export function hasTranslation(\n key: TranslationKey,\n locale?: string\n ): boolean\n}\n`\n\n const outputPath = path.resolve(cwd || process.cwd(), output)\n const outputDir = path.dirname(outputPath)\n\n if (!fs.existsSync(outputDir)) {\n fs.mkdirSync(outputDir, { recursive: true })\n }\n\n fs.writeFileSync(outputPath, content, 'utf-8')\n\n console.log(chalk.green(`Generated ${sortedKeys.length} translation key types`))\n console.log(chalk.gray(`Output: ${outputPath}\\n`))\n\n // Show sample\n const sample = sortedKeys.slice(0, 5)\n for (const key of sample) {\n console.log(` ${chalk.cyan(key)}`)\n }\n if (sortedKeys.length > 5) {\n console.log(chalk.gray(` ... and ${sortedKeys.length - 5} more`))\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,oBAAsB;AACtB,sBAAqB;AACrB,SAAoB;AACpB,uBAAe;AAsCf,IAAM,oBAAoB;AAAA,EACxB;AAAA,EACA;AAAA,EAAS;AAAA,EAAS;AAAA,EAAS;AAAA,EAAS;AAAA,EACpC;AAAA,EAAS;AAAA,EAAS;AAAA,EAAS;AAAA,EAAS;AAAA,EACpC;AAAA,EAAS;AAAA,EAAS;AACpB;AAEA,IAAM,eAAiD;AAAA,EACrD,IAAI,CAAC,MAAM,IAAI;AAAA,EACf,OAAO,CAAC,MAAM,IAAI;AAAA,EAClB,OAAO,CAAC,MAAM,IAAI;AAAA,EAClB,OAAO,CAAC,MAAM,IAAI;AAAA,EAClB,OAAO,CAAC,MAAM,IAAI;AAAA,EAClB,OAAO,CAAC,MAAM,IAAI;AAAA,EAClB,OAAO,CAAC,MA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