@dialexjs/cli 0.2.1 → 0.2.3
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
CHANGED
|
@@ -18,7 +18,7 @@ bun add -d @dialexjs/cli dialexjs
|
|
|
18
18
|
npm install -g @dialexjs/cli
|
|
19
19
|
```
|
|
20
20
|
|
|
21
|
-
Binaries installed: `
|
|
21
|
+
Binaries installed: `dialex` and the shorter alias `dx` (handy in package.json scripts).
|
|
22
22
|
|
|
23
23
|
---
|
|
24
24
|
|
|
@@ -44,7 +44,7 @@ dialex init --framework fastify --default-locale en --locales en,tr -y
|
|
|
44
44
|
|
|
45
45
|
Compiles `.content.ts` dictionaries into static TypeScript modules for zero-overhead server execution:
|
|
46
46
|
|
|
47
|
-
- Outputs `src/
|
|
47
|
+
- Outputs `src/dialex.generated.ts` (static dictionary map).
|
|
48
48
|
- Outputs `src/dialex-env.d.ts` (type registry augmentation).
|
|
49
49
|
- **Watch Mode (`-w` / `--watch`)**: Continuously monitors dictionary changes and updates bundles instantaneously.
|
|
50
50
|
|
|
@@ -82,6 +82,10 @@ dialex check
|
|
|
82
82
|
|
|
83
83
|
---
|
|
84
84
|
|
|
85
|
+
## 📝 Changelog
|
|
86
|
+
|
|
87
|
+
See what changed in each release in the [changelog](https://github.com/awaiden/dialex/blob/main/CHANGELOG.md), or on [GitHub Releases](https://github.com/awaiden/dialex/releases).
|
|
88
|
+
|
|
85
89
|
## 📄 License
|
|
86
90
|
|
|
87
91
|
MIT © [awaiden](https://github.com/awaiden)
|
package/dist/api.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { C as saveDictionaryFile, S as renderDictionaryFile, T as generateDictionaries, _ as listLeaves, a as parseStaticConfig, b as locationOf, c as analyzeProject, d as TODO_PREFIX, f as copyLeaf, g as hasPath, h as getString, i as DEFAULT_STATIC_CONFIG, l as relativeFile, m as getLeafSource, n as loadStaticProject, o as readStaticConfig, p as dictionaryLocation, r as toKey, s as DEFAULT_SOURCE_GLOB, t as loadProject, u as scanReferences, v as listLocales, w as setString, x as parseDictionaryText, y as loadDictionaryFile } from "./project-
|
|
1
|
+
import { C as saveDictionaryFile, S as renderDictionaryFile, T as generateDictionaries, _ as listLeaves, a as parseStaticConfig, b as locationOf, c as analyzeProject, d as TODO_PREFIX, f as copyLeaf, g as hasPath, h as getString, i as DEFAULT_STATIC_CONFIG, l as relativeFile, m as getLeafSource, n as loadStaticProject, o as readStaticConfig, p as dictionaryLocation, r as toKey, s as DEFAULT_SOURCE_GLOB, t as loadProject, u as scanReferences, v as listLocales, w as setString, x as parseDictionaryText, y as loadDictionaryFile } from "./project-BnG6V2I0.mjs";
|
|
2
2
|
export { DEFAULT_SOURCE_GLOB, DEFAULT_STATIC_CONFIG, TODO_PREFIX, analyzeProject, copyLeaf, dictionaryLocation, generateDictionaries, getLeafSource, getString, hasPath, listLeaves, listLocales, loadDictionaryFile, loadProject, loadStaticProject, locationOf, parseDictionaryText, parseStaticConfig, readStaticConfig, relativeFile, renderDictionaryFile, saveDictionaryFile, scanReferences, setString, toKey };
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { C as saveDictionaryFile, D as logger, E as runGenerate, T as generateDictionaries, _ as listLeaves, c as analyzeProject, d as TODO_PREFIX, f as copyLeaf, g as hasPath, h as getString, r as toKey, t as loadProject, v as listLocales, w as setString, y as loadDictionaryFile } from "./project-
|
|
2
|
+
import { C as saveDictionaryFile, D as logger, E as runGenerate, T as generateDictionaries, _ as listLeaves, c as analyzeProject, d as TODO_PREFIX, f as copyLeaf, g as hasPath, h as getString, r as toKey, t as loadProject, v as listLocales, w as setString, y as loadDictionaryFile } from "./project-BnG6V2I0.mjs";
|
|
3
3
|
import { Command } from "commander";
|
|
4
4
|
import fs from "node:fs";
|
|
5
5
|
import path from "node:path";
|
|
@@ -317,16 +317,16 @@ ${localeList.map((loc) => ` ${loc}: {
|
|
|
317
317
|
if (fs.existsSync(pkgPath)) try {
|
|
318
318
|
const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf-8"));
|
|
319
319
|
pkg.scripts = pkg.scripts || {};
|
|
320
|
-
if (!pkg.scripts["
|
|
321
|
-
pkg.scripts["
|
|
320
|
+
if (!pkg.scripts["dx:generate"]) {
|
|
321
|
+
pkg.scripts["dx:generate"] = "dx generate";
|
|
322
322
|
fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + "\n", "utf-8");
|
|
323
|
-
logger.success("Added \"
|
|
323
|
+
logger.success("Added \"dx:generate\" script to package.json");
|
|
324
324
|
}
|
|
325
325
|
} catch {}
|
|
326
326
|
if (options.ai === true || options.yes && options.ai !== false && options.noAi !== true) try {
|
|
327
|
-
const
|
|
328
|
-
fs.mkdirSync(
|
|
329
|
-
fs.writeFileSync(path.join(
|
|
327
|
+
const skillDir = path.join(root, ".agents/skills/dialex");
|
|
328
|
+
fs.mkdirSync(skillDir, { recursive: true });
|
|
329
|
+
fs.writeFileSync(path.join(skillDir, "SKILL.md"), `---
|
|
330
330
|
name: dialex
|
|
331
331
|
description: Guide for internationalizing JavaScript and TypeScript apps with Dialex. Use when adding translations, creating content dictionaries, configuring locales, or using Dialex with frameworks like Next.js, React, Express, Hono, Fastify, SvelteKit, and Nuxt.
|
|
332
332
|
---
|
|
@@ -368,14 +368,14 @@ This project uses [Dialex](https://github.com/awaiden/dialex) for type-safe inte
|
|
|
368
368
|
- Dictionaries are in \`*.content.ts\` files using \`defineDictionary\`.
|
|
369
369
|
- Run \`dialex check --json\` to verify parity.
|
|
370
370
|
- Run \`dialex check --fix\` to insert missing keys marked with \`[TODO]\`.
|
|
371
|
-
- Run \`
|
|
371
|
+
- Run \`dx generate\` (alias of \`dialex\`) or \`npm run dx:generate\` to compile dictionary bundles and update types.
|
|
372
372
|
`;
|
|
373
373
|
if (!fs.existsSync(agentsMdPath)) fs.writeFileSync(agentsMdPath, dialexAgentSnippet.trimStart(), "utf-8");
|
|
374
374
|
else {
|
|
375
375
|
const existing = fs.readFileSync(agentsMdPath, "utf-8");
|
|
376
376
|
if (!existing.includes("Dialex")) fs.writeFileSync(agentsMdPath, existing.trimEnd() + "\n" + dialexAgentSnippet, "utf-8");
|
|
377
377
|
}
|
|
378
|
-
logger.success("Configured AI assistant support (.
|
|
378
|
+
logger.success("Configured AI assistant support (.agents/skills, .mcp.json, AGENTS.md)");
|
|
379
379
|
} catch (err) {
|
|
380
380
|
logger.warn(`Could not finish AI configuration: ${err.message || String(err)}`);
|
|
381
381
|
}
|
|
@@ -386,7 +386,7 @@ This project uses [Dialex](https://github.com/awaiden/dialex) for type-safe inte
|
|
|
386
386
|
logger.log(`
|
|
387
387
|
import { Hono } from "hono";
|
|
388
388
|
import { i18n } from "dialexjs/hono";
|
|
389
|
-
import dictionaries from "./src/
|
|
389
|
+
import dictionaries from "./src/dialex.generated.js";
|
|
390
390
|
|
|
391
391
|
const app = new Hono();
|
|
392
392
|
app.use("*", i18n({ dictionaries }));
|
|
@@ -401,7 +401,7 @@ app.get("/", (c) => {
|
|
|
401
401
|
logger.log(`
|
|
402
402
|
import Fastify from "fastify";
|
|
403
403
|
import { i18nPlugin } from "dialexjs/fastify";
|
|
404
|
-
import dictionaries from "./src/
|
|
404
|
+
import dictionaries from "./src/dialex.generated.js";
|
|
405
405
|
|
|
406
406
|
const app = Fastify();
|
|
407
407
|
await app.register(i18nPlugin, { dictionaries });
|
|
@@ -416,7 +416,7 @@ app.get("/", (req) => {
|
|
|
416
416
|
logger.log(`
|
|
417
417
|
import express from "express";
|
|
418
418
|
import { i18n } from "dialexjs/express";
|
|
419
|
-
import dictionaries from "./src/
|
|
419
|
+
import dictionaries from "./src/dialex.generated.js";
|
|
420
420
|
|
|
421
421
|
const app = express();
|
|
422
422
|
app.use(i18n({ dictionaries }));
|
|
@@ -431,7 +431,7 @@ app.get("/", (req, res) => {
|
|
|
431
431
|
logger.log(`
|
|
432
432
|
import Koa from "koa";
|
|
433
433
|
import { i18n } from "dialexjs/koa";
|
|
434
|
-
import dictionaries from "./src/
|
|
434
|
+
import dictionaries from "./src/dialex.generated.js";
|
|
435
435
|
|
|
436
436
|
const app = new Koa();
|
|
437
437
|
app.use(i18n({ dictionaries }));
|
|
@@ -446,7 +446,7 @@ app.use((ctx) => {
|
|
|
446
446
|
logger.log(`
|
|
447
447
|
import { Module } from "@nestjs/common";
|
|
448
448
|
import { I18nModule } from "dialexjs/nestjs";
|
|
449
|
-
import dictionaries from "./src/
|
|
449
|
+
import dictionaries from "./src/dialex.generated.js";
|
|
450
450
|
|
|
451
451
|
@Module({
|
|
452
452
|
imports: [I18nModule.forRoot({ dictionaries })],
|
|
@@ -469,7 +469,7 @@ export default async function Page({ params }: { params: Promise<{ locale: strin
|
|
|
469
469
|
logger.log(`
|
|
470
470
|
import { Elysia } from "elysia";
|
|
471
471
|
import { i18n } from "dialexjs/elysia";
|
|
472
|
-
import dictionaries from "./src/
|
|
472
|
+
import dictionaries from "./src/dialex.generated.js";
|
|
473
473
|
|
|
474
474
|
new Elysia()
|
|
475
475
|
.use(i18n({ dictionaries }))
|
|
@@ -481,7 +481,7 @@ new Elysia()
|
|
|
481
481
|
logger.log(`
|
|
482
482
|
// src/hooks.server.ts
|
|
483
483
|
import { i18nHandle } from "dialexjs/sveltekit";
|
|
484
|
-
import dictionaries from "./
|
|
484
|
+
import dictionaries from "./dialex.generated.js";
|
|
485
485
|
|
|
486
486
|
export const handle = i18nHandle({ dictionaries });
|
|
487
487
|
|
|
@@ -493,7 +493,7 @@ export const handle = i18nHandle({ dictionaries });
|
|
|
493
493
|
logger.log(`
|
|
494
494
|
// src/middleware.ts
|
|
495
495
|
import { i18n } from "dialexjs/astro";
|
|
496
|
-
import dictionaries from "./
|
|
496
|
+
import dictionaries from "./dialex.generated.js";
|
|
497
497
|
|
|
498
498
|
export const onRequest = i18n({ dictionaries });
|
|
499
499
|
|
|
@@ -524,7 +524,7 @@ export default defineNuxtConfig({
|
|
|
524
524
|
break;
|
|
525
525
|
default: logger.log(`
|
|
526
526
|
Import dictionaries and register your framework middleware to begin!
|
|
527
|
-
Run \`npm run
|
|
527
|
+
Run \`npm run dx:generate\` whenever you add new dictionary files.
|
|
528
528
|
`);
|
|
529
529
|
}
|
|
530
530
|
if (isInteractive) p.outro(pc.green("✔ dialex is configured and ready to go!"));
|
|
@@ -1045,11 +1045,11 @@ async function runTranslate(options = {}) {
|
|
|
1045
1045
|
//#endregion
|
|
1046
1046
|
//#region src/index.ts
|
|
1047
1047
|
const program = new Command();
|
|
1048
|
-
program.name("dialex").description("Dialex CLI - High-performance, type-safe internationalization compiler and tooling").version("0.2.
|
|
1048
|
+
program.name("dialex").description("Dialex CLI - High-performance, type-safe internationalization compiler and tooling").version("0.2.3");
|
|
1049
1049
|
program.command("generate").alias("gen").description("Generate standalone dictionary bundle and TypeScript declarations").option("-w, --watch", "Watch dictionary files for changes").option("-o, --output <path>", "Custom output file path for generated dictionaries").option("-c, --config <path>", "Custom config path").option("--json", "Print machine-readable JSON").action(async (opts) => {
|
|
1050
1050
|
await runGenerate(opts);
|
|
1051
1051
|
});
|
|
1052
|
-
program.command("init").description("Initialize Dialex in the current project").option("-f, --framework <framework>", "Target framework (hono, express, fastify, koa, nestjs, next, react)").option("-d, --default-locale <locale>", "Default locale (e.g. en)").option("-l, --locales <locales>", "Comma-separated supported locales (e.g. en,tr)").option("-y, --yes", "Skip prompts and use defaults").option("--ai", "Configure AI agent support (.
|
|
1052
|
+
program.command("init").description("Initialize Dialex in the current project").option("-f, --framework <framework>", "Target framework (hono, express, fastify, koa, nestjs, next, react)").option("-d, --default-locale <locale>", "Default locale (e.g. en)").option("-l, --locales <locales>", "Comma-separated supported locales (e.g. en,tr)").option("-y, --yes", "Skip prompts and use defaults").option("--ai", "Configure AI agent support (.agents/skills, .mcp.json, AGENTS.md)").option("--no-ai", "Skip AI agent configuration").action(async (opts) => {
|
|
1053
1053
|
await runInit(opts);
|
|
1054
1054
|
});
|
|
1055
1055
|
program.command("check").alias("lint").description("Verify dictionary key parity and locale completeness").option("-c, --config <path>", "Custom config path").option("--json", "Print machine-readable JSON").option("--github", "Print GitHub Actions annotations").option("--fix", "Insert missing keys marked with [TODO]").option("--src <globs...>", "Source globs to scan for dictionary references").action(async (opts) => {
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../src/utils/detector.ts","../src/commands/init.ts","../src/commands/check.ts","../src/commands/export.ts","../src/commands/import.ts","../src/translate/placeholders.ts","../src/commands/translate.ts","../src/index.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport path from \"node:path\";\n\nexport type SupportedFramework =\n | \"next\"\n | \"react\"\n | \"hono\"\n | \"express\"\n | \"fastify\"\n | \"koa\"\n | \"nestjs\"\n | \"elysia\"\n | \"sveltekit\"\n | \"astro\"\n | \"vue\"\n | \"nuxt\";\n\nexport interface DetectedFramework {\n framework: SupportedFramework;\n confidence: \"high\" | \"medium\" | \"fallback\";\n matchedRule: string;\n}\n\n/**\n * Automatically inspects package.json dependencies and configuration files\n * to detect the active framework in the target project.\n */\nexport function detectFramework(root: string): DetectedFramework {\n const pkgPath = path.join(root, \"package.json\");\n if (fs.existsSync(pkgPath)) {\n try {\n const pkg = JSON.parse(fs.readFileSync(pkgPath, \"utf-8\"));\n const allDeps = {\n ...pkg.dependencies,\n ...pkg.devDependencies,\n };\n\n if (\"nuxt\" in allDeps) {\n return {\n framework: \"nuxt\",\n confidence: \"high\",\n matchedRule: \"package.json dependencies (nuxt)\",\n };\n }\n if (\"@sveltejs/kit\" in allDeps) {\n return {\n framework: \"sveltekit\",\n confidence: \"high\",\n matchedRule: \"package.json dependencies (@sveltejs/kit)\",\n };\n }\n if (\"astro\" in allDeps) {\n return {\n framework: \"astro\",\n confidence: \"high\",\n matchedRule: \"package.json dependencies (astro)\",\n };\n }\n if (\"next\" in allDeps) {\n return {\n framework: \"next\",\n confidence: \"high\",\n matchedRule: \"package.json dependencies (next)\",\n };\n }\n if (\"@nestjs/core\" in allDeps || \"@nestjs/common\" in allDeps) {\n return {\n framework: \"nestjs\",\n confidence: \"high\",\n matchedRule: \"package.json dependencies (@nestjs/core)\",\n };\n }\n if (\"fastify\" in allDeps) {\n return {\n framework: \"fastify\",\n confidence: \"high\",\n matchedRule: \"package.json dependencies (fastify)\",\n };\n }\n if (\"koa\" in allDeps) {\n return {\n framework: \"koa\",\n confidence: \"high\",\n matchedRule: \"package.json dependencies (koa)\",\n };\n }\n if (\"express\" in allDeps) {\n return {\n framework: \"express\",\n confidence: \"high\",\n matchedRule: \"package.json dependencies (express)\",\n };\n }\n if (\"elysia\" in allDeps) {\n return {\n framework: \"elysia\",\n confidence: \"high\",\n matchedRule: \"package.json dependencies (elysia)\",\n };\n }\n if (\"hono\" in allDeps) {\n return {\n framework: \"hono\",\n confidence: \"high\",\n matchedRule: \"package.json dependencies (hono)\",\n };\n }\n if (\"vue\" in allDeps && !(\"react\" in allDeps)) {\n return {\n framework: \"vue\",\n confidence: \"high\",\n matchedRule: \"package.json dependencies (vue)\",\n };\n }\n if (\"react\" in allDeps || \"vite\" in allDeps) {\n return {\n framework: \"react\",\n confidence: \"high\",\n matchedRule: \"package.json dependencies (react/vite)\",\n };\n }\n } catch {\n // Ignore JSON parse errors\n }\n }\n\n // Check filesystem configurations\n if (\n fs.existsSync(path.join(root, \"next.config.js\")) ||\n fs.existsSync(path.join(root, \"next.config.mjs\")) ||\n fs.existsSync(path.join(root, \"next.config.ts\"))\n ) {\n return {\n framework: \"next\",\n confidence: \"medium\",\n matchedRule: \"next.config file presence\",\n };\n }\n\n const configRules: [SupportedFramework, string][] = [\n [\"nuxt\", \"nuxt.config\"],\n [\"sveltekit\", \"svelte.config\"],\n [\"astro\", \"astro.config\"],\n ];\n for (const [framework, base] of configRules) {\n if ([\"js\", \"mjs\", \"ts\"].some((ext) => fs.existsSync(path.join(root, `${base}.${ext}`)))) {\n return { framework, confidence: \"medium\", matchedRule: `${base} file presence` };\n }\n }\n\n if (\n fs.existsSync(path.join(root, \"vite.config.js\")) ||\n fs.existsSync(path.join(root, \"vite.config.mjs\")) ||\n fs.existsSync(path.join(root, \"vite.config.ts\"))\n ) {\n return {\n framework: \"react\",\n confidence: \"medium\",\n matchedRule: \"vite.config file presence\",\n };\n }\n\n return {\n framework: \"hono\",\n confidence: \"fallback\",\n matchedRule: \"default fallback\",\n };\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport * as p from \"@clack/prompts\";\nimport pc from \"picocolors\";\nimport { parseModule, loadFile, writeFile } from \"magicast\";\nimport { addNuxtModule, addVitePlugin } from \"magicast/helpers\";\nimport { generateDictionaries } from \"./generate.js\";\nimport { detectFramework, type SupportedFramework } from \"../utils/detector.js\";\nimport { logger } from \"../utils/logger.js\";\n\nexport interface InitOptions {\n cwd?: string;\n framework?: string;\n defaultLocale?: string;\n locales?: string;\n yes?: boolean;\n ai?: boolean;\n noAi?: boolean;\n}\n\nexport async function runInit(options: InitOptions = {}) {\n const root = options.cwd || process.cwd();\n const detected = detectFramework(root);\n const isInteractive = !options.yes && process.stdin.isTTY;\n\n let framework = (options.framework as SupportedFramework) || detected.framework;\n let defaultLocale = options.defaultLocale || \"en\";\n let localesInput = options.locales || \"en,tr\";\n\n if (isInteractive) {\n p.intro(pc.bgCyan(pc.black(\" dialex init \")));\n\n const frameworkOptions: { value: SupportedFramework; label: string; hint?: string }[] = [\n {\n value: \"hono\",\n label: \"Hono\",\n hint: detected.framework === \"hono\" ? \"detected\" : undefined,\n },\n {\n value: \"express\",\n label: \"Express\",\n hint: detected.framework === \"express\" ? \"detected\" : undefined,\n },\n {\n value: \"fastify\",\n label: \"Fastify\",\n hint: detected.framework === \"fastify\" ? \"detected\" : undefined,\n },\n {\n value: \"koa\",\n label: \"Koa\",\n hint: detected.framework === \"koa\" ? \"detected\" : undefined,\n },\n {\n value: \"nestjs\",\n label: \"NestJS\",\n hint: detected.framework === \"nestjs\" ? \"detected\" : undefined,\n },\n {\n value: \"next\",\n label: \"Next.js\",\n hint: detected.framework === \"next\" ? \"detected\" : undefined,\n },\n {\n value: \"react\",\n label: \"React / Vite\",\n hint: detected.framework === \"react\" ? \"detected\" : undefined,\n },\n {\n value: \"elysia\",\n label: \"Elysia\",\n hint: detected.framework === \"elysia\" ? \"detected\" : undefined,\n },\n {\n value: \"sveltekit\",\n label: \"SvelteKit\",\n hint: detected.framework === \"sveltekit\" ? \"detected\" : undefined,\n },\n {\n value: \"astro\",\n label: \"Astro\",\n hint: detected.framework === \"astro\" ? \"detected\" : undefined,\n },\n {\n value: \"vue\",\n label: \"Vue / Vite\",\n hint: detected.framework === \"vue\" ? \"detected\" : undefined,\n },\n {\n value: \"nuxt\",\n label: \"Nuxt\",\n hint: detected.framework === \"nuxt\" ? \"detected\" : undefined,\n },\n ];\n\n const selectedFramework = await p.select({\n message: `Framework detected as ${pc.bold(detected.framework)} (${detected.matchedRule}). Select framework:`,\n options: frameworkOptions,\n initialValue: detected.framework,\n });\n\n if (p.isCancel(selectedFramework)) {\n p.cancel(\"Operation cancelled.\");\n return;\n }\n framework = selectedFramework as SupportedFramework;\n\n const inputDefault = await p.text({\n message: \"What is your default locale?\",\n initialValue: \"en\",\n validate: (v) => (!v || !v.trim() ? \"Default locale cannot be empty\" : undefined),\n });\n\n if (p.isCancel(inputDefault)) {\n p.cancel(\"Operation cancelled.\");\n return;\n }\n defaultLocale = inputDefault.trim();\n\n const inputLocales = await p.text({\n message: \"Comma-separated list of supported locales:\",\n initialValue: `${defaultLocale},tr`,\n validate: (v) => (!v || !v.trim() ? \"Locales list cannot be empty\" : undefined),\n });\n\n if (p.isCancel(inputLocales)) {\n p.cancel(\"Operation cancelled.\");\n return;\n }\n localesInput = inputLocales.trim();\n\n if (options.ai === undefined && options.noAi === undefined) {\n const confirmAi = await p.confirm({\n message: \"Configure AI agent support (Claude/Cursor skills, .mcp.json, AGENTS.md)?\",\n initialValue: true,\n });\n if (!p.isCancel(confirmAi)) {\n options.ai = confirmAi;\n }\n }\n } else {\n logger.info(`Auto-detected framework: ${pc.bold(framework)} (${detected.matchedRule})`);\n }\n\n const localeList = Array.from(\n new Set([\n defaultLocale,\n ...localesInput\n .split(\",\")\n .map((s) => s.trim())\n .filter(Boolean),\n ]),\n );\n\n // 1. AST generation or update for dialex.config.ts / i18n.config.ts via Magicast\n const configPath = fs.existsSync(path.join(root, \"dialex.config.ts\"))\n ? path.join(root, \"dialex.config.ts\")\n : fs.existsSync(path.join(root, \"i18n.config.ts\"))\n ? path.join(root, \"i18n.config.ts\")\n : path.join(root, \"dialex.config.ts\");\n const configFileName = path.basename(configPath);\n\n try {\n if (fs.existsSync(configPath)) {\n const mod = await loadFile(configPath);\n if (mod && mod.exports.default) {\n if (mod.exports.default.$args && mod.exports.default.$args[0]) {\n mod.exports.default.$args[0].defaultLocale = defaultLocale;\n mod.exports.default.$args[0].locales = localeList;\n }\n await writeFile(mod, configPath);\n logger.success(`Updated ${pc.bold(configFileName)} via Magicast`);\n }\n } else {\n const mod = parseModule(`import { defineConfig } from \"dialexjs\";\n\nexport default defineConfig({});\n`);\n mod.exports.default.$args[0].defaultLocale = defaultLocale;\n mod.exports.default.$args[0].locales = localeList;\n await writeFile(mod, configPath);\n logger.success(`Created ${pc.bold(configFileName)} via Magicast`);\n }\n } catch (err: any) {\n logger.warn(`Magicast config update notice: ${err.message || String(err)}`);\n // Fallback safe string write if AST parser encounters non-standard syntax\n const fallback = `import { defineConfig } from \"dialexjs\";\n\nexport default defineConfig({\n defaultLocale: \"${defaultLocale}\",\n locales: [${localeList.map((l) => `\"${l}\"`).join(\", \")}],\n});\n`;\n fs.writeFileSync(configPath, fallback, \"utf-8\");\n }\n\n // 2. Magicast AST injection for Vite and Nuxt projects\n if (framework === \"react\" || framework === \"vue\") {\n const possibleViteConfigs = [\n path.join(root, \"vite.config.ts\"),\n path.join(root, \"vite.config.js\"),\n path.join(root, \"vite.config.mjs\"),\n ];\n for (const vConfig of possibleViteConfigs) {\n if (fs.existsSync(vConfig)) {\n try {\n const vMod = await loadFile(vConfig);\n addVitePlugin(vMod, {\n from: \"dialexjs/vite\",\n imported: \"i18nPlugin\",\n constructor: \"i18nPlugin\",\n });\n await writeFile(vMod, vConfig);\n logger.success(\n `Injected i18nPlugin() into ${pc.bold(path.basename(vConfig))} via Magicast`,\n );\n break;\n } catch {\n // If already added or non-standard, continue\n }\n }\n }\n }\n\n if (framework === \"nuxt\") {\n const nuxtConfig = [\"nuxt.config.ts\", \"nuxt.config.js\", \"nuxt.config.mjs\"]\n .map((f) => path.join(root, f))\n .find((f) => fs.existsSync(f));\n if (nuxtConfig) {\n try {\n const nMod = await loadFile(nuxtConfig);\n addNuxtModule(nMod, \"dialexjs/nuxt\", \"dialex\", {\n defaultLocale,\n locales: localeList,\n });\n await writeFile(nMod, nuxtConfig);\n logger.success(\n `Registered dialexjs/nuxt in ${pc.bold(path.basename(nuxtConfig))} via Magicast`,\n );\n } catch {\n logger.warn(\"Could not update the Nuxt config; add the dialexjs/nuxt module manually.\");\n }\n }\n }\n\n // 3. Create starter dictionary in src/ (or root)\n const targetDir = fs.existsSync(path.join(root, \"src\")) ? path.join(root, \"src\") : root;\n const dictPath = path.join(targetDir, \"home.content.ts\");\n if (!fs.existsSync(dictPath)) {\n const dictRecords = localeList\n .map(\n (loc) => ` ${loc}: {\n title: \"Welcome to Dialex (${loc})!\",\n description: \"Type-safe internationalization.\",\n greeting: (name: string) => \"Hello, \" + name + \"!\",\n },`,\n )\n .join(\"\\n\");\n\n const dictContent = `import { defineDictionary } from \"dialexjs\";\n\nexport default defineDictionary(\"home\", {\n${dictRecords}\n});\n`;\n fs.writeFileSync(dictPath, dictContent, \"utf-8\");\n logger.success(`Created starter dictionary at ${pc.bold(path.relative(root, dictPath))}`);\n } else {\n logger.info(\"home.content.ts already exists, skipping creation.\");\n }\n\n // 4. Run standalone dictionary generation immediately\n generateDictionaries(root);\n logger.success(\"Generated types and standalone dictionary registry!\");\n\n // 5. Update package.json scripts\n const pkgPath = path.join(root, \"package.json\");\n if (fs.existsSync(pkgPath)) {\n try {\n const pkg = JSON.parse(fs.readFileSync(pkgPath, \"utf-8\"));\n pkg.scripts = pkg.scripts || {};\n if (!pkg.scripts[\"i18n:generate\"]) {\n pkg.scripts[\"i18n:generate\"] = \"dialex generate\";\n fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + \"\\n\", \"utf-8\");\n logger.success('Added \"i18n:generate\" script to package.json');\n }\n } catch {\n // Ignore JSON parse errors\n }\n }\n\n // 6. AI Agent Integration (.claude/skills, .mcp.json, AGENTS.md)\n const shouldSetupAi =\n options.ai === true || (options.yes && options.ai !== false && options.noAi !== true);\n if (shouldSetupAi) {\n try {\n // 6a. Copy or create skill in .claude/skills/dialex/SKILL.md\n const claudeSkillDir = path.join(root, \".claude/skills/dialex\");\n fs.mkdirSync(claudeSkillDir, { recursive: true });\n const skillContent = `---\nname: dialex\ndescription: Guide for internationalizing JavaScript and TypeScript apps with Dialex. Use when adding translations, creating content dictionaries, configuring locales, or using Dialex with frameworks like Next.js, React, Express, Hono, Fastify, SvelteKit, and Nuxt.\n---\n\n# Dialex Internationalization\n\nDialex is a high-performance, type-safe internationalization toolchain for JavaScript and TypeScript.\n\n## Core Concepts\n- Dictionaries are defined with \\`defineDictionary(\"name\", { ... })\\` in \\`*.content.ts\\` files.\n- Keys must match across all locales.\n- ICU message syntax is supported for plurals and selects.\n- Parity is validated at compile time with \\`dialex check\\`.\n\n## Useful Commands\n- \\`dialex check --json\\`: Check dictionary parity and references.\n- \\`dialex check --fix\\`: Automatically insert missing keys marked with [TODO].\n- \\`dialex generate\\`: Rebuild standalone dictionary bundle and types.\n- \\`dialex translate --locale <locale>\\`: Automatically translate missing keys.\n`;\n fs.writeFileSync(path.join(claudeSkillDir, \"SKILL.md\"), skillContent, \"utf-8\");\n\n // 6b. Merge .mcp.json\n const mcpConfigPath = path.join(root, \".mcp.json\");\n let mcpConfig: Record<string, any> = {};\n if (fs.existsSync(mcpConfigPath)) {\n try {\n mcpConfig = JSON.parse(fs.readFileSync(mcpConfigPath, \"utf-8\"));\n } catch {\n mcpConfig = {};\n }\n }\n mcpConfig.mcpServers = mcpConfig.mcpServers || {};\n mcpConfig.mcpServers.dialex = mcpConfig.mcpServers.dialex || {\n command: \"npx\",\n args: [\"@dialexjs/mcp\"],\n };\n fs.writeFileSync(mcpConfigPath, JSON.stringify(mcpConfig, null, 2) + \"\\n\", \"utf-8\");\n\n // 6c. Add snippet to AGENTS.md if absent\n const agentsMdPath = path.join(root, \"AGENTS.md\");\n const dialexAgentSnippet = `\n## Internationalization (Dialex)\n\nThis project uses [Dialex](https://github.com/awaiden/dialex) for type-safe internationalization.\n- Dictionaries are in \\`*.content.ts\\` files using \\`defineDictionary\\`.\n- Run \\`dialex check --json\\` to verify parity.\n- Run \\`dialex check --fix\\` to insert missing keys marked with \\`[TODO]\\`.\n- Run \\`dialex generate\\` or \\`npm run i18n:generate\\` to compile dictionary bundles and update types.\n`;\n if (!fs.existsSync(agentsMdPath)) {\n fs.writeFileSync(agentsMdPath, dialexAgentSnippet.trimStart(), \"utf-8\");\n } else {\n const existing = fs.readFileSync(agentsMdPath, \"utf-8\");\n if (!existing.includes(\"Dialex\")) {\n fs.writeFileSync(agentsMdPath, existing.trimEnd() + \"\\n\" + dialexAgentSnippet, \"utf-8\");\n }\n }\n\n logger.success(\"Configured AI assistant support (.claude/skills, .mcp.json, AGENTS.md)\");\n } catch (err: any) {\n logger.warn(`Could not finish AI configuration: ${err.message || String(err)}`);\n }\n }\n\n // 7. Framework-specific quickstart instructions\n logger.log(\"\");\n logger.info(pc.bold(`Quick start for ${framework.toUpperCase()}:`));\n\n switch (framework) {\n case \"hono\":\n logger.log(`\nimport { Hono } from \"hono\";\nimport { i18n } from \"dialexjs/hono\";\nimport dictionaries from \"./src/i18n.generated.js\";\n\nconst app = new Hono();\napp.use(\"*\", i18n({ dictionaries }));\n\napp.get(\"/\", (c) => {\n const dict = c.var.getDictionary(\"home\");\n return c.json({ title: dict.title });\n});\n`);\n break;\n case \"fastify\":\n logger.log(`\nimport Fastify from \"fastify\";\nimport { i18nPlugin } from \"dialexjs/fastify\";\nimport dictionaries from \"./src/i18n.generated.js\";\n\nconst app = Fastify();\nawait app.register(i18nPlugin, { dictionaries });\n\napp.get(\"/\", (req) => {\n const dict = req.getDictionary(\"home\");\n return { title: dict.title };\n});\n`);\n break;\n case \"express\":\n logger.log(`\nimport express from \"express\";\nimport { i18n } from \"dialexjs/express\";\nimport dictionaries from \"./src/i18n.generated.js\";\n\nconst app = express();\napp.use(i18n({ dictionaries }));\n\napp.get(\"/\", (req, res) => {\n const dict = req.getDictionary(\"home\");\n res.json({ title: dict.title });\n});\n`);\n break;\n case \"koa\":\n logger.log(`\nimport Koa from \"koa\";\nimport { i18n } from \"dialexjs/koa\";\nimport dictionaries from \"./src/i18n.generated.js\";\n\nconst app = new Koa();\napp.use(i18n({ dictionaries }));\n\napp.use((ctx) => {\n const dict = ctx.getDictionary(\"home\");\n ctx.body = { title: dict.title };\n});\n`);\n break;\n case \"nestjs\":\n logger.log(`\nimport { Module } from \"@nestjs/common\";\nimport { I18nModule } from \"dialexjs/nestjs\";\nimport dictionaries from \"./src/i18n.generated.js\";\n\n@Module({\n imports: [I18nModule.forRoot({ dictionaries })],\n})\nexport class AppModule {}\n`);\n break;\n case \"next\":\n logger.log(`\nimport { getDictionary } from \"dialexjs/server\";\n\nexport default async function Page({ params }: { params: Promise<{ locale: string }> }) {\n const { locale = \"en\" } = await params;\n const dict = getDictionary(\"home\", locale);\n return <h1>{dict.title}</h1>;\n}\n`);\n break;\n case \"elysia\":\n logger.log(`\nimport { Elysia } from \"elysia\";\nimport { i18n } from \"dialexjs/elysia\";\nimport dictionaries from \"./src/i18n.generated.js\";\n\nnew Elysia()\n .use(i18n({ dictionaries }))\n .get(\"/\", ({ getDictionary }) => ({ title: getDictionary(\"home\").title }))\n .listen(3000);\n`);\n break;\n case \"sveltekit\":\n logger.log(`\n// src/hooks.server.ts\nimport { i18nHandle } from \"dialexjs/sveltekit\";\nimport dictionaries from \"./i18n.generated.js\";\n\nexport const handle = i18nHandle({ dictionaries });\n\n// src/app.html: <html lang=\"%dialex.lang%\">\n// In load functions: locals.getDictionary(\"home\")\n`);\n break;\n case \"astro\":\n logger.log(`\n// src/middleware.ts\nimport { i18n } from \"dialexjs/astro\";\nimport dictionaries from \"./i18n.generated.js\";\n\nexport const onRequest = i18n({ dictionaries });\n\n// In pages: Astro.locals.getDictionary(\"home\")\n`);\n break;\n case \"vue\":\n logger.log(`\n// src/main.ts\nimport { createApp } from \"vue\";\nimport { createI18n } from \"dialexjs/vue\";\nimport App from \"./App.vue\";\n\ncreateApp(App).use(createI18n()).mount(\"#app\");\n\n// In components: const dict = useDictionary(\"home\")\n`);\n break;\n case \"nuxt\":\n logger.log(`\n// nuxt.config.ts\nexport default defineNuxtConfig({\n modules: [\"dialexjs/nuxt\"],\n});\n\n// In components: const dict = useDictionary(\"home\")\n`);\n break;\n default:\n logger.log(`\nImport dictionaries and register your framework middleware to begin!\nRun \\`npm run i18n:generate\\` whenever you add new dictionary files.\n`);\n break;\n }\n\n if (isInteractive) {\n p.outro(pc.green(\"✔ dialex is configured and ready to go!\"));\n }\n}\n","import path from \"node:path\";\nimport fg from \"fast-glob\";\nimport pc from \"picocolors\";\nimport { resolveI18nConfig } from \"dialexjs/scanner\";\nimport { analyzeProject, type AnalysisIssue } from \"../analysis.js\";\nimport { logger } from \"../utils/logger.js\";\nimport {\n TODO_PREFIX,\n copyLeaf,\n hasPath,\n listLeaves,\n listLocales,\n loadDictionaryFile,\n saveDictionaryFile,\n} from \"../utils/dictionary-edit.js\";\n\nexport interface CheckOptions {\n cwd?: string;\n config?: string;\n exitOnError?: boolean;\n /** Print machine-readable JSON instead of human output. */\n json?: boolean;\n /** Also print GitHub Actions workflow annotations. */\n github?: boolean;\n /** Insert missing keys (marked with `[TODO]`) before checking. */\n fix?: boolean;\n /** Globs of source files to scan for dictionary references. */\n src?: string[];\n}\n\nexport interface CheckAnnotation {\n level: \"error\" | \"warning\";\n message: string;\n line?: number;\n}\n\nexport interface CheckDiagnostic {\n file: string;\n name?: string;\n errors: string[];\n warnings: string[];\n annotations: CheckAnnotation[];\n}\n\nexport interface CheckResult {\n success: boolean;\n diagnostics: CheckDiagnostic[];\n totalIssues: number;\n totalWarnings: number;\n /** Number of missing keys inserted by `--fix`. */\n fixed: number;\n}\n\nconst DICTIONARY_IGNORE = [\"**/node_modules/**\", \"**/dist/**\", \"**/.next/**\"];\n\nfunction addIssue(diag: CheckDiagnostic, issue: AnalysisIssue) {\n const level = issue.level === \"error\" ? \"error\" : \"warning\";\n (level === \"error\" ? diag.errors : diag.warnings).push(issue.message);\n diag.annotations.push({\n level,\n message: issue.message,\n line: issue.range ? issue.range.start.line + 1 : undefined,\n });\n}\n\n/**\n * Inserts keys that exist in one locale but not in another, copying the default-locale value\n * (strings get a `[TODO]` prefix). Returns how many keys were inserted.\n */\nasync function applyFixes(\n files: string[],\n configuredLocales: string[],\n defaultLocale: string,\n): Promise<number> {\n let fixed = 0;\n\n for (const file of files) {\n const df = await loadDictionaryFile(file);\n // Spreads and computed keys hide keys from the syntax tree; inserting would be guesswork.\n if (!df?.complete) continue;\n\n const present = listLocales(df);\n const targets = Array.from(new Set([...present, ...configuredLocales]));\n const sourceOrder = [defaultLocale, ...present.filter((l) => l !== defaultLocale)].filter((l) =>\n present.includes(l),\n );\n\n const allPaths = new Map<string, string[]>();\n for (const locale of present) {\n for (const leaf of listLeaves(df, locale)) allPaths.set(leaf.path.join(\"\\u0000\"), leaf.path);\n }\n\n let changed = false;\n for (const target of targets) {\n for (const leafPath of allPaths.values()) {\n if (hasPath(df, target, leafPath)) continue;\n const source = sourceOrder.find((l) => l !== target && hasPath(df, l, leafPath));\n if (source && copyLeaf(df, source, target, leafPath, (v) => `${TODO_PREFIX}${v}`)) {\n fixed++;\n changed = true;\n }\n }\n }\n\n if (changed) await saveDictionaryFile(df);\n }\n\n return fixed;\n}\n\nfunction escapeAnnotation(value: string): string {\n return value.replace(/%/g, \"%25\").replace(/\\r/g, \"%0D\").replace(/\\n/g, \"%0A\");\n}\n\nexport async function runCheck(options: CheckOptions = {}): Promise<CheckResult> {\n const root = options.cwd || process.cwd();\n const quiet = options.json === true;\n const inlineConfig = options.config ? { configFile: options.config } : {};\n const config = resolveI18nConfig(root, inlineConfig);\n const include = config.include || \"**/*.content.ts\";\n const configuredLocales = config.locales || [];\n const defaultLocale = config.defaultLocale || \"en\";\n\n const files = fg.sync(include, { cwd: root, absolute: true, ignore: DICTIONARY_IGNORE });\n\n if (files.length === 0) {\n if (!quiet) {\n const patternStr = Array.isArray(include) ? include.join(\", \") : include;\n logger.warn(`No dictionary files found matching \"${patternStr}\".`);\n }\n const empty: CheckResult = {\n success: true,\n diagnostics: [],\n totalIssues: 0,\n totalWarnings: 0,\n fixed: 0,\n };\n if (quiet) console.log(JSON.stringify(empty, null, 2));\n return empty;\n }\n\n let fixed = 0;\n if (options.fix) {\n fixed = await applyFixes(files, configuredLocales, defaultLocale);\n if (fixed > 0 && !quiet) {\n logger.success(\n `Inserted ${fixed} missing key${fixed === 1 ? \"\" : \"s\"} marked ${TODO_PREFIX.trim()}`,\n );\n }\n }\n\n const analysis = await analyzeProject({\n root,\n config,\n src: options.src && options.src.length > 0 ? options.src : undefined,\n runtime: true,\n });\n\n // Group issues per file, dictionary files first (the analysis reports them first)\n const byFile = new Map<string, CheckDiagnostic>();\n const dictionaryFiles = new Set(analysis.files);\n for (const issue of analysis.issues) {\n if (issue.level === \"info\") continue;\n const rel = path.relative(root, issue.file);\n let diag = byFile.get(rel);\n if (!diag) {\n diag = { file: rel, errors: [], warnings: [], annotations: [] };\n byFile.set(rel, diag);\n }\n if (dictionaryFiles.has(issue.file) && issue.dictionary && !diag.name)\n diag.name = issue.dictionary;\n addIssue(diag, issue);\n }\n const diagnostics = [...byFile.values()];\n\n const totalIssues = diagnostics.reduce((n, d) => n + d.errors.length, 0);\n const totalWarnings = diagnostics.reduce((n, d) => n + d.warnings.length, 0);\n const reported = diagnostics.filter((d) => d.errors.length > 0 || d.warnings.length > 0);\n const result: CheckResult = {\n success: totalIssues === 0,\n diagnostics: reported,\n totalIssues,\n totalWarnings,\n fixed,\n };\n\n if (options.github) {\n for (const d of reported) {\n for (const a of d.annotations) {\n const location = `file=${d.file}${a.line ? `,line=${a.line}` : \"\"}`;\n console.log(`::${a.level} ${location},title=dialex::${escapeAnnotation(a.message)}`);\n }\n }\n }\n\n if (quiet) {\n console.log(JSON.stringify(result, null, 2));\n } else if (reported.length > 0) {\n logger.log(\"\");\n if (totalIssues > 0) {\n logger.error(\n `Found ${totalIssues} issue${totalIssues === 1 ? \"\" : \"s\"} across ${reported.filter((d) => d.errors.length > 0).length} file${reported.length === 1 ? \"\" : \"s\"}:`,\n );\n }\n logger.log(\"\");\n\n for (const d of reported) {\n logger.log(` ${pc.underline(pc.bold(d.file))} ${d.name ? pc.dim(`(${d.name})`) : \"\"}:`);\n for (const a of d.annotations) {\n const where = a.line ? pc.dim(`:${a.line}`) : \"\";\n const mark = a.level === \"error\" ? pc.red(\"✖\") : pc.yellow(\"⚠\");\n logger.log(` ${mark} ${a.message}${where}`);\n }\n logger.log(\"\");\n }\n }\n\n if (totalIssues > 0) {\n if (options.exitOnError !== false) process.exit(1);\n return result;\n }\n\n if (!quiet) {\n const warningNote =\n totalWarnings > 0 ? ` (${totalWarnings} warning${totalWarnings === 1 ? \"\" : \"s\"})` : \"\";\n logger.success(\n `All ${files.length} dictionary file${files.length === 1 ? \"\" : \"s\"} passed checks with 0 issues${warningNote}!`,\n );\n }\n return result;\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport { listLeaves, listLocales } from \"../utils/dictionary-edit.js\";\nimport { loadProject, toKey } from \"../utils/project.js\";\nimport { logger } from \"../utils/logger.js\";\n\nexport type TranslationFormat = \"json\" | \"csv\" | \"xliff\";\n\nexport interface ExportOptions {\n cwd?: string;\n config?: string;\n format?: TranslationFormat;\n /** Output directory, relative to `cwd`. */\n out?: string;\n /** Limit the export to these locales. */\n locale?: string[];\n /** Print machine-readable JSON instead of human output. */\n json?: boolean;\n}\n\nexport interface ExportResult {\n success: boolean;\n files: string[];\n keys: number;\n /** Function values cannot be exported as plain text. */\n skippedFunctions: number;\n skippedFiles: string[];\n}\n\nexport const escapeXml = (value: string) =>\n value.replace(/&/g, \"&\").replace(/</g, \"<\").replace(/>/g, \">\").replace(/\"/g, \""\");\n\nexport const csvCell = (value: string) =>\n /[\",\\r\\n]/.test(value) ? `\"${value.replace(/\"/g, '\"\"')}\"` : value;\n\nexport async function runExport(options: ExportOptions = {}): Promise<ExportResult> {\n const root = options.cwd || process.cwd();\n const format = options.format || \"json\";\n if (![\"json\", \"csv\", \"xliff\"].includes(format)) {\n throw new Error(`Unsupported format \"${format}\". Use json, csv, or xliff.`);\n }\n const outDir = path.resolve(root, options.out || \"i18n-export\");\n\n const project = await loadProject(root, options.config);\n const defaultLocale = project.config.defaultLocale || \"en\";\n\n // locale -> key -> value (insertion order = source order)\n const table = new Map<string, Map<string, string>>();\n const orderedKeys = new Set<string>();\n let skippedFunctions = 0;\n\n const localeSet = new Set<string>(project.config.locales || []);\n for (const { df } of project.dictionaries) listLocales(df).forEach((l) => localeSet.add(l));\n let locales = Array.from(localeSet);\n if (options.locale && options.locale.length > 0) {\n locales = locales.filter((l) => options.locale!.includes(l) || l === defaultLocale);\n }\n for (const locale of locales) table.set(locale, new Map());\n\n for (const { name, df } of project.dictionaries) {\n for (const locale of listLocales(df)) {\n if (!table.has(locale)) continue;\n for (const leaf of listLeaves(df, locale)) {\n if (leaf.kind === \"string\" && leaf.value !== undefined) {\n const key = toKey(name, leaf.path);\n table.get(locale)!.set(key, leaf.value);\n orderedKeys.add(key);\n } else if (locale === defaultLocale) {\n skippedFunctions++;\n }\n }\n }\n }\n\n fs.mkdirSync(outDir, { recursive: true });\n const files: string[] = [];\n const write = (name: string, content: string) => {\n const file = path.join(outDir, name);\n fs.writeFileSync(file, content, \"utf-8\");\n files.push(path.relative(root, file));\n };\n\n if (format === \"json\") {\n for (const [locale, values] of table) {\n write(`${locale}.json`, JSON.stringify(Object.fromEntries(values), null, 2) + \"\\n\");\n }\n } else if (format === \"csv\") {\n const header = [\"key\", ...table.keys()].map(csvCell).join(\",\");\n const rows = [...orderedKeys].map((key) =>\n [key, ...[...table.values()].map((v) => v.get(key) ?? \"\")].map(csvCell).join(\",\"),\n );\n write(\"translations.csv\", [header, ...rows].join(\"\\n\") + \"\\n\");\n } else {\n const source = table.get(defaultLocale);\n for (const [locale, values] of table) {\n if (locale === defaultLocale) continue;\n const units = [...orderedKeys].map((key) => {\n const src = source?.get(key) ?? \"\";\n const target = values.get(key);\n const targetXml = target === undefined ? \"\" : `<target>${escapeXml(target)}</target>`;\n return ` <trans-unit id=\"${escapeXml(key)}\"><source>${escapeXml(src)}</source>${targetXml}</trans-unit>`;\n });\n write(\n `${locale}.xlf`,\n `<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<xliff version=\"1.2\" xmlns=\"urn:oasis:names:tc:xliff:document:1.2\">\n <file original=\"dialex\" source-language=\"${escapeXml(defaultLocale)}\" target-language=\"${escapeXml(locale)}\" datatype=\"plaintext\">\n <body>\n${units.join(\"\\n\")}\n </body>\n </file>\n</xliff>\n`,\n );\n }\n }\n\n const quiet = options.json === true;\n\n const result: ExportResult = {\n success: true,\n files,\n keys: orderedKeys.size,\n skippedFunctions,\n skippedFiles: project.unsupported,\n };\n\n if (quiet) {\n console.log(JSON.stringify(result, null, 2));\n } else {\n logger.success(\n `Exported ${orderedKeys.size} key${orderedKeys.size === 1 ? \"\" : \"s\"} to ${files.length} ${format} file${files.length === 1 ? \"\" : \"s\"} in ${path.relative(root, outDir) || \".\"}`,\n );\n if (skippedFunctions > 0) {\n logger.warn(\n `${skippedFunctions} function value${skippedFunctions === 1 ? \"\" : \"s\"} skipped (not translatable as text)`,\n );\n }\n for (const file of project.unsupported)\n logger.warn(`Skipped ${file}: unsupported dictionary shape`);\n }\n\n return result;\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport {\n getString,\n hasPath,\n listLocales,\n saveDictionaryFile,\n setString,\n} from \"../utils/dictionary-edit.js\";\nimport { argumentSignature, parseMessage } from \"dialexjs/icu\";\nimport { loadProject } from \"../utils/project.js\";\nimport { logger } from \"../utils/logger.js\";\nimport type { TranslationFormat } from \"./export.js\";\n\nexport interface ImportOptions {\n cwd?: string;\n config?: string;\n /** File to import (`.json`, `.csv`, or `.xlf`/`.xliff`). */\n file: string;\n format?: TranslationFormat;\n /** Locale for single-locale files. Defaults to the file name (`tr.json`) or XLIFF target language. */\n locale?: string;\n /** Allow keys that do not exist in any locale yet. */\n allowNew?: boolean;\n /** Print machine-readable JSON instead of human output. */\n json?: boolean;\n}\n\nexport interface ImportEntry {\n locale: string;\n key: string;\n value: string;\n}\n\nexport interface ImportResult {\n success: boolean;\n created: number;\n updated: number;\n /** Function/non-text values that cannot be overwritten. */\n skipped: string[];\n /** Values refused because they are invalid ICU or change the message arguments. */\n rejected: string[];\n unknown: string[];\n errors: string[];\n}\n\nconst unescapeXml = (value: string) =>\n value\n .replace(/</g, \"<\")\n .replace(/>/g, \">\")\n .replace(/"/g, '\"')\n .replace(/'/g, \"'\")\n .replace(/&/g, \"&\");\n\nexport function parseCsv(text: string): string[][] {\n const rows: string[][] = [];\n let row: string[] = [];\n let cell = \"\";\n let quoted = false;\n\n for (let i = 0; i < text.length; i++) {\n const ch = text[i];\n if (quoted) {\n if (ch === '\"' && text[i + 1] === '\"') {\n cell += '\"';\n i++;\n } else if (ch === '\"') {\n quoted = false;\n } else {\n cell += ch;\n }\n } else if (ch === '\"') {\n quoted = true;\n } else if (ch === \",\") {\n row.push(cell);\n cell = \"\";\n } else if (ch === \"\\n\" || ch === \"\\r\") {\n if (ch === \"\\r\" && text[i + 1] === \"\\n\") i++;\n row.push(cell);\n rows.push(row);\n row = [];\n cell = \"\";\n } else {\n cell += ch;\n }\n }\n if (cell !== \"\" || row.length > 0) {\n row.push(cell);\n rows.push(row);\n }\n return rows.filter((r) => r.some((c) => c !== \"\"));\n}\n\nexport function parseEntries(\n content: string,\n format: TranslationFormat,\n fallbackLocale: string | undefined,\n): ImportEntry[] {\n const entries: ImportEntry[] = [];\n\n if (format === \"json\") {\n const data = JSON.parse(content) as Record<string, unknown>;\n const isNested =\n Object.keys(data).length > 0 &&\n Object.values(data).every((v) => v && typeof v === \"object\" && !Array.isArray(v));\n if (isNested) {\n for (const [locale, values] of Object.entries(data)) {\n for (const [key, value] of Object.entries(values as Record<string, unknown>)) {\n if (typeof value === \"string\") entries.push({ locale, key, value });\n }\n }\n } else {\n if (!fallbackLocale) throw new Error(\"Cannot infer the locale; pass --locale.\");\n for (const [key, value] of Object.entries(data)) {\n if (typeof value === \"string\") entries.push({ locale: fallbackLocale, key, value });\n }\n }\n } else if (format === \"csv\") {\n const [header, ...rows] = parseCsv(content);\n if (!header || header[0] !== \"key\") throw new Error('CSV must start with a \"key\" column.');\n for (const row of rows) {\n header.slice(1).forEach((locale, i) => {\n const value = row[i + 1];\n if (value !== undefined && value !== \"\") entries.push({ locale, key: row[0], value });\n });\n }\n } else {\n const locale = /target-language=\"([^\"]*)\"/.exec(content)?.[1] ?? fallbackLocale;\n if (!locale) throw new Error(\"Cannot infer the locale; pass --locale.\");\n const unit = /<trans-unit\\b[^>]*\\bid=\"([^\"]*)\"[^>]*>([\\s\\S]*?)<\\/trans-unit>/g;\n for (const match of content.matchAll(unit)) {\n const target = /<target\\b[^>]*>([\\s\\S]*?)<\\/target>/.exec(match[2])?.[1];\n if (target !== undefined && target !== \"\") {\n entries.push({ locale, key: unescapeXml(match[1]), value: unescapeXml(target) });\n }\n }\n }\n\n return entries;\n}\n\nfunction inferFormat(file: string): TranslationFormat {\n const ext = path.extname(file).toLowerCase();\n if (ext === \".json\") return \"json\";\n if (ext === \".csv\") return \"csv\";\n if (ext === \".xlf\" || ext === \".xliff\") return \"xliff\";\n throw new Error(`Cannot infer format from \"${ext}\". Pass --format json|csv|xliff.`);\n}\n\n/**\n * Why `value` must not replace the current text, if it is an ICU message that is invalid or uses\n * different arguments than the same key in another locale.\n */\nfunction icuProblem(\n df: Parameters<typeof getString>[0],\n defaultLocale: string,\n locale: string,\n keyPath: string[],\n value: string,\n): string | undefined {\n if (!value.includes(\"{\")) return undefined;\n\n let signature: string;\n try {\n signature = argumentSignature(parseMessage(value));\n } catch (error) {\n return `invalid ICU: ${(error as Error).message}`;\n }\n\n const locales = listLocales(df);\n for (const other of [defaultLocale, ...locales.filter((l) => l !== defaultLocale)]) {\n if (other === locale) continue;\n const reference = getString(df, other, keyPath);\n if (!reference?.includes(\"{\")) continue;\n try {\n const expected = argumentSignature(parseMessage(reference));\n return expected === signature\n ? undefined\n : `arguments differ from \"${other}\": expected ${expected || \"none\"}, found ${signature || \"none\"}`;\n } catch {\n continue;\n }\n }\n return undefined;\n}\n\nexport async function runImport(options: ImportOptions): Promise<ImportResult> {\n const root = options.cwd || process.cwd();\n const file = path.resolve(root, options.file);\n const format = options.format || inferFormat(file);\n const fallbackLocale = options.locale ?? path.basename(file, path.extname(file));\n\n const entries = parseEntries(\n fs.readFileSync(file, \"utf-8\"),\n format,\n options.locale ?? fallbackLocale,\n );\n const project = await loadProject(root, options.config);\n const byName = new Map(project.dictionaries.map((d) => [d.name, d]));\n\n const quiet = options.json === true;\n const result: ImportResult = {\n success: true,\n created: 0,\n updated: 0,\n skipped: [],\n rejected: [],\n unknown: [],\n errors: [],\n };\n const touched = new Set<string>();\n\n for (const { locale, key, value } of entries) {\n const [name, ...keyPath] = key.split(\".\");\n const dict = byName.get(name);\n if (!dict || keyPath.length === 0) {\n result.unknown.push(key);\n continue;\n }\n\n const exists = listLocales(dict.df).some((l) => hasPath(dict.df, l, keyPath));\n if (!exists && !options.allowNew) {\n result.unknown.push(key);\n continue;\n }\n\n const problem = icuProblem(\n dict.df,\n project.config.defaultLocale ?? \"en\",\n locale,\n keyPath,\n value,\n );\n if (problem) {\n result.rejected.push(`${locale}:${key} (${problem})`);\n continue;\n }\n\n const outcome = setString(dict.df, locale, keyPath, value);\n if (outcome === \"skipped\") {\n result.skipped.push(`${locale}:${key}`);\n } else {\n result[outcome]++;\n touched.add(dict.rel);\n }\n }\n\n for (const dict of project.dictionaries) {\n if (touched.has(dict.rel)) await saveDictionaryFile(dict.df);\n }\n\n if (result.rejected.length > 0) {\n result.success = false;\n }\n\n if (quiet) {\n console.log(JSON.stringify(result, null, 2));\n } else {\n logger.success(\n `Imported ${result.created + result.updated} value${result.created + result.updated === 1 ? \"\" : \"s\"} (${result.created} added, ${result.updated} updated)`,\n );\n if (result.unknown.length > 0) {\n logger.warn(\n `${result.unknown.length} unknown key${result.unknown.length === 1 ? \"\" : \"s\"} ignored (use --allow-new to add): ${result.unknown.slice(0, 5).join(\", \")}${result.unknown.length > 5 ? \", ...\" : \"\"}`,\n );\n }\n if (result.rejected.length > 0) {\n logger.warn(\n `${result.rejected.length} value${result.rejected.length === 1 ? \"\" : \"s\"} rejected: ${result.rejected.slice(0, 5).join(\"; \")}`,\n );\n }\n if (result.skipped.length > 0) {\n logger.warn(\n `${result.skipped.length} non-text value${result.skipped.length === 1 ? \"\" : \"s\"} left unchanged: ${result.skipped.slice(0, 5).join(\", \")}`,\n );\n }\n }\n\n return result;\n}\n","import { getArguments, isIcuStructured, parseMessage } from \"dialexjs/icu\";\n\n/** `{name}`, `%s` / `%1$d`, and HTML/XML tags: text that must survive translation unchanged. */\nconst PLACEHOLDER = /\\{[^{}]+\\}|%\\d*\\$?[sdif]|<\\/?[A-Za-z][^<>]*>/g;\n\nexport function extractPlaceholders(text: string): string[] {\n return text.match(PLACEHOLDER) ?? [];\n}\n\n/**\n * ICU plural/select messages put translatable text inside `{...}` branches, so brace matching\n * is meaningless for them. Compare the structure instead: the same arguments with the same\n * types, every `select` key and every exact `=N` plural match preserved. A translation may\n * add or drop plural categories (`one`, `few`, ...), because languages need different ones.\n */\nfunction preservesIcuStructure(source: string, translated: string): boolean {\n try {\n const before = getArguments(parseMessage(source));\n const after = getArguments(parseMessage(translated));\n const sameArguments =\n before.length === after.length &&\n before.every((a) => after.some((b) => a.name === b.name && a.type === b.type));\n if (!sameArguments) return false;\n\n return before.every((a) => {\n const other = after.find((b) => b.name === a.name && b.type === a.type)!;\n const keep =\n a.type === \"select\"\n ? (a.selectors ?? [])\n : (a.selectors ?? []).filter((selector) => selector.startsWith(\"=\"));\n return keep.every((selector) => other.selectors?.includes(selector));\n });\n } catch {\n return false;\n }\n}\n\n/** True when every placeholder of `source` appears in `translated` (as many times as in the source). */\nexport function preservesPlaceholders(source: string, translated: string): boolean {\n if (isIcuStructured(source)) return preservesIcuStructure(source, translated);\n\n const remaining = extractPlaceholders(translated);\n for (const placeholder of extractPlaceholders(source)) {\n const index = remaining.indexOf(placeholder);\n if (index === -1) return false;\n remaining.splice(index, 1);\n }\n return true;\n}\n","import pc from \"picocolors\";\nimport type { TranslateProvider } from \"dialexjs\";\nimport {\n TODO_PREFIX,\n listLeaves,\n listLocales,\n saveDictionaryFile,\n setString,\n} from \"../utils/dictionary-edit.js\";\nimport { loadProject, toKey, type ProjectDictionary } from \"../utils/project.js\";\nimport { isIcuStructured } from \"dialexjs/icu\";\nimport { preservesPlaceholders } from \"../translate/placeholders.js\";\nimport { logger } from \"../utils/logger.js\";\n\nexport interface TranslateOptions {\n cwd?: string;\n config?: string;\n /** Target locales. Defaults to every configured locale except the source. */\n locale?: string[];\n /** Locale to translate from. Defaults to `translate.sourceLocale`, then `defaultLocale`. */\n source?: string;\n /** List what would be translated without calling the provider or writing files. */\n dryRun?: boolean;\n /** Overrides the provider from the config (used by tests). */\n provider?: TranslateProvider;\n /** Print machine-readable JSON instead of human output. */\n json?: boolean;\n}\n\nexport interface PendingTranslation {\n file: string;\n locale: string;\n key: string;\n source: string;\n /** Present after translation. */\n translated?: string;\n}\n\nexport interface TranslateResult {\n success: boolean;\n dryRun: boolean;\n pending: PendingTranslation[];\n translated: number;\n /** Translations rejected because they changed placeholders, or that could not be written. */\n rejected: string[];\n}\n\ninterface Task extends PendingTranslation {\n dict: ProjectDictionary;\n path: string[];\n}\n\nexport async function runTranslate(options: TranslateOptions = {}): Promise<TranslateResult> {\n const root = options.cwd || process.cwd();\n const project = await loadProject(root, options.config);\n const settings = project.config.translate;\n const provider = options.provider ?? settings?.provider;\n\n if (!provider && !options.dryRun) {\n throw new Error(\n \"No translate provider configured. Add `translate: { provider: claudeProvider() }` to dialex.config.ts \" +\n '(import it from \"@dialexjs/cli/translate\").',\n );\n }\n\n const source = options.source ?? settings?.sourceLocale ?? project.config.defaultLocale ?? \"en\";\n const everyLocale = new Set<string>(project.config.locales ?? []);\n for (const { df } of project.dictionaries) listLocales(df).forEach((l) => everyLocale.add(l));\n const targets = (options.locale?.length ? options.locale : [...everyLocale]).filter(\n (l) => l !== source,\n );\n\n // 1. Collect strings that are missing or still marked [TODO]\n const tasks: Task[] = [];\n for (const dict of project.dictionaries) {\n const sourceLeaves = listLeaves(dict.df, source).filter(\n (leaf) => leaf.kind === \"string\" && leaf.value !== undefined,\n );\n\n for (const locale of targets) {\n const existing = new Map(\n listLeaves(dict.df, locale).map((leaf) => [leaf.path.join(\"\\u0000\"), leaf]),\n );\n for (const leaf of sourceLeaves) {\n const current = existing.get(leaf.path.join(\"\\u0000\"));\n const needs =\n !current || (current.kind === \"string\" && current.value?.startsWith(TODO_PREFIX));\n if (needs) {\n tasks.push({\n dict,\n path: leaf.path,\n file: dict.rel,\n locale,\n key: toKey(dict.name, leaf.path),\n source: leaf.value!,\n });\n }\n }\n }\n }\n\n const quiet = options.json === true;\n\n const result: TranslateResult = {\n success: true,\n dryRun: options.dryRun === true,\n pending: tasks,\n translated: 0,\n rejected: [],\n };\n\n if (tasks.length === 0) {\n if (quiet) {\n console.log(JSON.stringify(result, null, 2));\n } else {\n logger.success(`Nothing to translate from \"${source}\".`);\n }\n return result;\n }\n\n if (options.dryRun) {\n if (quiet) {\n console.log(JSON.stringify(result, null, 2));\n } else {\n logger.info(\n `Would translate ${tasks.length} string${tasks.length === 1 ? \"\" : \"s\"} from \"${source}\":`,\n );\n for (const t of tasks) {\n logger.log(` ${pc.dim(t.locale)} ${t.key} ${pc.dim(JSON.stringify(t.source))}`);\n }\n }\n return result;\n }\n\n // 2. Translate per target locale, de-duplicating identical source strings\n const touched = new Set<ProjectDictionary>();\n for (const locale of targets) {\n const localeTasks = tasks.filter((t) => t.locale === locale);\n if (localeTasks.length === 0) continue;\n\n // Providers that cannot keep ICU plural/select structure intact never see those messages\n const sendable = provider!.supportsIcu\n ? localeTasks\n : localeTasks.filter((task) => {\n if (!isIcuStructured(task.source)) return true;\n result.rejected.push(\n `${locale}:${task.key} (provider does not support ICU plural/select messages)`,\n );\n return false;\n });\n if (sendable.length === 0) continue;\n\n const unique = [...new Set(sendable.map((t) => t.source))];\n if (!quiet) {\n logger.info(\n `Translating ${unique.length} string${unique.length === 1 ? \"\" : \"s\"} to \"${locale}\" with ${provider!.name ?? \"provider\"}...`,\n );\n }\n const translations = await provider!.translate(unique, source, locale);\n if (translations.length !== unique.length) {\n throw new Error(\n `Provider returned ${translations.length} translations for ${unique.length} strings.`,\n );\n }\n const byText = new Map(unique.map((text, i) => [text, translations[i]]));\n\n for (const task of sendable) {\n const translated = byText.get(task.source);\n if (typeof translated !== \"string\" || translated.trim() === \"\") {\n result.rejected.push(`${locale}:${task.key} (empty translation)`);\n continue;\n }\n if (!preservesPlaceholders(task.source, translated)) {\n result.rejected.push(`${locale}:${task.key} (placeholders changed)`);\n continue;\n }\n if (setString(task.dict.df, locale, task.path, translated) === \"skipped\") {\n result.rejected.push(`${locale}:${task.key} (not a text value)`);\n continue;\n }\n task.translated = translated;\n result.translated++;\n touched.add(task.dict);\n }\n }\n\n for (const dict of touched) await saveDictionaryFile(dict.df);\n\n if (result.rejected.length > 0) {\n result.success = false;\n }\n\n if (quiet) {\n console.log(JSON.stringify(result, null, 2));\n } else {\n logger.success(\n `Translated ${result.translated} of ${tasks.length} string${tasks.length === 1 ? \"\" : \"s\"}.`,\n );\n if (result.rejected.length > 0) {\n logger.warn(\n `${result.rejected.length} left unchanged: ${result.rejected.slice(0, 5).join(\"; \")}${result.rejected.length > 5 ? \"; ...\" : \"\"}`,\n );\n }\n }\n return result;\n}\n","#!/usr/bin/env node\n\nimport { Command } from \"commander\";\nimport { runGenerate } from \"./commands/generate.js\";\nimport { runInit } from \"./commands/init.js\";\nimport { logger } from \"./utils/logger.js\";\nimport { runCheck } from \"./commands/check.js\";\nimport { runExport } from \"./commands/export.js\";\nimport { runImport } from \"./commands/import.js\";\nimport { runTranslate } from \"./commands/translate.js\";\n\nconst program = new Command();\n\nprogram\n .name(\"dialex\")\n .description(\"Dialex CLI - High-performance, type-safe internationalization compiler and tooling\")\n .version(\"0.2.1\");\n\nprogram\n .command(\"generate\")\n .alias(\"gen\")\n .description(\"Generate standalone dictionary bundle and TypeScript declarations\")\n .option(\"-w, --watch\", \"Watch dictionary files for changes\")\n .option(\"-o, --output <path>\", \"Custom output file path for generated dictionaries\")\n .option(\"-c, --config <path>\", \"Custom config path\")\n .option(\"--json\", \"Print machine-readable JSON\")\n .action(async (opts) => {\n await runGenerate(opts);\n });\n\nprogram\n .command(\"init\")\n .description(\"Initialize Dialex in the current project\")\n .option(\n \"-f, --framework <framework>\",\n \"Target framework (hono, express, fastify, koa, nestjs, next, react)\",\n )\n .option(\"-d, --default-locale <locale>\", \"Default locale (e.g. en)\")\n .option(\"-l, --locales <locales>\", \"Comma-separated supported locales (e.g. en,tr)\")\n .option(\"-y, --yes\", \"Skip prompts and use defaults\")\n .option(\"--ai\", \"Configure AI agent support (.claude/skills, .mcp.json, AGENTS.md)\")\n .option(\"--no-ai\", \"Skip AI agent configuration\")\n .action(async (opts) => {\n await runInit(opts);\n });\n\nprogram\n .command(\"check\")\n .alias(\"lint\")\n .description(\"Verify dictionary key parity and locale completeness\")\n .option(\"-c, --config <path>\", \"Custom config path\")\n .option(\"--json\", \"Print machine-readable JSON\")\n .option(\"--github\", \"Print GitHub Actions annotations\")\n .option(\"--fix\", \"Insert missing keys marked with [TODO]\")\n .option(\"--src <globs...>\", \"Source globs to scan for dictionary references\")\n .action(async (opts) => {\n await runCheck(opts);\n });\n\nprogram\n .command(\"export\")\n .description(\"Export dictionary strings for translators (json, csv, or xliff)\")\n .option(\"-f, --format <format>\", \"Output format: json, csv, xliff\", \"json\")\n .option(\"-o, --out <dir>\", \"Output directory\", \"i18n-export\")\n .option(\"-l, --locale <locales...>\", \"Limit to these locales\")\n .option(\"-c, --config <path>\", \"Custom config path\")\n .option(\"--json\", \"Print machine-readable JSON\")\n .action(async (opts) => {\n await runExport(opts);\n });\n\nprogram\n .command(\"import <file>\")\n .description(\"Write translated strings from a json, csv, or xliff file back into dictionaries\")\n .option(\"-f, --format <format>\", \"Input format (inferred from the extension)\")\n .option(\"-l, --locale <locale>\", \"Locale for single-locale files\")\n .option(\"--allow-new\", \"Add keys that do not exist in any locale yet\")\n .option(\"-c, --config <path>\", \"Custom config path\")\n .option(\"--json\", \"Print machine-readable JSON\")\n .action(async (file, opts) => {\n await runImport({ file, ...opts });\n });\n\nprogram\n .command(\"translate\")\n .description(\"Fill missing translations with the provider configured in dialex.config.ts\")\n .option(\"-l, --locale <locales...>\", \"Target locales (default: all configured)\")\n .option(\n \"-s, --source <locale>\",\n \"Source locale (default: translate.sourceLocale or defaultLocale)\",\n )\n .option(\"--dry-run\", \"List what would be translated without calling the provider\")\n .option(\"-c, --config <path>\", \"Custom config path\")\n .option(\"--json\", \"Print machine-readable JSON\")\n .action(async (opts) => {\n try {\n await runTranslate(opts);\n } catch (err: any) {\n if (opts.json) {\n console.log(JSON.stringify({ success: false, error: err.message || String(err) }, null, 2));\n } else {\n logger.error(err.message || String(err));\n }\n process.exit(1);\n }\n });\n\nprogram.parse();\n"],"mappings":";;;;;;;;;;;;;;;;;AA2BA,SAAgB,gBAAgB,MAAiC;CAC/D,MAAM,UAAU,KAAK,KAAK,MAAM,cAAc;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EAAE,GAAG,MAAM,CAAC,CAAC;OAE1F,OAAO,MAAM,IAAI,WAAW,OAAO,GAAG,CAAC;EAEzC,QAAQ,KAAK,CAAC;CAChB;AACF,CAAC;AAEH,QAAQ,MAAM"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../src/utils/detector.ts","../src/commands/init.ts","../src/commands/check.ts","../src/commands/export.ts","../src/commands/import.ts","../src/translate/placeholders.ts","../src/commands/translate.ts","../src/index.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport path from \"node:path\";\n\nexport type SupportedFramework =\n | \"next\"\n | \"react\"\n | \"hono\"\n | \"express\"\n | \"fastify\"\n | \"koa\"\n | \"nestjs\"\n | \"elysia\"\n | \"sveltekit\"\n | \"astro\"\n | \"vue\"\n | \"nuxt\";\n\nexport interface DetectedFramework {\n framework: SupportedFramework;\n confidence: \"high\" | \"medium\" | \"fallback\";\n matchedRule: string;\n}\n\n/**\n * Automatically inspects package.json dependencies and configuration files\n * to detect the active framework in the target project.\n */\nexport function detectFramework(root: string): DetectedFramework {\n const pkgPath = path.join(root, \"package.json\");\n if (fs.existsSync(pkgPath)) {\n try {\n const pkg = JSON.parse(fs.readFileSync(pkgPath, \"utf-8\"));\n const allDeps = {\n ...pkg.dependencies,\n ...pkg.devDependencies,\n };\n\n if (\"nuxt\" in allDeps) {\n return {\n framework: \"nuxt\",\n confidence: \"high\",\n matchedRule: \"package.json dependencies (nuxt)\",\n };\n }\n if (\"@sveltejs/kit\" in allDeps) {\n return {\n framework: \"sveltekit\",\n confidence: \"high\",\n matchedRule: \"package.json dependencies (@sveltejs/kit)\",\n };\n }\n if (\"astro\" in allDeps) {\n return {\n framework: \"astro\",\n confidence: \"high\",\n matchedRule: \"package.json dependencies (astro)\",\n };\n }\n if (\"next\" in allDeps) {\n return {\n framework: \"next\",\n confidence: \"high\",\n matchedRule: \"package.json dependencies (next)\",\n };\n }\n if (\"@nestjs/core\" in allDeps || \"@nestjs/common\" in allDeps) {\n return {\n framework: \"nestjs\",\n confidence: \"high\",\n matchedRule: \"package.json dependencies (@nestjs/core)\",\n };\n }\n if (\"fastify\" in allDeps) {\n return {\n framework: \"fastify\",\n confidence: \"high\",\n matchedRule: \"package.json dependencies (fastify)\",\n };\n }\n if (\"koa\" in allDeps) {\n return {\n framework: \"koa\",\n confidence: \"high\",\n matchedRule: \"package.json dependencies (koa)\",\n };\n }\n if (\"express\" in allDeps) {\n return {\n framework: \"express\",\n confidence: \"high\",\n matchedRule: \"package.json dependencies (express)\",\n };\n }\n if (\"elysia\" in allDeps) {\n return {\n framework: \"elysia\",\n confidence: \"high\",\n matchedRule: \"package.json dependencies (elysia)\",\n };\n }\n if (\"hono\" in allDeps) {\n return {\n framework: \"hono\",\n confidence: \"high\",\n matchedRule: \"package.json dependencies (hono)\",\n };\n }\n if (\"vue\" in allDeps && !(\"react\" in allDeps)) {\n return {\n framework: \"vue\",\n confidence: \"high\",\n matchedRule: \"package.json dependencies (vue)\",\n };\n }\n if (\"react\" in allDeps || \"vite\" in allDeps) {\n return {\n framework: \"react\",\n confidence: \"high\",\n matchedRule: \"package.json dependencies (react/vite)\",\n };\n }\n } catch {\n // Ignore JSON parse errors\n }\n }\n\n // Check filesystem configurations\n if (\n fs.existsSync(path.join(root, \"next.config.js\")) ||\n fs.existsSync(path.join(root, \"next.config.mjs\")) ||\n fs.existsSync(path.join(root, \"next.config.ts\"))\n ) {\n return {\n framework: \"next\",\n confidence: \"medium\",\n matchedRule: \"next.config file presence\",\n };\n }\n\n const configRules: [SupportedFramework, string][] = [\n [\"nuxt\", \"nuxt.config\"],\n [\"sveltekit\", \"svelte.config\"],\n [\"astro\", \"astro.config\"],\n ];\n for (const [framework, base] of configRules) {\n if ([\"js\", \"mjs\", \"ts\"].some((ext) => fs.existsSync(path.join(root, `${base}.${ext}`)))) {\n return { framework, confidence: \"medium\", matchedRule: `${base} file presence` };\n }\n }\n\n if (\n fs.existsSync(path.join(root, \"vite.config.js\")) ||\n fs.existsSync(path.join(root, \"vite.config.mjs\")) ||\n fs.existsSync(path.join(root, \"vite.config.ts\"))\n ) {\n return {\n framework: \"react\",\n confidence: \"medium\",\n matchedRule: \"vite.config file presence\",\n };\n }\n\n return {\n framework: \"hono\",\n confidence: \"fallback\",\n matchedRule: \"default fallback\",\n };\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport * as p from \"@clack/prompts\";\nimport pc from \"picocolors\";\nimport { parseModule, loadFile, writeFile } from \"magicast\";\nimport { addNuxtModule, addVitePlugin } from \"magicast/helpers\";\nimport { generateDictionaries } from \"./generate.js\";\nimport { detectFramework, type SupportedFramework } from \"../utils/detector.js\";\nimport { logger } from \"../utils/logger.js\";\n\nexport interface InitOptions {\n cwd?: string;\n framework?: string;\n defaultLocale?: string;\n locales?: string;\n yes?: boolean;\n ai?: boolean;\n noAi?: boolean;\n}\n\nexport async function runInit(options: InitOptions = {}) {\n const root = options.cwd || process.cwd();\n const detected = detectFramework(root);\n const isInteractive = !options.yes && process.stdin.isTTY;\n\n let framework = (options.framework as SupportedFramework) || detected.framework;\n let defaultLocale = options.defaultLocale || \"en\";\n let localesInput = options.locales || \"en,tr\";\n\n if (isInteractive) {\n p.intro(pc.bgCyan(pc.black(\" dialex init \")));\n\n const frameworkOptions: { value: SupportedFramework; label: string; hint?: string }[] = [\n {\n value: \"hono\",\n label: \"Hono\",\n hint: detected.framework === \"hono\" ? \"detected\" : undefined,\n },\n {\n value: \"express\",\n label: \"Express\",\n hint: detected.framework === \"express\" ? \"detected\" : undefined,\n },\n {\n value: \"fastify\",\n label: \"Fastify\",\n hint: detected.framework === \"fastify\" ? \"detected\" : undefined,\n },\n {\n value: \"koa\",\n label: \"Koa\",\n hint: detected.framework === \"koa\" ? \"detected\" : undefined,\n },\n {\n value: \"nestjs\",\n label: \"NestJS\",\n hint: detected.framework === \"nestjs\" ? \"detected\" : undefined,\n },\n {\n value: \"next\",\n label: \"Next.js\",\n hint: detected.framework === \"next\" ? \"detected\" : undefined,\n },\n {\n value: \"react\",\n label: \"React / Vite\",\n hint: detected.framework === \"react\" ? \"detected\" : undefined,\n },\n {\n value: \"elysia\",\n label: \"Elysia\",\n hint: detected.framework === \"elysia\" ? \"detected\" : undefined,\n },\n {\n value: \"sveltekit\",\n label: \"SvelteKit\",\n hint: detected.framework === \"sveltekit\" ? \"detected\" : undefined,\n },\n {\n value: \"astro\",\n label: \"Astro\",\n hint: detected.framework === \"astro\" ? \"detected\" : undefined,\n },\n {\n value: \"vue\",\n label: \"Vue / Vite\",\n hint: detected.framework === \"vue\" ? \"detected\" : undefined,\n },\n {\n value: \"nuxt\",\n label: \"Nuxt\",\n hint: detected.framework === \"nuxt\" ? \"detected\" : undefined,\n },\n ];\n\n const selectedFramework = await p.select({\n message: `Framework detected as ${pc.bold(detected.framework)} (${detected.matchedRule}). Select framework:`,\n options: frameworkOptions,\n initialValue: detected.framework,\n });\n\n if (p.isCancel(selectedFramework)) {\n p.cancel(\"Operation cancelled.\");\n return;\n }\n framework = selectedFramework as SupportedFramework;\n\n const inputDefault = await p.text({\n message: \"What is your default locale?\",\n initialValue: \"en\",\n validate: (v) => (!v || !v.trim() ? \"Default locale cannot be empty\" : undefined),\n });\n\n if (p.isCancel(inputDefault)) {\n p.cancel(\"Operation cancelled.\");\n return;\n }\n defaultLocale = inputDefault.trim();\n\n const inputLocales = await p.text({\n message: \"Comma-separated list of supported locales:\",\n initialValue: `${defaultLocale},tr`,\n validate: (v) => (!v || !v.trim() ? \"Locales list cannot be empty\" : undefined),\n });\n\n if (p.isCancel(inputLocales)) {\n p.cancel(\"Operation cancelled.\");\n return;\n }\n localesInput = inputLocales.trim();\n\n if (options.ai === undefined && options.noAi === undefined) {\n const confirmAi = await p.confirm({\n message: \"Configure AI agent support (Claude/Cursor skills, .mcp.json, AGENTS.md)?\",\n initialValue: true,\n });\n if (!p.isCancel(confirmAi)) {\n options.ai = confirmAi;\n }\n }\n } else {\n logger.info(`Auto-detected framework: ${pc.bold(framework)} (${detected.matchedRule})`);\n }\n\n const localeList = Array.from(\n new Set([\n defaultLocale,\n ...localesInput\n .split(\",\")\n .map((s) => s.trim())\n .filter(Boolean),\n ]),\n );\n\n // 1. AST generation or update for dialex.config.ts / i18n.config.ts via Magicast\n const configPath = fs.existsSync(path.join(root, \"dialex.config.ts\"))\n ? path.join(root, \"dialex.config.ts\")\n : fs.existsSync(path.join(root, \"i18n.config.ts\"))\n ? path.join(root, \"i18n.config.ts\")\n : path.join(root, \"dialex.config.ts\");\n const configFileName = path.basename(configPath);\n\n try {\n if (fs.existsSync(configPath)) {\n const mod = await loadFile(configPath);\n if (mod && mod.exports.default) {\n if (mod.exports.default.$args && mod.exports.default.$args[0]) {\n mod.exports.default.$args[0].defaultLocale = defaultLocale;\n mod.exports.default.$args[0].locales = localeList;\n }\n await writeFile(mod, configPath);\n logger.success(`Updated ${pc.bold(configFileName)} via Magicast`);\n }\n } else {\n const mod = parseModule(`import { defineConfig } from \"dialexjs\";\n\nexport default defineConfig({});\n`);\n mod.exports.default.$args[0].defaultLocale = defaultLocale;\n mod.exports.default.$args[0].locales = localeList;\n await writeFile(mod, configPath);\n logger.success(`Created ${pc.bold(configFileName)} via Magicast`);\n }\n } catch (err: any) {\n logger.warn(`Magicast config update notice: ${err.message || String(err)}`);\n // Fallback safe string write if AST parser encounters non-standard syntax\n const fallback = `import { defineConfig } from \"dialexjs\";\n\nexport default defineConfig({\n defaultLocale: \"${defaultLocale}\",\n locales: [${localeList.map((l) => `\"${l}\"`).join(\", \")}],\n});\n`;\n fs.writeFileSync(configPath, fallback, \"utf-8\");\n }\n\n // 2. Magicast AST injection for Vite and Nuxt projects\n if (framework === \"react\" || framework === \"vue\") {\n const possibleViteConfigs = [\n path.join(root, \"vite.config.ts\"),\n path.join(root, \"vite.config.js\"),\n path.join(root, \"vite.config.mjs\"),\n ];\n for (const vConfig of possibleViteConfigs) {\n if (fs.existsSync(vConfig)) {\n try {\n const vMod = await loadFile(vConfig);\n addVitePlugin(vMod, {\n from: \"dialexjs/vite\",\n imported: \"i18nPlugin\",\n constructor: \"i18nPlugin\",\n });\n await writeFile(vMod, vConfig);\n logger.success(\n `Injected i18nPlugin() into ${pc.bold(path.basename(vConfig))} via Magicast`,\n );\n break;\n } catch {\n // If already added or non-standard, continue\n }\n }\n }\n }\n\n if (framework === \"nuxt\") {\n const nuxtConfig = [\"nuxt.config.ts\", \"nuxt.config.js\", \"nuxt.config.mjs\"]\n .map((f) => path.join(root, f))\n .find((f) => fs.existsSync(f));\n if (nuxtConfig) {\n try {\n const nMod = await loadFile(nuxtConfig);\n addNuxtModule(nMod, \"dialexjs/nuxt\", \"dialex\", {\n defaultLocale,\n locales: localeList,\n });\n await writeFile(nMod, nuxtConfig);\n logger.success(\n `Registered dialexjs/nuxt in ${pc.bold(path.basename(nuxtConfig))} via Magicast`,\n );\n } catch {\n logger.warn(\"Could not update the Nuxt config; add the dialexjs/nuxt module manually.\");\n }\n }\n }\n\n // 3. Create starter dictionary in src/ (or root)\n const targetDir = fs.existsSync(path.join(root, \"src\")) ? path.join(root, \"src\") : root;\n const dictPath = path.join(targetDir, \"home.content.ts\");\n if (!fs.existsSync(dictPath)) {\n const dictRecords = localeList\n .map(\n (loc) => ` ${loc}: {\n title: \"Welcome to Dialex (${loc})!\",\n description: \"Type-safe internationalization.\",\n greeting: (name: string) => \"Hello, \" + name + \"!\",\n },`,\n )\n .join(\"\\n\");\n\n const dictContent = `import { defineDictionary } from \"dialexjs\";\n\nexport default defineDictionary(\"home\", {\n${dictRecords}\n});\n`;\n fs.writeFileSync(dictPath, dictContent, \"utf-8\");\n logger.success(`Created starter dictionary at ${pc.bold(path.relative(root, dictPath))}`);\n } else {\n logger.info(\"home.content.ts already exists, skipping creation.\");\n }\n\n // 4. Run standalone dictionary generation immediately\n generateDictionaries(root);\n logger.success(\"Generated types and standalone dictionary registry!\");\n\n // 5. Update package.json scripts\n const pkgPath = path.join(root, \"package.json\");\n if (fs.existsSync(pkgPath)) {\n try {\n const pkg = JSON.parse(fs.readFileSync(pkgPath, \"utf-8\"));\n pkg.scripts = pkg.scripts || {};\n if (!pkg.scripts[\"dx:generate\"]) {\n pkg.scripts[\"dx:generate\"] = \"dx generate\";\n fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + \"\\n\", \"utf-8\");\n logger.success('Added \"dx:generate\" script to package.json');\n }\n } catch {\n // Ignore JSON parse errors\n }\n }\n\n // 6. AI Agent Integration (.agents/skills, .mcp.json, AGENTS.md)\n const shouldSetupAi =\n options.ai === true || (options.yes && options.ai !== false && options.noAi !== true);\n if (shouldSetupAi) {\n try {\n // 6a. Copy or create skill in .agents/skills/dialex/SKILL.md\n const skillDir = path.join(root, \".agents/skills/dialex\");\n fs.mkdirSync(skillDir, { recursive: true });\n const skillContent = `---\nname: dialex\ndescription: Guide for internationalizing JavaScript and TypeScript apps with Dialex. Use when adding translations, creating content dictionaries, configuring locales, or using Dialex with frameworks like Next.js, React, Express, Hono, Fastify, SvelteKit, and Nuxt.\n---\n\n# Dialex Internationalization\n\nDialex is a high-performance, type-safe internationalization toolchain for JavaScript and TypeScript.\n\n## Core Concepts\n- Dictionaries are defined with \\`defineDictionary(\"name\", { ... })\\` in \\`*.content.ts\\` files.\n- Keys must match across all locales.\n- ICU message syntax is supported for plurals and selects.\n- Parity is validated at compile time with \\`dialex check\\`.\n\n## Useful Commands\n- \\`dialex check --json\\`: Check dictionary parity and references.\n- \\`dialex check --fix\\`: Automatically insert missing keys marked with [TODO].\n- \\`dialex generate\\`: Rebuild standalone dictionary bundle and types.\n- \\`dialex translate --locale <locale>\\`: Automatically translate missing keys.\n`;\n fs.writeFileSync(path.join(skillDir, \"SKILL.md\"), skillContent, \"utf-8\");\n\n // 6b. Merge .mcp.json\n const mcpConfigPath = path.join(root, \".mcp.json\");\n let mcpConfig: Record<string, any> = {};\n if (fs.existsSync(mcpConfigPath)) {\n try {\n mcpConfig = JSON.parse(fs.readFileSync(mcpConfigPath, \"utf-8\"));\n } catch {\n mcpConfig = {};\n }\n }\n mcpConfig.mcpServers = mcpConfig.mcpServers || {};\n mcpConfig.mcpServers.dialex = mcpConfig.mcpServers.dialex || {\n command: \"npx\",\n args: [\"@dialexjs/mcp\"],\n };\n fs.writeFileSync(mcpConfigPath, JSON.stringify(mcpConfig, null, 2) + \"\\n\", \"utf-8\");\n\n // 6c. Add snippet to AGENTS.md if absent\n const agentsMdPath = path.join(root, \"AGENTS.md\");\n const dialexAgentSnippet = `\n## Internationalization (Dialex)\n\nThis project uses [Dialex](https://github.com/awaiden/dialex) for type-safe internationalization.\n- Dictionaries are in \\`*.content.ts\\` files using \\`defineDictionary\\`.\n- Run \\`dialex check --json\\` to verify parity.\n- Run \\`dialex check --fix\\` to insert missing keys marked with \\`[TODO]\\`.\n- Run \\`dx generate\\` (alias of \\`dialex\\`) or \\`npm run dx:generate\\` to compile dictionary bundles and update types.\n`;\n if (!fs.existsSync(agentsMdPath)) {\n fs.writeFileSync(agentsMdPath, dialexAgentSnippet.trimStart(), \"utf-8\");\n } else {\n const existing = fs.readFileSync(agentsMdPath, \"utf-8\");\n if (!existing.includes(\"Dialex\")) {\n fs.writeFileSync(agentsMdPath, existing.trimEnd() + \"\\n\" + dialexAgentSnippet, \"utf-8\");\n }\n }\n\n logger.success(\"Configured AI assistant support (.agents/skills, .mcp.json, AGENTS.md)\");\n } catch (err: any) {\n logger.warn(`Could not finish AI configuration: ${err.message || String(err)}`);\n }\n }\n\n // 7. Framework-specific quickstart instructions\n logger.log(\"\");\n logger.info(pc.bold(`Quick start for ${framework.toUpperCase()}:`));\n\n switch (framework) {\n case \"hono\":\n logger.log(`\nimport { Hono } from \"hono\";\nimport { i18n } from \"dialexjs/hono\";\nimport dictionaries from \"./src/dialex.generated.js\";\n\nconst app = new Hono();\napp.use(\"*\", i18n({ dictionaries }));\n\napp.get(\"/\", (c) => {\n const dict = c.var.getDictionary(\"home\");\n return c.json({ title: dict.title });\n});\n`);\n break;\n case \"fastify\":\n logger.log(`\nimport Fastify from \"fastify\";\nimport { i18nPlugin } from \"dialexjs/fastify\";\nimport dictionaries from \"./src/dialex.generated.js\";\n\nconst app = Fastify();\nawait app.register(i18nPlugin, { dictionaries });\n\napp.get(\"/\", (req) => {\n const dict = req.getDictionary(\"home\");\n return { title: dict.title };\n});\n`);\n break;\n case \"express\":\n logger.log(`\nimport express from \"express\";\nimport { i18n } from \"dialexjs/express\";\nimport dictionaries from \"./src/dialex.generated.js\";\n\nconst app = express();\napp.use(i18n({ dictionaries }));\n\napp.get(\"/\", (req, res) => {\n const dict = req.getDictionary(\"home\");\n res.json({ title: dict.title });\n});\n`);\n break;\n case \"koa\":\n logger.log(`\nimport Koa from \"koa\";\nimport { i18n } from \"dialexjs/koa\";\nimport dictionaries from \"./src/dialex.generated.js\";\n\nconst app = new Koa();\napp.use(i18n({ dictionaries }));\n\napp.use((ctx) => {\n const dict = ctx.getDictionary(\"home\");\n ctx.body = { title: dict.title };\n});\n`);\n break;\n case \"nestjs\":\n logger.log(`\nimport { Module } from \"@nestjs/common\";\nimport { I18nModule } from \"dialexjs/nestjs\";\nimport dictionaries from \"./src/dialex.generated.js\";\n\n@Module({\n imports: [I18nModule.forRoot({ dictionaries })],\n})\nexport class AppModule {}\n`);\n break;\n case \"next\":\n logger.log(`\nimport { getDictionary } from \"dialexjs/server\";\n\nexport default async function Page({ params }: { params: Promise<{ locale: string }> }) {\n const { locale = \"en\" } = await params;\n const dict = getDictionary(\"home\", locale);\n return <h1>{dict.title}</h1>;\n}\n`);\n break;\n case \"elysia\":\n logger.log(`\nimport { Elysia } from \"elysia\";\nimport { i18n } from \"dialexjs/elysia\";\nimport dictionaries from \"./src/dialex.generated.js\";\n\nnew Elysia()\n .use(i18n({ dictionaries }))\n .get(\"/\", ({ getDictionary }) => ({ title: getDictionary(\"home\").title }))\n .listen(3000);\n`);\n break;\n case \"sveltekit\":\n logger.log(`\n// src/hooks.server.ts\nimport { i18nHandle } from \"dialexjs/sveltekit\";\nimport dictionaries from \"./dialex.generated.js\";\n\nexport const handle = i18nHandle({ dictionaries });\n\n// src/app.html: <html lang=\"%dialex.lang%\">\n// In load functions: locals.getDictionary(\"home\")\n`);\n break;\n case \"astro\":\n logger.log(`\n// src/middleware.ts\nimport { i18n } from \"dialexjs/astro\";\nimport dictionaries from \"./dialex.generated.js\";\n\nexport const onRequest = i18n({ dictionaries });\n\n// In pages: Astro.locals.getDictionary(\"home\")\n`);\n break;\n case \"vue\":\n logger.log(`\n// src/main.ts\nimport { createApp } from \"vue\";\nimport { createI18n } from \"dialexjs/vue\";\nimport App from \"./App.vue\";\n\ncreateApp(App).use(createI18n()).mount(\"#app\");\n\n// In components: const dict = useDictionary(\"home\")\n`);\n break;\n case \"nuxt\":\n logger.log(`\n// nuxt.config.ts\nexport default defineNuxtConfig({\n modules: [\"dialexjs/nuxt\"],\n});\n\n// In components: const dict = useDictionary(\"home\")\n`);\n break;\n default:\n logger.log(`\nImport dictionaries and register your framework middleware to begin!\nRun \\`npm run dx:generate\\` whenever you add new dictionary files.\n`);\n break;\n }\n\n if (isInteractive) {\n p.outro(pc.green(\"✔ dialex is configured and ready to go!\"));\n }\n}\n","import path from \"node:path\";\nimport fg from \"fast-glob\";\nimport pc from \"picocolors\";\nimport { resolveI18nConfig } from \"dialexjs/scanner\";\nimport { analyzeProject, type AnalysisIssue } from \"../analysis.js\";\nimport { logger } from \"../utils/logger.js\";\nimport {\n TODO_PREFIX,\n copyLeaf,\n hasPath,\n listLeaves,\n listLocales,\n loadDictionaryFile,\n saveDictionaryFile,\n} from \"../utils/dictionary-edit.js\";\n\nexport interface CheckOptions {\n cwd?: string;\n config?: string;\n exitOnError?: boolean;\n /** Print machine-readable JSON instead of human output. */\n json?: boolean;\n /** Also print GitHub Actions workflow annotations. */\n github?: boolean;\n /** Insert missing keys (marked with `[TODO]`) before checking. */\n fix?: boolean;\n /** Globs of source files to scan for dictionary references. */\n src?: string[];\n}\n\nexport interface CheckAnnotation {\n level: \"error\" | \"warning\";\n message: string;\n line?: number;\n}\n\nexport interface CheckDiagnostic {\n file: string;\n name?: string;\n errors: string[];\n warnings: string[];\n annotations: CheckAnnotation[];\n}\n\nexport interface CheckResult {\n success: boolean;\n diagnostics: CheckDiagnostic[];\n totalIssues: number;\n totalWarnings: number;\n /** Number of missing keys inserted by `--fix`. */\n fixed: number;\n}\n\nconst DICTIONARY_IGNORE = [\"**/node_modules/**\", \"**/dist/**\", \"**/.next/**\"];\n\nfunction addIssue(diag: CheckDiagnostic, issue: AnalysisIssue) {\n const level = issue.level === \"error\" ? \"error\" : \"warning\";\n (level === \"error\" ? diag.errors : diag.warnings).push(issue.message);\n diag.annotations.push({\n level,\n message: issue.message,\n line: issue.range ? issue.range.start.line + 1 : undefined,\n });\n}\n\n/**\n * Inserts keys that exist in one locale but not in another, copying the default-locale value\n * (strings get a `[TODO]` prefix). Returns how many keys were inserted.\n */\nasync function applyFixes(\n files: string[],\n configuredLocales: string[],\n defaultLocale: string,\n): Promise<number> {\n let fixed = 0;\n\n for (const file of files) {\n const df = await loadDictionaryFile(file);\n // Spreads and computed keys hide keys from the syntax tree; inserting would be guesswork.\n if (!df?.complete) continue;\n\n const present = listLocales(df);\n const targets = Array.from(new Set([...present, ...configuredLocales]));\n const sourceOrder = [defaultLocale, ...present.filter((l) => l !== defaultLocale)].filter((l) =>\n present.includes(l),\n );\n\n const allPaths = new Map<string, string[]>();\n for (const locale of present) {\n for (const leaf of listLeaves(df, locale)) allPaths.set(leaf.path.join(\"\\u0000\"), leaf.path);\n }\n\n let changed = false;\n for (const target of targets) {\n for (const leafPath of allPaths.values()) {\n if (hasPath(df, target, leafPath)) continue;\n const source = sourceOrder.find((l) => l !== target && hasPath(df, l, leafPath));\n if (source && copyLeaf(df, source, target, leafPath, (v) => `${TODO_PREFIX}${v}`)) {\n fixed++;\n changed = true;\n }\n }\n }\n\n if (changed) await saveDictionaryFile(df);\n }\n\n return fixed;\n}\n\nfunction escapeAnnotation(value: string): string {\n return value.replace(/%/g, \"%25\").replace(/\\r/g, \"%0D\").replace(/\\n/g, \"%0A\");\n}\n\nexport async function runCheck(options: CheckOptions = {}): Promise<CheckResult> {\n const root = options.cwd || process.cwd();\n const quiet = options.json === true;\n const inlineConfig = options.config ? { configFile: options.config } : {};\n const config = resolveI18nConfig(root, inlineConfig);\n const include = config.include || \"**/*.content.ts\";\n const configuredLocales = config.locales || [];\n const defaultLocale = config.defaultLocale || \"en\";\n\n const files = fg.sync(include, { cwd: root, absolute: true, ignore: DICTIONARY_IGNORE });\n\n if (files.length === 0) {\n if (!quiet) {\n const patternStr = Array.isArray(include) ? include.join(\", \") : include;\n logger.warn(`No dictionary files found matching \"${patternStr}\".`);\n }\n const empty: CheckResult = {\n success: true,\n diagnostics: [],\n totalIssues: 0,\n totalWarnings: 0,\n fixed: 0,\n };\n if (quiet) console.log(JSON.stringify(empty, null, 2));\n return empty;\n }\n\n let fixed = 0;\n if (options.fix) {\n fixed = await applyFixes(files, configuredLocales, defaultLocale);\n if (fixed > 0 && !quiet) {\n logger.success(\n `Inserted ${fixed} missing key${fixed === 1 ? \"\" : \"s\"} marked ${TODO_PREFIX.trim()}`,\n );\n }\n }\n\n const analysis = await analyzeProject({\n root,\n config,\n src: options.src && options.src.length > 0 ? options.src : undefined,\n runtime: true,\n });\n\n // Group issues per file, dictionary files first (the analysis reports them first)\n const byFile = new Map<string, CheckDiagnostic>();\n const dictionaryFiles = new Set(analysis.files);\n for (const issue of analysis.issues) {\n if (issue.level === \"info\") continue;\n const rel = path.relative(root, issue.file);\n let diag = byFile.get(rel);\n if (!diag) {\n diag = { file: rel, errors: [], warnings: [], annotations: [] };\n byFile.set(rel, diag);\n }\n if (dictionaryFiles.has(issue.file) && issue.dictionary && !diag.name)\n diag.name = issue.dictionary;\n addIssue(diag, issue);\n }\n const diagnostics = [...byFile.values()];\n\n const totalIssues = diagnostics.reduce((n, d) => n + d.errors.length, 0);\n const totalWarnings = diagnostics.reduce((n, d) => n + d.warnings.length, 0);\n const reported = diagnostics.filter((d) => d.errors.length > 0 || d.warnings.length > 0);\n const result: CheckResult = {\n success: totalIssues === 0,\n diagnostics: reported,\n totalIssues,\n totalWarnings,\n fixed,\n };\n\n if (options.github) {\n for (const d of reported) {\n for (const a of d.annotations) {\n const location = `file=${d.file}${a.line ? `,line=${a.line}` : \"\"}`;\n console.log(`::${a.level} ${location},title=dialex::${escapeAnnotation(a.message)}`);\n }\n }\n }\n\n if (quiet) {\n console.log(JSON.stringify(result, null, 2));\n } else if (reported.length > 0) {\n logger.log(\"\");\n if (totalIssues > 0) {\n logger.error(\n `Found ${totalIssues} issue${totalIssues === 1 ? \"\" : \"s\"} across ${reported.filter((d) => d.errors.length > 0).length} file${reported.length === 1 ? \"\" : \"s\"}:`,\n );\n }\n logger.log(\"\");\n\n for (const d of reported) {\n logger.log(` ${pc.underline(pc.bold(d.file))} ${d.name ? pc.dim(`(${d.name})`) : \"\"}:`);\n for (const a of d.annotations) {\n const where = a.line ? pc.dim(`:${a.line}`) : \"\";\n const mark = a.level === \"error\" ? pc.red(\"✖\") : pc.yellow(\"⚠\");\n logger.log(` ${mark} ${a.message}${where}`);\n }\n logger.log(\"\");\n }\n }\n\n if (totalIssues > 0) {\n if (options.exitOnError !== false) process.exit(1);\n return result;\n }\n\n if (!quiet) {\n const warningNote =\n totalWarnings > 0 ? ` (${totalWarnings} warning${totalWarnings === 1 ? \"\" : \"s\"})` : \"\";\n logger.success(\n `All ${files.length} dictionary file${files.length === 1 ? \"\" : \"s\"} passed checks with 0 issues${warningNote}!`,\n );\n }\n return result;\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport { listLeaves, listLocales } from \"../utils/dictionary-edit.js\";\nimport { loadProject, toKey } from \"../utils/project.js\";\nimport { logger } from \"../utils/logger.js\";\n\nexport type TranslationFormat = \"json\" | \"csv\" | \"xliff\";\n\nexport interface ExportOptions {\n cwd?: string;\n config?: string;\n format?: TranslationFormat;\n /** Output directory, relative to `cwd`. */\n out?: string;\n /** Limit the export to these locales. */\n locale?: string[];\n /** Print machine-readable JSON instead of human output. */\n json?: boolean;\n}\n\nexport interface ExportResult {\n success: boolean;\n files: string[];\n keys: number;\n /** Function values cannot be exported as plain text. */\n skippedFunctions: number;\n skippedFiles: string[];\n}\n\nexport const escapeXml = (value: string) =>\n value.replace(/&/g, \"&\").replace(/</g, \"<\").replace(/>/g, \">\").replace(/\"/g, \""\");\n\nexport const csvCell = (value: string) =>\n /[\",\\r\\n]/.test(value) ? `\"${value.replace(/\"/g, '\"\"')}\"` : value;\n\nexport async function runExport(options: ExportOptions = {}): Promise<ExportResult> {\n const root = options.cwd || process.cwd();\n const format = options.format || \"json\";\n if (![\"json\", \"csv\", \"xliff\"].includes(format)) {\n throw new Error(`Unsupported format \"${format}\". Use json, csv, or xliff.`);\n }\n const outDir = path.resolve(root, options.out || \"i18n-export\");\n\n const project = await loadProject(root, options.config);\n const defaultLocale = project.config.defaultLocale || \"en\";\n\n // locale -> key -> value (insertion order = source order)\n const table = new Map<string, Map<string, string>>();\n const orderedKeys = new Set<string>();\n let skippedFunctions = 0;\n\n const localeSet = new Set<string>(project.config.locales || []);\n for (const { df } of project.dictionaries) listLocales(df).forEach((l) => localeSet.add(l));\n let locales = Array.from(localeSet);\n if (options.locale && options.locale.length > 0) {\n locales = locales.filter((l) => options.locale!.includes(l) || l === defaultLocale);\n }\n for (const locale of locales) table.set(locale, new Map());\n\n for (const { name, df } of project.dictionaries) {\n for (const locale of listLocales(df)) {\n if (!table.has(locale)) continue;\n for (const leaf of listLeaves(df, locale)) {\n if (leaf.kind === \"string\" && leaf.value !== undefined) {\n const key = toKey(name, leaf.path);\n table.get(locale)!.set(key, leaf.value);\n orderedKeys.add(key);\n } else if (locale === defaultLocale) {\n skippedFunctions++;\n }\n }\n }\n }\n\n fs.mkdirSync(outDir, { recursive: true });\n const files: string[] = [];\n const write = (name: string, content: string) => {\n const file = path.join(outDir, name);\n fs.writeFileSync(file, content, \"utf-8\");\n files.push(path.relative(root, file));\n };\n\n if (format === \"json\") {\n for (const [locale, values] of table) {\n write(`${locale}.json`, JSON.stringify(Object.fromEntries(values), null, 2) + \"\\n\");\n }\n } else if (format === \"csv\") {\n const header = [\"key\", ...table.keys()].map(csvCell).join(\",\");\n const rows = [...orderedKeys].map((key) =>\n [key, ...[...table.values()].map((v) => v.get(key) ?? \"\")].map(csvCell).join(\",\"),\n );\n write(\"translations.csv\", [header, ...rows].join(\"\\n\") + \"\\n\");\n } else {\n const source = table.get(defaultLocale);\n for (const [locale, values] of table) {\n if (locale === defaultLocale) continue;\n const units = [...orderedKeys].map((key) => {\n const src = source?.get(key) ?? \"\";\n const target = values.get(key);\n const targetXml = target === undefined ? \"\" : `<target>${escapeXml(target)}</target>`;\n return ` <trans-unit id=\"${escapeXml(key)}\"><source>${escapeXml(src)}</source>${targetXml}</trans-unit>`;\n });\n write(\n `${locale}.xlf`,\n `<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<xliff version=\"1.2\" xmlns=\"urn:oasis:names:tc:xliff:document:1.2\">\n <file original=\"dialex\" source-language=\"${escapeXml(defaultLocale)}\" target-language=\"${escapeXml(locale)}\" datatype=\"plaintext\">\n <body>\n${units.join(\"\\n\")}\n </body>\n </file>\n</xliff>\n`,\n );\n }\n }\n\n const quiet = options.json === true;\n\n const result: ExportResult = {\n success: true,\n files,\n keys: orderedKeys.size,\n skippedFunctions,\n skippedFiles: project.unsupported,\n };\n\n if (quiet) {\n console.log(JSON.stringify(result, null, 2));\n } else {\n logger.success(\n `Exported ${orderedKeys.size} key${orderedKeys.size === 1 ? \"\" : \"s\"} to ${files.length} ${format} file${files.length === 1 ? \"\" : \"s\"} in ${path.relative(root, outDir) || \".\"}`,\n );\n if (skippedFunctions > 0) {\n logger.warn(\n `${skippedFunctions} function value${skippedFunctions === 1 ? \"\" : \"s\"} skipped (not translatable as text)`,\n );\n }\n for (const file of project.unsupported)\n logger.warn(`Skipped ${file}: unsupported dictionary shape`);\n }\n\n return result;\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport {\n getString,\n hasPath,\n listLocales,\n saveDictionaryFile,\n setString,\n} from \"../utils/dictionary-edit.js\";\nimport { argumentSignature, parseMessage } from \"dialexjs/icu\";\nimport { loadProject } from \"../utils/project.js\";\nimport { logger } from \"../utils/logger.js\";\nimport type { TranslationFormat } from \"./export.js\";\n\nexport interface ImportOptions {\n cwd?: string;\n config?: string;\n /** File to import (`.json`, `.csv`, or `.xlf`/`.xliff`). */\n file: string;\n format?: TranslationFormat;\n /** Locale for single-locale files. Defaults to the file name (`tr.json`) or XLIFF target language. */\n locale?: string;\n /** Allow keys that do not exist in any locale yet. */\n allowNew?: boolean;\n /** Print machine-readable JSON instead of human output. */\n json?: boolean;\n}\n\nexport interface ImportEntry {\n locale: string;\n key: string;\n value: string;\n}\n\nexport interface ImportResult {\n success: boolean;\n created: number;\n updated: number;\n /** Function/non-text values that cannot be overwritten. */\n skipped: string[];\n /** Values refused because they are invalid ICU or change the message arguments. */\n rejected: string[];\n unknown: string[];\n errors: string[];\n}\n\nconst unescapeXml = (value: string) =>\n value\n .replace(/</g, \"<\")\n .replace(/>/g, \">\")\n .replace(/"/g, '\"')\n .replace(/'/g, \"'\")\n .replace(/&/g, \"&\");\n\nexport function parseCsv(text: string): string[][] {\n const rows: string[][] = [];\n let row: string[] = [];\n let cell = \"\";\n let quoted = false;\n\n for (let i = 0; i < text.length; i++) {\n const ch = text[i];\n if (quoted) {\n if (ch === '\"' && text[i + 1] === '\"') {\n cell += '\"';\n i++;\n } else if (ch === '\"') {\n quoted = false;\n } else {\n cell += ch;\n }\n } else if (ch === '\"') {\n quoted = true;\n } else if (ch === \",\") {\n row.push(cell);\n cell = \"\";\n } else if (ch === \"\\n\" || ch === \"\\r\") {\n if (ch === \"\\r\" && text[i + 1] === \"\\n\") i++;\n row.push(cell);\n rows.push(row);\n row = [];\n cell = \"\";\n } else {\n cell += ch;\n }\n }\n if (cell !== \"\" || row.length > 0) {\n row.push(cell);\n rows.push(row);\n }\n return rows.filter((r) => r.some((c) => c !== \"\"));\n}\n\nexport function parseEntries(\n content: string,\n format: TranslationFormat,\n fallbackLocale: string | undefined,\n): ImportEntry[] {\n const entries: ImportEntry[] = [];\n\n if (format === \"json\") {\n const data = JSON.parse(content) as Record<string, unknown>;\n const isNested =\n Object.keys(data).length > 0 &&\n Object.values(data).every((v) => v && typeof v === \"object\" && !Array.isArray(v));\n if (isNested) {\n for (const [locale, values] of Object.entries(data)) {\n for (const [key, value] of Object.entries(values as Record<string, unknown>)) {\n if (typeof value === \"string\") entries.push({ locale, key, value });\n }\n }\n } else {\n if (!fallbackLocale) throw new Error(\"Cannot infer the locale; pass --locale.\");\n for (const [key, value] of Object.entries(data)) {\n if (typeof value === \"string\") entries.push({ locale: fallbackLocale, key, value });\n }\n }\n } else if (format === \"csv\") {\n const [header, ...rows] = parseCsv(content);\n if (!header || header[0] !== \"key\") throw new Error('CSV must start with a \"key\" column.');\n for (const row of rows) {\n header.slice(1).forEach((locale, i) => {\n const value = row[i + 1];\n if (value !== undefined && value !== \"\") entries.push({ locale, key: row[0], value });\n });\n }\n } else {\n const locale = /target-language=\"([^\"]*)\"/.exec(content)?.[1] ?? fallbackLocale;\n if (!locale) throw new Error(\"Cannot infer the locale; pass --locale.\");\n const unit = /<trans-unit\\b[^>]*\\bid=\"([^\"]*)\"[^>]*>([\\s\\S]*?)<\\/trans-unit>/g;\n for (const match of content.matchAll(unit)) {\n const target = /<target\\b[^>]*>([\\s\\S]*?)<\\/target>/.exec(match[2])?.[1];\n if (target !== undefined && target !== \"\") {\n entries.push({ locale, key: unescapeXml(match[1]), value: unescapeXml(target) });\n }\n }\n }\n\n return entries;\n}\n\nfunction inferFormat(file: string): TranslationFormat {\n const ext = path.extname(file).toLowerCase();\n if (ext === \".json\") return \"json\";\n if (ext === \".csv\") return \"csv\";\n if (ext === \".xlf\" || ext === \".xliff\") return \"xliff\";\n throw new Error(`Cannot infer format from \"${ext}\". Pass --format json|csv|xliff.`);\n}\n\n/**\n * Why `value` must not replace the current text, if it is an ICU message that is invalid or uses\n * different arguments than the same key in another locale.\n */\nfunction icuProblem(\n df: Parameters<typeof getString>[0],\n defaultLocale: string,\n locale: string,\n keyPath: string[],\n value: string,\n): string | undefined {\n if (!value.includes(\"{\")) return undefined;\n\n let signature: string;\n try {\n signature = argumentSignature(parseMessage(value));\n } catch (error) {\n return `invalid ICU: ${(error as Error).message}`;\n }\n\n const locales = listLocales(df);\n for (const other of [defaultLocale, ...locales.filter((l) => l !== defaultLocale)]) {\n if (other === locale) continue;\n const reference = getString(df, other, keyPath);\n if (!reference?.includes(\"{\")) continue;\n try {\n const expected = argumentSignature(parseMessage(reference));\n return expected === signature\n ? undefined\n : `arguments differ from \"${other}\": expected ${expected || \"none\"}, found ${signature || \"none\"}`;\n } catch {\n continue;\n }\n }\n return undefined;\n}\n\nexport async function runImport(options: ImportOptions): Promise<ImportResult> {\n const root = options.cwd || process.cwd();\n const file = path.resolve(root, options.file);\n const format = options.format || inferFormat(file);\n const fallbackLocale = options.locale ?? path.basename(file, path.extname(file));\n\n const entries = parseEntries(\n fs.readFileSync(file, \"utf-8\"),\n format,\n options.locale ?? fallbackLocale,\n );\n const project = await loadProject(root, options.config);\n const byName = new Map(project.dictionaries.map((d) => [d.name, d]));\n\n const quiet = options.json === true;\n const result: ImportResult = {\n success: true,\n created: 0,\n updated: 0,\n skipped: [],\n rejected: [],\n unknown: [],\n errors: [],\n };\n const touched = new Set<string>();\n\n for (const { locale, key, value } of entries) {\n const [name, ...keyPath] = key.split(\".\");\n const dict = byName.get(name);\n if (!dict || keyPath.length === 0) {\n result.unknown.push(key);\n continue;\n }\n\n const exists = listLocales(dict.df).some((l) => hasPath(dict.df, l, keyPath));\n if (!exists && !options.allowNew) {\n result.unknown.push(key);\n continue;\n }\n\n const problem = icuProblem(\n dict.df,\n project.config.defaultLocale ?? \"en\",\n locale,\n keyPath,\n value,\n );\n if (problem) {\n result.rejected.push(`${locale}:${key} (${problem})`);\n continue;\n }\n\n const outcome = setString(dict.df, locale, keyPath, value);\n if (outcome === \"skipped\") {\n result.skipped.push(`${locale}:${key}`);\n } else {\n result[outcome]++;\n touched.add(dict.rel);\n }\n }\n\n for (const dict of project.dictionaries) {\n if (touched.has(dict.rel)) await saveDictionaryFile(dict.df);\n }\n\n if (result.rejected.length > 0) {\n result.success = false;\n }\n\n if (quiet) {\n console.log(JSON.stringify(result, null, 2));\n } else {\n logger.success(\n `Imported ${result.created + result.updated} value${result.created + result.updated === 1 ? \"\" : \"s\"} (${result.created} added, ${result.updated} updated)`,\n );\n if (result.unknown.length > 0) {\n logger.warn(\n `${result.unknown.length} unknown key${result.unknown.length === 1 ? \"\" : \"s\"} ignored (use --allow-new to add): ${result.unknown.slice(0, 5).join(\", \")}${result.unknown.length > 5 ? \", ...\" : \"\"}`,\n );\n }\n if (result.rejected.length > 0) {\n logger.warn(\n `${result.rejected.length} value${result.rejected.length === 1 ? \"\" : \"s\"} rejected: ${result.rejected.slice(0, 5).join(\"; \")}`,\n );\n }\n if (result.skipped.length > 0) {\n logger.warn(\n `${result.skipped.length} non-text value${result.skipped.length === 1 ? \"\" : \"s\"} left unchanged: ${result.skipped.slice(0, 5).join(\", \")}`,\n );\n }\n }\n\n return result;\n}\n","import { getArguments, isIcuStructured, parseMessage } from \"dialexjs/icu\";\n\n/** `{name}`, `%s` / `%1$d`, and HTML/XML tags: text that must survive translation unchanged. */\nconst PLACEHOLDER = /\\{[^{}]+\\}|%\\d*\\$?[sdif]|<\\/?[A-Za-z][^<>]*>/g;\n\nexport function extractPlaceholders(text: string): string[] {\n return text.match(PLACEHOLDER) ?? [];\n}\n\n/**\n * ICU plural/select messages put translatable text inside `{...}` branches, so brace matching\n * is meaningless for them. Compare the structure instead: the same arguments with the same\n * types, every `select` key and every exact `=N` plural match preserved. A translation may\n * add or drop plural categories (`one`, `few`, ...), because languages need different ones.\n */\nfunction preservesIcuStructure(source: string, translated: string): boolean {\n try {\n const before = getArguments(parseMessage(source));\n const after = getArguments(parseMessage(translated));\n const sameArguments =\n before.length === after.length &&\n before.every((a) => after.some((b) => a.name === b.name && a.type === b.type));\n if (!sameArguments) return false;\n\n return before.every((a) => {\n const other = after.find((b) => b.name === a.name && b.type === a.type)!;\n const keep =\n a.type === \"select\"\n ? (a.selectors ?? [])\n : (a.selectors ?? []).filter((selector) => selector.startsWith(\"=\"));\n return keep.every((selector) => other.selectors?.includes(selector));\n });\n } catch {\n return false;\n }\n}\n\n/** True when every placeholder of `source` appears in `translated` (as many times as in the source). */\nexport function preservesPlaceholders(source: string, translated: string): boolean {\n if (isIcuStructured(source)) return preservesIcuStructure(source, translated);\n\n const remaining = extractPlaceholders(translated);\n for (const placeholder of extractPlaceholders(source)) {\n const index = remaining.indexOf(placeholder);\n if (index === -1) return false;\n remaining.splice(index, 1);\n }\n return true;\n}\n","import pc from \"picocolors\";\nimport type { TranslateProvider } from \"dialexjs\";\nimport {\n TODO_PREFIX,\n listLeaves,\n listLocales,\n saveDictionaryFile,\n setString,\n} from \"../utils/dictionary-edit.js\";\nimport { loadProject, toKey, type ProjectDictionary } from \"../utils/project.js\";\nimport { isIcuStructured } from \"dialexjs/icu\";\nimport { preservesPlaceholders } from \"../translate/placeholders.js\";\nimport { logger } from \"../utils/logger.js\";\n\nexport interface TranslateOptions {\n cwd?: string;\n config?: string;\n /** Target locales. Defaults to every configured locale except the source. */\n locale?: string[];\n /** Locale to translate from. Defaults to `translate.sourceLocale`, then `defaultLocale`. */\n source?: string;\n /** List what would be translated without calling the provider or writing files. */\n dryRun?: boolean;\n /** Overrides the provider from the config (used by tests). */\n provider?: TranslateProvider;\n /** Print machine-readable JSON instead of human output. */\n json?: boolean;\n}\n\nexport interface PendingTranslation {\n file: string;\n locale: string;\n key: string;\n source: string;\n /** Present after translation. */\n translated?: string;\n}\n\nexport interface TranslateResult {\n success: boolean;\n dryRun: boolean;\n pending: PendingTranslation[];\n translated: number;\n /** Translations rejected because they changed placeholders, or that could not be written. */\n rejected: string[];\n}\n\ninterface Task extends PendingTranslation {\n dict: ProjectDictionary;\n path: string[];\n}\n\nexport async function runTranslate(options: TranslateOptions = {}): Promise<TranslateResult> {\n const root = options.cwd || process.cwd();\n const project = await loadProject(root, options.config);\n const settings = project.config.translate;\n const provider = options.provider ?? settings?.provider;\n\n if (!provider && !options.dryRun) {\n throw new Error(\n \"No translate provider configured. Add `translate: { provider: claudeProvider() }` to dialex.config.ts \" +\n '(import it from \"@dialexjs/cli/translate\").',\n );\n }\n\n const source = options.source ?? settings?.sourceLocale ?? project.config.defaultLocale ?? \"en\";\n const everyLocale = new Set<string>(project.config.locales ?? []);\n for (const { df } of project.dictionaries) listLocales(df).forEach((l) => everyLocale.add(l));\n const targets = (options.locale?.length ? options.locale : [...everyLocale]).filter(\n (l) => l !== source,\n );\n\n // 1. Collect strings that are missing or still marked [TODO]\n const tasks: Task[] = [];\n for (const dict of project.dictionaries) {\n const sourceLeaves = listLeaves(dict.df, source).filter(\n (leaf) => leaf.kind === \"string\" && leaf.value !== undefined,\n );\n\n for (const locale of targets) {\n const existing = new Map(\n listLeaves(dict.df, locale).map((leaf) => [leaf.path.join(\"\\u0000\"), leaf]),\n );\n for (const leaf of sourceLeaves) {\n const current = existing.get(leaf.path.join(\"\\u0000\"));\n const needs =\n !current || (current.kind === \"string\" && current.value?.startsWith(TODO_PREFIX));\n if (needs) {\n tasks.push({\n dict,\n path: leaf.path,\n file: dict.rel,\n locale,\n key: toKey(dict.name, leaf.path),\n source: leaf.value!,\n });\n }\n }\n }\n }\n\n const quiet = options.json === true;\n\n const result: TranslateResult = {\n success: true,\n dryRun: options.dryRun === true,\n pending: tasks,\n translated: 0,\n rejected: [],\n };\n\n if (tasks.length === 0) {\n if (quiet) {\n console.log(JSON.stringify(result, null, 2));\n } else {\n logger.success(`Nothing to translate from \"${source}\".`);\n }\n return result;\n }\n\n if (options.dryRun) {\n if (quiet) {\n console.log(JSON.stringify(result, null, 2));\n } else {\n logger.info(\n `Would translate ${tasks.length} string${tasks.length === 1 ? \"\" : \"s\"} from \"${source}\":`,\n );\n for (const t of tasks) {\n logger.log(` ${pc.dim(t.locale)} ${t.key} ${pc.dim(JSON.stringify(t.source))}`);\n }\n }\n return result;\n }\n\n // 2. Translate per target locale, de-duplicating identical source strings\n const touched = new Set<ProjectDictionary>();\n for (const locale of targets) {\n const localeTasks = tasks.filter((t) => t.locale === locale);\n if (localeTasks.length === 0) continue;\n\n // Providers that cannot keep ICU plural/select structure intact never see those messages\n const sendable = provider!.supportsIcu\n ? localeTasks\n : localeTasks.filter((task) => {\n if (!isIcuStructured(task.source)) return true;\n result.rejected.push(\n `${locale}:${task.key} (provider does not support ICU plural/select messages)`,\n );\n return false;\n });\n if (sendable.length === 0) continue;\n\n const unique = [...new Set(sendable.map((t) => t.source))];\n if (!quiet) {\n logger.info(\n `Translating ${unique.length} string${unique.length === 1 ? \"\" : \"s\"} to \"${locale}\" with ${provider!.name ?? \"provider\"}...`,\n );\n }\n const translations = await provider!.translate(unique, source, locale);\n if (translations.length !== unique.length) {\n throw new Error(\n `Provider returned ${translations.length} translations for ${unique.length} strings.`,\n );\n }\n const byText = new Map(unique.map((text, i) => [text, translations[i]]));\n\n for (const task of sendable) {\n const translated = byText.get(task.source);\n if (typeof translated !== \"string\" || translated.trim() === \"\") {\n result.rejected.push(`${locale}:${task.key} (empty translation)`);\n continue;\n }\n if (!preservesPlaceholders(task.source, translated)) {\n result.rejected.push(`${locale}:${task.key} (placeholders changed)`);\n continue;\n }\n if (setString(task.dict.df, locale, task.path, translated) === \"skipped\") {\n result.rejected.push(`${locale}:${task.key} (not a text value)`);\n continue;\n }\n task.translated = translated;\n result.translated++;\n touched.add(task.dict);\n }\n }\n\n for (const dict of touched) await saveDictionaryFile(dict.df);\n\n if (result.rejected.length > 0) {\n result.success = false;\n }\n\n if (quiet) {\n console.log(JSON.stringify(result, null, 2));\n } else {\n logger.success(\n `Translated ${result.translated} of ${tasks.length} string${tasks.length === 1 ? \"\" : \"s\"}.`,\n );\n if (result.rejected.length > 0) {\n logger.warn(\n `${result.rejected.length} left unchanged: ${result.rejected.slice(0, 5).join(\"; \")}${result.rejected.length > 5 ? \"; ...\" : \"\"}`,\n );\n }\n }\n return result;\n}\n","#!/usr/bin/env node\n\nimport { Command } from \"commander\";\nimport { runGenerate } from \"./commands/generate.js\";\nimport { runInit } from \"./commands/init.js\";\nimport { logger } from \"./utils/logger.js\";\nimport { runCheck } from \"./commands/check.js\";\nimport { runExport } from \"./commands/export.js\";\nimport { runImport } from \"./commands/import.js\";\nimport { runTranslate } from \"./commands/translate.js\";\n\nconst program = new Command();\n\nprogram\n .name(\"dialex\")\n .description(\"Dialex CLI - High-performance, type-safe internationalization compiler and tooling\")\n .version(\"0.2.3\");\n\nprogram\n .command(\"generate\")\n .alias(\"gen\")\n .description(\"Generate standalone dictionary bundle and TypeScript declarations\")\n .option(\"-w, --watch\", \"Watch dictionary files for changes\")\n .option(\"-o, --output <path>\", \"Custom output file path for generated dictionaries\")\n .option(\"-c, --config <path>\", \"Custom config path\")\n .option(\"--json\", \"Print machine-readable JSON\")\n .action(async (opts) => {\n await runGenerate(opts);\n });\n\nprogram\n .command(\"init\")\n .description(\"Initialize Dialex in the current project\")\n .option(\n \"-f, --framework <framework>\",\n \"Target framework (hono, express, fastify, koa, nestjs, next, react)\",\n )\n .option(\"-d, --default-locale <locale>\", \"Default locale (e.g. en)\")\n .option(\"-l, --locales <locales>\", \"Comma-separated supported locales (e.g. en,tr)\")\n .option(\"-y, --yes\", \"Skip prompts and use defaults\")\n .option(\"--ai\", \"Configure AI agent support (.agents/skills, .mcp.json, AGENTS.md)\")\n .option(\"--no-ai\", \"Skip AI agent configuration\")\n .action(async (opts) => {\n await runInit(opts);\n });\n\nprogram\n .command(\"check\")\n .alias(\"lint\")\n .description(\"Verify dictionary key parity and locale completeness\")\n .option(\"-c, --config <path>\", \"Custom config path\")\n .option(\"--json\", \"Print machine-readable JSON\")\n .option(\"--github\", \"Print GitHub Actions annotations\")\n .option(\"--fix\", \"Insert missing keys marked with [TODO]\")\n .option(\"--src <globs...>\", \"Source globs to scan for dictionary references\")\n .action(async (opts) => {\n await runCheck(opts);\n });\n\nprogram\n .command(\"export\")\n .description(\"Export dictionary strings for translators (json, csv, or xliff)\")\n .option(\"-f, --format <format>\", \"Output format: json, csv, xliff\", \"json\")\n .option(\"-o, --out <dir>\", \"Output directory\", \"i18n-export\")\n .option(\"-l, --locale <locales...>\", \"Limit to these locales\")\n .option(\"-c, --config <path>\", \"Custom config path\")\n .option(\"--json\", \"Print machine-readable JSON\")\n .action(async (opts) => {\n await runExport(opts);\n });\n\nprogram\n .command(\"import <file>\")\n .description(\"Write translated strings from a json, csv, or xliff file back into dictionaries\")\n .option(\"-f, --format <format>\", \"Input format (inferred from the extension)\")\n .option(\"-l, --locale <locale>\", \"Locale for single-locale files\")\n .option(\"--allow-new\", \"Add keys that do not exist in any locale yet\")\n .option(\"-c, --config <path>\", \"Custom config path\")\n .option(\"--json\", \"Print machine-readable JSON\")\n .action(async (file, opts) => {\n await runImport({ file, ...opts });\n });\n\nprogram\n .command(\"translate\")\n .description(\"Fill missing translations with the provider configured in dialex.config.ts\")\n .option(\"-l, --locale <locales...>\", \"Target locales (default: all configured)\")\n .option(\n \"-s, --source <locale>\",\n \"Source locale (default: translate.sourceLocale or defaultLocale)\",\n )\n .option(\"--dry-run\", \"List what would be translated without calling the provider\")\n .option(\"-c, --config <path>\", \"Custom config path\")\n .option(\"--json\", \"Print machine-readable JSON\")\n .action(async (opts) => {\n try {\n await runTranslate(opts);\n } catch (err: any) {\n if (opts.json) {\n console.log(JSON.stringify({ success: false, error: err.message || String(err) }, null, 2));\n } else {\n logger.error(err.message || String(err));\n }\n process.exit(1);\n }\n });\n\nprogram.parse();\n"],"mappings":";;;;;;;;;;;;;;;;;AA2BA,SAAgB,gBAAgB,MAAiC;CAC/D,MAAM,UAAU,KAAK,KAAK,MAAM,cAAc;CAC9C,IAAI,GAAG,WAAW,OAAO,GACvB,IAAI;EACF,MAAM,MAAM,KAAK,MAAM,GAAG,aAAa,SAAS,OAA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AAC;CAChB;AACF,CAAC;AAEH,QAAQ,MAAM"}
|
|
@@ -31,7 +31,7 @@ function generateDictionaries(root, options = {}) {
|
|
|
31
31
|
]
|
|
32
32
|
});
|
|
33
33
|
const srcDir = fs.existsSync(path.join(root, "src")) ? path.join(root, "src") : root;
|
|
34
|
-
const targetOutput = options.output ? path.resolve(root, options.output) : path.join(srcDir, "
|
|
34
|
+
const targetOutput = options.output ? path.resolve(root, options.output) : path.join(srcDir, "dialex.generated.ts");
|
|
35
35
|
const targetDir = path.dirname(targetOutput);
|
|
36
36
|
generateDts(root, files, config.locales);
|
|
37
37
|
const dtsPath = path.join(srcDir, "dialex-env.d.ts");
|
|
@@ -475,7 +475,7 @@ const SOURCE_IGNORE = [
|
|
|
475
475
|
"**/coverage/**",
|
|
476
476
|
"**/graphify-out/**",
|
|
477
477
|
"**/*.d.ts",
|
|
478
|
-
"**/
|
|
478
|
+
"**/dialex.generated.*",
|
|
479
479
|
"**/dialex.config.*",
|
|
480
480
|
"**/i18n.config.*"
|
|
481
481
|
];
|
|
@@ -989,4 +989,4 @@ const toKey = (dictionary, keyPath) => [dictionary, ...keyPath].join(".");
|
|
|
989
989
|
//#endregion
|
|
990
990
|
export { saveDictionaryFile as C, logger as D, runGenerate as E, renderDictionaryFile as S, generateDictionaries as T, listLeaves as _, parseStaticConfig as a, locationOf as b, analyzeProject as c, TODO_PREFIX as d, copyLeaf as f, hasPath as g, getString as h, DEFAULT_STATIC_CONFIG as i, relativeFile as l, getLeafSource as m, loadStaticProject as n, readStaticConfig as o, dictionaryLocation as p, toKey as r, DEFAULT_SOURCE_GLOB as s, loadProject as t, scanReferences as u, listLocales as v, setString as w, parseDictionaryText as x, loadDictionaryFile as y };
|
|
991
991
|
|
|
992
|
-
//# sourceMappingURL=project-
|
|
992
|
+
//# sourceMappingURL=project-BnG6V2I0.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project-BnG6V2I0.mjs","names":["unwrapNode","propertyKeyName","isObjectNode","findProperty"],"sources":["../src/utils/logger.ts","../src/commands/generate.ts","../src/utils/dictionary-edit.ts","../src/utils/icu-check.ts","../src/analysis.ts","../src/utils/static-config.ts","../src/utils/project.ts"],"sourcesContent":["import pc from \"picocolors\";\n\nexport const logger = {\n info: (msg: string) => console.log(pc.blue(\"ℹ \") + msg),\n success: (msg: string) => console.log(pc.green(\"✔ \") + pc.bold(msg)),\n warn: (msg: string) => console.warn(pc.yellow(\"⚠ \") + msg),\n error: (msg: string) => console.error(pc.red(\"✖ \") + pc.bold(msg)),\n log: (msg: string) => console.log(msg),\n};\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport fg from \"fast-glob\";\nimport chokidar from \"chokidar\";\nimport { resolveI18nConfig, generateDts } from \"dialexjs/scanner\";\nimport { logger } from \"../utils/logger.js\";\n\nexport interface GenerateOptions {\n cwd?: string;\n watch?: boolean;\n output?: string;\n config?: string;\n json?: boolean;\n}\n\nexport function generateDictionaries(\n root: string,\n options: GenerateOptions = {},\n): {\n files: string[];\n outputPath: string;\n dtsPath: string;\n} {\n const inlineConfig = options.config ? { configFile: options.config } : {};\n const config = resolveI18nConfig(root, inlineConfig);\n const include = config.include || \"**/*.content.ts\";\n\n const files = fg.sync(include, {\n cwd: root,\n absolute: true,\n ignore: [\"**/node_modules/**\", \"**/dist/**\", \"**/.next/**\"],\n });\n\n const srcDir = fs.existsSync(path.join(root, \"src\")) ? path.join(root, \"src\") : root;\n const targetOutput = options.output\n ? path.resolve(root, options.output)\n : path.join(srcDir, \"dialex.generated.ts\");\n\n const targetDir = path.dirname(targetOutput);\n\n // 1. Generate TypeScript environment declarations\n generateDts(root, files, config.locales);\n const dtsPath = path.join(srcDir, \"dialex-env.d.ts\");\n\n // 2. Build standalone generated module content\n const importLines: string[] = [];\n const dictIdentifiers: string[] = [];\n\n files.forEach((file, idx) => {\n let rel = path.relative(targetDir, file).replace(/\\\\/g, \"/\");\n rel = rel.replace(/\\.ts$/, \".js\");\n if (!rel.startsWith(\".\")) {\n rel = \"./\" + rel;\n }\n const id = `dict_${idx}`;\n importLines.push(`import ${id} from \"${rel}\";`);\n dictIdentifiers.push(id);\n });\n\n const dictList =\n dictIdentifiers.length <= 1\n ? `[${dictIdentifiers.join(\", \")}]`\n : `[\\n ${dictIdentifiers.join(\",\\n \")}\\n]`;\n\n const content = `// Auto-generated by dialex CLI. Do not edit directly.\n/* eslint-disable */\n// @ts-nocheck\n${importLines.join(\"\\n\")}\n\nexport const dictionaries = ${dictList};\n\nexport const dictionaryMap = {\n${dictIdentifiers.map((id) => ` [${id}.name]: ${id}.dictionary,`).join(\"\\n\")}\n};\n\nexport default dictionaries;\n`;\n\n fs.mkdirSync(targetDir, { recursive: true });\n const existing = fs.existsSync(targetOutput) ? fs.readFileSync(targetOutput, \"utf-8\") : \"\";\n if (existing !== content) {\n fs.writeFileSync(targetOutput, content, \"utf-8\");\n }\n\n return { files, outputPath: targetOutput, dtsPath };\n}\n\nexport async function runGenerate(options: GenerateOptions = {}) {\n const root = options.cwd || process.cwd();\n const quiet = options.json === true;\n\n const doGenerate = () => {\n try {\n const { files, outputPath, dtsPath } = generateDictionaries(root, options);\n if (quiet) {\n console.log(\n JSON.stringify(\n {\n success: true,\n files: files.map((f) => path.relative(root, f)),\n outputPath: path.relative(root, outputPath),\n dtsPath: path.relative(root, dtsPath),\n },\n null,\n 2,\n ),\n );\n } else {\n logger.success(\n `Generated dictionaries for ${files.length} file${files.length === 1 ? \"\" : \"s\"}:`,\n );\n logger.info(`→ ${path.relative(root, outputPath)}`);\n logger.info(`→ ${path.relative(root, dtsPath)}`);\n }\n return true;\n } catch (err: any) {\n if (quiet) {\n console.log(\n JSON.stringify(\n {\n success: false,\n error: err.message || String(err),\n },\n null,\n 2,\n ),\n );\n } else {\n logger.error(`Generation failed: ${err.message || String(err)}`);\n }\n return false;\n }\n };\n\n const ok = doGenerate();\n if (!ok && !options.watch) {\n process.exit(1);\n }\n\n if (options.watch) {\n logger.info(\"Watching for dictionary changes (-w, --watch)...\");\n const inlineConfig = options.config ? { configFile: options.config } : {};\n const config = resolveI18nConfig(root, inlineConfig);\n const pattern = config.include || \"**/*.content.ts\";\n\n const watcher = chokidar.watch(pattern, {\n cwd: root,\n ignoreInitial: true,\n ignored: [\"**/node_modules/**\", \"**/dist/**\", \"**/.next/**\"],\n });\n\n watcher.on(\"all\", (event, filePath) => {\n logger.info(`[${event}] ${filePath} changed, regenerating...`);\n doGenerate();\n });\n }\n}\n","import fs from \"node:fs\";\nimport { loadFile, writeFile, generateCode, parseExpression, parseModule } from \"magicast\";\n\n/**\n * AST-level helpers for reading and editing `.content.ts` dictionary files.\n *\n * Magicast's proxy layer cannot represent every value (for example template-literal\n * functions), so these helpers work on the underlying AST nodes and use Magicast only\n * to parse and print, which preserves the rest of the file's formatting.\n *\n * Supported shapes:\n * - `export default defineDictionary(\"name\", { en: {...}, tr: {...} })`\n * - `export default defineDictionary({ name: \"name\", dictionary: { ... } })`\n * - `export default { name: \"name\", dictionary: { ... } }`\n */\n\ntype Node = { type: string; [key: string]: any };\n\nexport const TODO_PREFIX = \"[TODO] \";\n\nconst IDENTIFIER = /^[A-Za-z_$][\\w$]*$/;\n\nexport interface DictionaryFile {\n file: string;\n /** Dictionary name from `defineDictionary(\"name\", ...)` or the `name` property, if literal. */\n name?: string;\n mod: Awaited<ReturnType<typeof loadFile>>;\n /** The object whose keys are locales. */\n localesObj: Node;\n /** Whether the file ended with a newline when loaded; restored on save. */\n endsWithNewline: boolean;\n /**\n * `false` when part of the dictionary cannot be read statically (spreads, computed keys, or a\n * locale whose content is not an object literal). Leaf lists and parity checks are unreliable\n * for such files.\n */\n complete: boolean;\n}\n\n/** A zero-based line/column range, as used by editors. */\nexport interface SourceRange {\n start: { line: number; column: number };\n end: { line: number; column: number };\n}\n\nexport type LeafKind = \"string\" | \"function\" | \"other\";\n\nexport interface Leaf {\n path: string[];\n kind: LeafKind;\n /** Present when `kind` is `\"string\"`. */\n value?: string;\n}\n\nfunction unwrap(node: Node): Node {\n while (\n node &&\n (node.type === \"TSAsExpression\" ||\n node.type === \"TSSatisfiesExpression\" ||\n node.type === \"ParenthesizedExpression\")\n ) {\n node = node.expression;\n }\n return node;\n}\n\nconst isObject = (node: Node) => node?.type === \"ObjectExpression\";\n\nfunction keyName(prop: Node): string | undefined {\n const key = prop?.key;\n if (!key || prop.computed) return undefined;\n if (key.type === \"Identifier\") return key.name;\n if (key.type === \"StringLiteral\" || (key.type === \"Literal\" && typeof key.value === \"string\")) {\n return key.value;\n }\n if (key.type === \"NumericLiteral\") return String(key.value);\n return undefined;\n}\n\nconst isPropLike = (p: Node) =>\n p?.type === \"ObjectProperty\" || p?.type === \"Property\" || p?.type === \"ObjectMethod\";\n\nfunction findProp(obj: Node, key: string): Node | undefined {\n return obj.properties.find((p: Node) => isPropLike(p) && keyName(p) === key);\n}\n\nfunction stringValue(node: Node): string | undefined {\n node = unwrap(node);\n if (node?.type === \"StringLiteral\") return node.value;\n if (node?.type === \"Literal\" && typeof node.value === \"string\") return node.value;\n if (node?.type === \"TemplateLiteral\" && node.expressions.length === 0) {\n return node.quasis[0]?.value?.cooked ?? undefined;\n }\n return undefined;\n}\n\nfunction leafKind(node: Node): LeafKind {\n node = unwrap(node);\n if (stringValue(node) !== undefined) return \"string\";\n if (\n node?.type === \"ArrowFunctionExpression\" ||\n node?.type === \"FunctionExpression\" ||\n node?.type === \"ObjectMethod\"\n ) {\n return \"function\";\n }\n return \"other\";\n}\n\nfunction dictionaryProp(obj: Node): Node | undefined {\n const prop = findProp(obj, \"dictionary\");\n const value = unwrap(prop?.value);\n return isObject(value) ? value : undefined;\n}\n\nfunction locateName(declaration: Node): string | undefined {\n const decl = unwrap(declaration);\n if (decl?.type === \"CallExpression\") {\n const first = unwrap(decl.arguments[0]);\n if (isObject(first)) return stringValue(findProp(first, \"name\")?.value);\n return stringValue(first);\n }\n if (isObject(decl)) return stringValue(findProp(decl, \"name\")?.value);\n return undefined;\n}\n\nfunction locateLocalesObject(declaration: Node): Node | undefined {\n const decl = unwrap(declaration);\n if (decl?.type === \"CallExpression\") {\n const first = unwrap(decl.arguments[0]);\n const second = unwrap(decl.arguments[1]);\n if (isObject(second)) return second;\n if (isObject(first)) return dictionaryProp(first);\n return undefined;\n }\n if (isObject(decl)) return dictionaryProp(decl);\n return undefined;\n}\n\n/** Quotes a property key only when it is not a valid identifier. */\nfunction keyCode(key: string): string {\n return IDENTIFIER.test(key) ? key : JSON.stringify(key);\n}\n\n/** Builds a detached `key: <value>` property node from source text. */\nfunction makeProp(key: string, valueCode: string): Node {\n const expr: Node = parseExpression(`({ ${keyCode(key)}: ${valueCode} })`);\n return expr.$ast.properties[0];\n}\n\nfunction makeStringNode(value: string): Node {\n return makeProp(\"_\", JSON.stringify(value)).value;\n}\n\n/**\n * A dictionary is statically readable when every locale is an object literal and no object on the\n * way down uses spreads or computed keys.\n */\nfunction isStaticallyComplete(localesObj: Node): boolean {\n const walk = (obj: Node): boolean =>\n obj.properties.every((prop: Node) => {\n if (!isPropLike(prop) || keyName(prop) === undefined) return false;\n if (prop.type === \"ObjectMethod\") return true;\n const value = unwrap(prop.value);\n return isObject(value) ? walk(value) : true;\n });\n\n return localesObj.properties.every((prop: Node) => {\n if (!isPropLike(prop) || keyName(prop) === undefined || prop.type === \"ObjectMethod\")\n return false;\n const value = unwrap(prop.value);\n return isObject(value) && walk(value);\n });\n}\n\n/**\n * Parses dictionary source text (for example an unsaved editor buffer). Returns `undefined` when\n * the file does not have an editable shape; throws on syntax errors.\n */\nexport function parseDictionaryText(file: string, text: string): DictionaryFile | undefined {\n const mod = parseModule(text);\n const exported: Node = (mod.exports as any).default;\n const ast: Node = exported?.$ast;\n if (!ast) return undefined;\n const declaration = ast.declaration ?? ast;\n const localesObj = locateLocalesObject(declaration);\n return localesObj\n ? {\n file,\n mod,\n localesObj,\n name: locateName(declaration),\n endsWithNewline: text.endsWith(\"\\n\"),\n complete: isStaticallyComplete(localesObj),\n }\n : undefined;\n}\n\n/** Loads a dictionary file; returns `undefined` when its shape is not editable. */\nexport async function loadDictionaryFile(file: string): Promise<DictionaryFile | undefined> {\n return parseDictionaryText(file, fs.readFileSync(file, \"utf-8\"));\n}\n\n/** The source text with all edits applied, without writing anything. */\nexport function renderDictionaryFile(df: DictionaryFile): string {\n const code = generateCode(df.mod as any).code;\n return df.endsWithNewline && !code.endsWith(\"\\n\") ? `${code}\\n` : code;\n}\n\nexport async function saveDictionaryFile(df: DictionaryFile): Promise<void> {\n await writeFile(df.mod, df.file);\n if (df.endsWithNewline) {\n const text = fs.readFileSync(df.file, \"utf-8\");\n if (!text.endsWith(\"\\n\")) fs.writeFileSync(df.file, text + \"\\n\", \"utf-8\");\n }\n}\n\nexport function listLocales(df: DictionaryFile): string[] {\n return df.localesObj.properties\n .filter(isPropLike)\n .map(keyName)\n .filter((k: string | undefined): k is string => k !== undefined);\n}\n\nfunction localeObject(df: DictionaryFile, locale: string): Node | undefined {\n const value = unwrap(findProp(df.localesObj, locale)?.value);\n return isObject(value) ? value : undefined;\n}\n\n/** Lists every leaf (string, function, or other value) of a locale, in source order. */\nexport function listLeaves(df: DictionaryFile, locale: string): Leaf[] {\n const root = localeObject(df, locale);\n if (!root) return [];\n\n const leaves: Leaf[] = [];\n const walk = (obj: Node, prefix: string[]) => {\n for (const prop of obj.properties) {\n if (!isPropLike(prop)) continue;\n const name = keyName(prop);\n if (name === undefined) continue;\n const path = [...prefix, name];\n const value = prop.type === \"ObjectMethod\" ? prop : unwrap(prop.value);\n if (isObject(value)) {\n walk(value, path);\n } else {\n const kind = leafKind(value);\n leaves.push({ path, kind, ...(kind === \"string\" ? { value: stringValue(value) } : {}) });\n }\n }\n };\n walk(root, []);\n return leaves;\n}\n\nfunction getProp(df: DictionaryFile, locale: string, path: string[]): Node | undefined {\n let obj = localeObject(df, locale);\n for (let i = 0; obj && i < path.length; i++) {\n const prop = findProp(obj, path[i]);\n if (!prop) return undefined;\n if (i === path.length - 1) return prop;\n const next = unwrap(prop.value);\n obj = isObject(next) ? next : undefined;\n }\n return undefined;\n}\n\nexport function hasPath(df: DictionaryFile, locale: string, path: string[]): boolean {\n return getProp(df, locale, path) !== undefined;\n}\n\nexport function getString(df: DictionaryFile, locale: string, path: string[]): string | undefined {\n const prop = getProp(df, locale, path);\n return prop && prop.type !== \"ObjectMethod\" ? stringValue(prop.value) : undefined;\n}\n\nfunction ensureLocale(df: DictionaryFile, locale: string): Node {\n let obj = localeObject(df, locale);\n if (!obj) {\n const prop = makeProp(locale, \"{}\");\n df.localesObj.properties.push(prop);\n obj = prop.value as Node;\n }\n return obj;\n}\n\n/** Returns the object that should contain the last path segment, creating objects as needed. */\nfunction ensureParent(df: DictionaryFile, locale: string, path: string[]): Node | undefined {\n let obj = ensureLocale(df, locale);\n for (const segment of path.slice(0, -1)) {\n let prop = findProp(obj, segment);\n if (!prop) {\n prop = makeProp(segment, \"{}\");\n obj.properties.push(prop);\n }\n const next = unwrap(prop.value);\n if (!isObject(next)) return undefined;\n obj = next;\n }\n return obj;\n}\n\nexport type SetResult = \"created\" | \"updated\" | \"skipped\";\n\n/**\n * Sets a string value at `path`. Existing function or non-string values are left alone\n * (`\"skipped\"`) because they cannot be translated as plain text.\n */\nexport function setString(\n df: DictionaryFile,\n locale: string,\n path: string[],\n value: string,\n): SetResult {\n const parent = ensureParent(df, locale, path);\n if (!parent) return \"skipped\";\n\n const last = path[path.length - 1];\n const existing = findProp(parent, last);\n if (existing) {\n if (existing.type === \"ObjectMethod\" || leafKind(existing.value) !== \"string\") {\n return \"skipped\";\n }\n existing.value = makeStringNode(value);\n return \"updated\";\n }\n parent.properties.push(makeProp(last, JSON.stringify(value)));\n return \"created\";\n}\n\n/**\n * Copies the leaf at `path` from one locale to another. String values can be rewritten with\n * `mapString` (for example to add a `[TODO]` marker); other values are copied verbatim.\n * Returns `false` when the source has no such leaf or the target already has one.\n */\nexport function copyLeaf(\n df: DictionaryFile,\n fromLocale: string,\n toLocale: string,\n path: string[],\n mapString?: (value: string) => string,\n): boolean {\n const source = getProp(df, fromLocale, path);\n if (!source || hasPath(df, toLocale, path)) return false;\n\n const parent = ensureParent(df, toLocale, path);\n if (!parent) return false;\n\n const last = path[path.length - 1];\n const text = source.type === \"ObjectMethod\" ? undefined : stringValue(source.value);\n if (text !== undefined && mapString) {\n parent.properties.push(makeProp(last, JSON.stringify(mapString(text))));\n } else {\n const code = generateCode(source as any).code;\n const expr: Node = parseExpression(`({ ${code} })`);\n parent.properties.push(expr.$ast.properties[0]);\n }\n return true;\n}\n\n/** Leaf paths of a runtime dictionary value (plain objects recurse; everything else is a leaf). */\nexport function flattenPaths(value: unknown, prefix: string[] = []): string[][] {\n if (value && typeof value === \"object\" && !Array.isArray(value)) {\n return Object.entries(value).flatMap(([k, v]) => flattenPaths(v, [...prefix, k]));\n }\n return prefix.length > 0 ? [prefix] : [];\n}\n\nconst toRange = (loc: Node | undefined): SourceRange | undefined =>\n loc\n ? {\n start: { line: loc.start.line - 1, column: loc.start.column },\n end: { line: loc.end.line - 1, column: loc.end.column },\n }\n : undefined;\n\n/**\n * Where a locale (no `path`) or a key within it is written. The range covers the property key, so\n * it is a good place to attach a diagnostic or jump to.\n */\nexport function locationOf(\n df: DictionaryFile,\n locale: string,\n path: string[] = [],\n): SourceRange | undefined {\n const prop = path.length === 0 ? findProp(df.localesObj, locale) : getProp(df, locale, path);\n return toRange((prop?.key ?? prop)?.loc);\n}\n\n/** The source text of the dictionary object itself (the object whose keys are locales). */\nexport function dictionaryLocation(df: DictionaryFile): SourceRange | undefined {\n return toRange(df.localesObj.loc);\n}\n\n/** The source code of a leaf's value (a function's source, or a string with its quotes). */\nexport function getLeafSource(\n df: DictionaryFile,\n locale: string,\n path: string[],\n): string | undefined {\n const prop = getProp(df, locale, path);\n if (!prop) return undefined;\n return generateCode((prop.type === \"ObjectMethod\" ? prop : prop.value) as any).code;\n}\n\n// AST helpers shared with the static config reader.\nexport {\n unwrap as unwrapNode,\n isObject as isObjectNode,\n keyName as propertyKeyName,\n findProp as findProperty,\n};\nexport type { Node as AstNode };\n","import {\n argumentSignature,\n findPlurals,\n getArguments,\n isIcuStructured,\n parseMessage,\n type IcuNode,\n} from \"dialexjs/icu\";\n\nexport interface IcuFinding {\n level: \"error\" | \"warning\";\n code: \"invalid-icu\" | \"icu-args-mismatch\" | \"icu-plural-categories\";\n locale: string;\n /** Dotted key including the dictionary name, e.g. `cart.items`. */\n key: string;\n message: string;\n}\n\n/** `locale -> dotted path within the dictionary -> string value` */\nexport type LocaleStrings = Map<string, Map<string, string>>;\n\n/** CLDR order. `resolvedOptions().pluralCategories` order differs between Node versions. */\nconst CATEGORY_ORDER = [\"zero\", \"one\", \"two\", \"few\", \"many\"];\n\nfunction requiredCategories(locale: string, ordinal: boolean): string[] {\n try {\n return new Intl.PluralRules(locale, { type: ordinal ? \"ordinal\" : \"cardinal\" })\n .resolvedOptions()\n .pluralCategories.filter((c) => c !== \"other\")\n .sort((a, b) => CATEGORY_ORDER.indexOf(a) - CATEGORY_ORDER.indexOf(b));\n } catch {\n return []; // not a valid BCP 47 tag; nothing to compare against\n }\n}\n\n/**\n * Validates ICU messages across the locales of one dictionary:\n *\n * - invalid syntax: an error for messages that clearly use ICU (plural/select/number/date/time),\n * a warning for plain `{placeholders}` that do not parse (they may not be meant as ICU);\n * - every locale must use the same arguments as the reference locale;\n * - plural options should cover the categories the locale's plural rules need.\n */\nexport function checkIcu(\n dictionary: string,\n strings: LocaleStrings,\n defaultLocale: string,\n): IcuFinding[] {\n const findings: IcuFinding[] = [];\n const parsed = new Map<string, Map<string, IcuNode[]>>();\n\n for (const [locale, entries] of strings) {\n const ok = new Map<string, IcuNode[]>();\n for (const [path, value] of entries) {\n if (!value.includes(\"{\")) continue;\n const key = `${dictionary}.${path}`;\n try {\n ok.set(path, parseMessage(value));\n } catch (error) {\n const structured = isIcuStructured(value);\n findings.push({\n level: structured ? \"error\" : \"warning\",\n code: \"invalid-icu\",\n locale,\n key,\n message: structured\n ? `Invalid ICU message \"${key}\" (${locale}): ${(error as Error).message}`\n : `\"${key}\" (${locale}) contains braces but is not valid ICU, so t() values cannot be applied: ${(error as Error).message}`,\n });\n }\n }\n parsed.set(locale, ok);\n }\n\n // Compare every locale against the reference (default locale first)\n const order = [defaultLocale, ...[...parsed.keys()].filter((l) => l !== defaultLocale)];\n const paths = new Set([...parsed.values()].flatMap((m) => [...m.keys()]));\n\n for (const path of paths) {\n const key = `${dictionary}.${path}`;\n const reference = order.find((l) => parsed.get(l)?.has(path));\n if (!reference) continue;\n const expected = argumentSignature(parsed.get(reference)!.get(path)!);\n\n for (const locale of order) {\n const nodes = parsed.get(locale)?.get(path);\n if (nodes && locale !== reference) {\n const found = argumentSignature(nodes);\n if (found !== expected) {\n findings.push({\n level: \"error\",\n code: \"icu-args-mismatch\",\n locale,\n key,\n message: `Locale \"${locale}\" uses different arguments than \"${reference}\" for \"${key}\" (expected ${expected || \"none\"}, found ${found || \"none\"})`,\n });\n }\n }\n if (!nodes) continue;\n\n for (const plural of findPlurals(nodes)) {\n const missing = requiredCategories(locale, plural.ordinal).filter(\n (c) => !(c in plural.options),\n );\n if (missing.length > 0) {\n findings.push({\n level: \"warning\",\n code: \"icu-plural-categories\",\n locale,\n key,\n message: `Locale \"${locale}\" plural \"${plural.name}\" in \"${key}\" has no ${missing.map((c) => `\"${c}\"`).join(\", \")} option (used by this language; \"other\" will be shown instead)`,\n });\n }\n }\n }\n }\n\n return findings;\n}\n\n/** Arguments of a message, or `undefined` when it does not parse. */\nexport function tryGetArguments(message: string) {\n try {\n return getArguments(parseMessage(message));\n } catch {\n return undefined;\n }\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\nimport fg from \"fast-glob\";\nimport {\n TODO_PREFIX,\n dictionaryLocation,\n flattenPaths,\n listLeaves,\n listLocales,\n loadDictionaryFile,\n locationOf,\n type DictionaryFile,\n type SourceRange,\n} from \"./utils/dictionary-edit.js\";\nimport { checkIcu, type LocaleStrings } from \"./utils/icu-check.js\";\n\n/**\n * Project analysis shared by `dialex check` and the editor extension.\n *\n * It reads dictionaries from the syntax tree, so it never runs project code. Dictionaries that\n * cannot be read that way (spreads, computed keys, imported values) are skipped with an `info`\n * issue, unless `runtime: true` is passed, in which case they are imported and read from the\n * evaluated module (the CLI does this; editors must not).\n */\n\nexport type IssueLevel = \"error\" | \"warning\" | \"info\";\n\nexport type IssueCode =\n | \"invalid-dictionary\"\n | \"unanalyzable\"\n | \"missing-locale\"\n | \"missing-key\"\n | \"invalid-locale\"\n | \"todo-placeholder\"\n | \"invalid-icu\"\n | \"icu-args-mismatch\"\n | \"icu-plural-categories\"\n | \"unknown-dictionary\"\n | \"unknown-path\"\n | \"unused-key\"\n | \"unused-dictionary\";\n\nexport interface AnalysisIssue {\n /** Absolute path of the file the issue is in. */\n file: string;\n level: IssueLevel;\n code: IssueCode;\n message: string;\n /** Where to point, when known. Lines and columns are zero-based. */\n range?: SourceRange;\n /** The dictionary the issue is about, when it is about one. */\n dictionary?: string;\n locale?: string;\n /** Key path within the dictionary. */\n path?: string[];\n /** For `missing-key`: a locale that has the key, to copy it from. */\n sourceLocale?: string;\n}\n\nexport interface AnalysisConfig {\n defaultLocale?: string;\n locales?: string[];\n include?: string | string[];\n}\n\nexport interface AnalysisOptions {\n root: string;\n config: AnalysisConfig;\n /** Source globs to scan for dictionary references. Pass `[]` to skip scanning. */\n src?: string[];\n /** Import dictionaries the syntax tree cannot fully describe. Runs project code. */\n runtime?: boolean;\n /** Extra ignore globs, relative to `root`. */\n ignore?: string[];\n /** Report possibly unused keys and dictionaries. @default true */\n unused?: boolean;\n}\n\nexport interface LeafInfo {\n kind: \"string\" | \"function\" | \"other\";\n value?: string;\n}\n\nexport interface AnalyzedDictionary {\n name: string;\n /** Absolute path. */\n file: string;\n /** Locales in source order. */\n locales: string[];\n /** `locale -> dotted path -> leaf` */\n leaves: Map<string, Map<string, LeafInfo>>;\n /** Union of dotted leaf paths across locales, in order of first appearance. */\n paths: string[];\n /** The parsed file, present when it was read statically. */\n df?: DictionaryFile;\n}\n\nexport interface AnalysisResult {\n issues: AnalysisIssue[];\n dictionaries: AnalyzedDictionary[];\n /** Absolute paths of every dictionary file that matched. */\n files: string[];\n sourceFilesScanned: number;\n}\n\nconst DICTIONARY_IGNORE = [\"**/node_modules/**\", \"**/dist/**\", \"**/.next/**\"];\n\nexport const DEFAULT_SOURCE_GLOB = \"**/*.{ts,tsx,js,jsx,mjs,cjs,vue,svelte,astro,mdx}\";\nconst SOURCE_IGNORE = [\n ...DICTIONARY_IGNORE,\n \"**/.nuxt/**\",\n \"**/.output/**\",\n \"**/.svelte-kit/**\",\n \"**/.astro/**\",\n \"**/coverage/**\",\n \"**/graphify-out/**\",\n \"**/*.d.ts\",\n \"**/dialex.generated.*\",\n \"**/dialex.config.*\",\n \"**/i18n.config.*\",\n];\n\n/** `getDictionary(\"x\")`, `useDictionary(\"x\")`, `@I18nDictionary(\"x\")` */\nconst DICTIONARY_CALL =\n /\\b(?:getDictionary|useDictionary|I18nDictionary)\\(\\s*([\"'`])([^\"'`$\\n]+)\\1/dg;\n/** `t(\"dictionary.path.to.key\")` */\nconst T_CALL = /(?<![\\w$.])t\\(\\s*([\"'`])([\\w-]+(?:\\.[\\w-]+)+)\\1/dg;\n\nexport interface Reference {\n /** A dictionary name, or a full `dictionary.key.path`. */\n kind: \"dictionary\" | \"path\";\n value: string;\n /** Offsets of the string's contents (without the quotes) in the scanned text. */\n start: number;\n end: number;\n}\n\n/** Finds `getDictionary(\"x\")`-style and `t(\"x.y.z\")` references in source text. */\nexport function scanReferences(text: string): Reference[] {\n const references: Reference[] = [];\n const collect = (pattern: RegExp, kind: Reference[\"kind\"]) => {\n for (const match of text.matchAll(pattern)) {\n const [start, end] = match.indices![2] as [number, number];\n references.push({ kind, value: match[2], start, end });\n }\n };\n collect(DICTIONARY_CALL, \"dictionary\");\n collect(T_CALL, \"path\");\n return references.sort((a, b) => a.start - b.start);\n}\n\nfunction lineStarts(text: string): number[] {\n const starts = [0];\n for (let i = 0; i < text.length; i++) if (text.charCodeAt(i) === 10) starts.push(i + 1);\n return starts;\n}\n\nfunction positionAt(starts: number[], offset: number) {\n let low = 0;\n let high = starts.length - 1;\n while (low < high) {\n const mid = Math.ceil((low + high) / 2);\n if (starts[mid] <= offset) low = mid;\n else high = mid - 1;\n }\n return { line: low, column: offset - starts[low] };\n}\n\ninterface DictionaryData {\n name: string;\n locales: string[];\n leaves: Map<string, Map<string, LeafInfo>>;\n df?: DictionaryFile;\n}\n\ntype Loaded =\n | { ok: true; data: DictionaryData }\n | { ok: false; level: IssueLevel; code: IssueCode; message: string };\n\nfunction fromSyntaxTree(df: DictionaryFile): DictionaryData {\n const locales = listLocales(df);\n const leaves = new Map<string, Map<string, LeafInfo>>();\n for (const locale of locales) {\n const entries = new Map<string, LeafInfo>();\n for (const leaf of listLeaves(df, locale)) {\n entries.set(leaf.path.join(\".\"), { kind: leaf.kind, value: leaf.value });\n }\n leaves.set(locale, entries);\n }\n return { name: df.name!, locales, leaves, df };\n}\n\nasync function fromRuntime(file: string): Promise<Loaded> {\n try {\n const mod = await import(`${pathToFileURL(file).href}?t=${Date.now()}_${Math.random()}`);\n const definition = mod.default || mod;\n if (!definition || typeof definition !== \"object\" || !definition.dictionary) {\n return {\n ok: false,\n level: \"error\",\n code: \"invalid-dictionary\",\n message: \"Default export does not appear to be a valid defineDictionary output.\",\n };\n }\n\n const dictionary = definition.dictionary as Record<string, Record<string, any>>;\n const leaves = new Map<string, Map<string, LeafInfo>>();\n const invalid: string[] = [];\n\n for (const [locale, content] of Object.entries(dictionary)) {\n if (!content || typeof content !== \"object\") {\n invalid.push(locale);\n continue;\n }\n const entries = new Map<string, LeafInfo>();\n for (const leafPath of flattenPaths(content)) {\n let value: any = content;\n for (const segment of leafPath) value = value?.[segment];\n entries.set(\n leafPath.join(\".\"),\n typeof value === \"string\"\n ? { kind: \"string\", value }\n : { kind: typeof value === \"function\" ? \"function\" : \"other\" },\n );\n }\n leaves.set(locale, entries);\n }\n\n if (invalid.length > 0) {\n return {\n ok: false,\n level: \"error\",\n code: \"invalid-locale\",\n message: invalid.map((l) => `Locale \"${l}\" content is empty or invalid.`).join(\"\\n\"),\n };\n }\n\n return {\n ok: true,\n data: { name: String(definition.name ?? \"\"), locales: [...leaves.keys()], leaves },\n };\n } catch (error: any) {\n return {\n ok: false,\n level: \"error\",\n code: \"invalid-dictionary\",\n message: `Failed to import dictionary: ${error.message || String(error)}`,\n };\n }\n}\n\nasync function loadDictionaryData(file: string, runtime: boolean): Promise<Loaded> {\n let astError: Error | undefined;\n try {\n const df = await loadDictionaryFile(file);\n if (df?.complete && df.name) return { ok: true, data: fromSyntaxTree(df) };\n } catch (error) {\n astError = error as Error;\n }\n\n if (runtime) return fromRuntime(file);\n\n return astError\n ? {\n ok: false,\n level: \"error\",\n code: \"invalid-dictionary\",\n message: `Failed to parse dictionary: ${astError.message}`,\n }\n : {\n ok: false,\n level: \"info\",\n code: \"unanalyzable\",\n message:\n \"This dictionary uses spreads, computed keys, imported values, or a computed name, so it cannot be analyzed statically.\",\n };\n}\n\nexport async function analyzeProject(options: AnalysisOptions): Promise<AnalysisResult> {\n const { root, config } = options;\n const include = config.include || \"**/*.content.ts\";\n const configuredLocales = config.locales || [];\n const defaultLocale = config.defaultLocale || \"en\";\n const extraIgnore = options.ignore ?? [];\n\n const files = fg.sync(include, {\n cwd: root,\n absolute: true,\n ignore: [...DICTIONARY_IGNORE, ...extraIgnore],\n });\n\n const issues: AnalysisIssue[] = [];\n const dictionaries: AnalyzedDictionary[] = [];\n\n // 1. Dictionaries: parity, placeholders, ICU\n for (const file of files) {\n const loaded = await loadDictionaryData(file, options.runtime === true);\n if (!loaded.ok) {\n for (const message of loaded.message.split(\"\\n\")) {\n issues.push({ file, level: loaded.level, code: loaded.code, message });\n }\n continue;\n }\n\n const { data } = loaded;\n const { df } = data;\n const at = (locale?: string, keyPath?: string[]) =>\n df && locale ? locationOf(df, locale, keyPath) : undefined;\n const add = (issue: Omit<AnalysisIssue, \"file\" | \"dictionary\">) =>\n issues.push({ ...issue, file, dictionary: data.name });\n\n for (const required of configuredLocales) {\n if (!data.locales.includes(required)) {\n add({\n level: \"error\",\n code: \"missing-locale\",\n message: `Missing configured locale \"${required}\"`,\n range: df ? dictionaryLocation(df) : undefined,\n locale: required,\n });\n }\n }\n\n const paths: string[] = [];\n const seen = new Set<string>();\n for (const locale of data.locales) {\n for (const leafPath of data.leaves.get(locale)!.keys()) {\n if (!seen.has(leafPath)) {\n seen.add(leafPath);\n paths.push(leafPath);\n }\n }\n }\n\n for (const locale of data.locales) {\n const present = data.leaves.get(locale)!;\n for (const leafPath of paths) {\n if (present.has(leafPath)) continue;\n const sourceLocale = [defaultLocale, ...data.locales].find(\n (l) => l !== locale && data.leaves.get(l)?.has(leafPath),\n );\n add({\n level: \"error\",\n code: \"missing-key\",\n message: `Locale \"${locale}\" is missing key \"${leafPath}\"`,\n range: at(locale),\n locale,\n path: leafPath.split(\".\"),\n sourceLocale,\n });\n }\n }\n\n const strings: LocaleStrings = new Map();\n for (const locale of data.locales) {\n const entries = new Map<string, string>();\n strings.set(locale, entries);\n for (const [leafPath, leaf] of data.leaves.get(locale)!) {\n if (leaf.kind !== \"string\" || leaf.value === undefined) continue;\n entries.set(leafPath, leaf.value);\n if (leaf.value.startsWith(TODO_PREFIX)) {\n add({\n level: \"warning\",\n code: \"todo-placeholder\",\n message: `Locale \"${locale}\" key \"${leafPath}\" still has a ${TODO_PREFIX.trim()} placeholder`,\n range: at(locale, leafPath.split(\".\")),\n locale,\n path: leafPath.split(\".\"),\n });\n }\n }\n }\n\n for (const finding of checkIcu(data.name, strings, defaultLocale)) {\n const keyPath = finding.key.slice(data.name.length + 1).split(\".\");\n add({\n level: finding.level,\n code: finding.code,\n message: finding.message,\n range: at(finding.locale, keyPath),\n locale: finding.locale,\n path: keyPath,\n });\n }\n\n dictionaries.push({\n name: data.name,\n file,\n locales: data.locales,\n leaves: data.leaves,\n paths,\n df,\n });\n }\n\n // 2. Source code: references to dictionaries and keys\n const known = new Map(dictionaries.map((d) => [d.name, d]));\n const dictionaryFiles = new Set(files);\n const sourceGlobs = options.src ?? [DEFAULT_SOURCE_GLOB];\n const sourceFiles =\n sourceGlobs.length === 0\n ? []\n : fg\n .sync(sourceGlobs, {\n cwd: root,\n absolute: true,\n ignore: [...SOURCE_IGNORE, ...extraIgnore],\n })\n .filter((f) => !dictionaryFiles.has(f));\n\n if (sourceFiles.length > 0) {\n const tokens = new Set<string>();\n\n for (const file of sourceFiles) {\n let text: string;\n try {\n text = fs.readFileSync(file, \"utf-8\");\n } catch {\n continue;\n }\n for (const token of text.match(/[\\w$-]+/g) ?? []) tokens.add(token);\n\n const starts = lineStarts(text);\n const rangeOf = (start: number, end: number): SourceRange => ({\n start: positionAt(starts, start),\n end: positionAt(starts, end),\n });\n\n for (const ref of scanReferences(text)) {\n if (ref.kind === \"dictionary\") {\n if (!known.has(ref.value)) {\n issues.push({\n file,\n level: \"error\",\n code: \"unknown-dictionary\",\n message: `Unknown dictionary \"${ref.value}\"`,\n range: rangeOf(ref.start, ref.end),\n dictionary: ref.value,\n });\n }\n continue;\n }\n\n const [name, ...rest] = ref.value.split(\".\");\n const dictionary = known.get(name);\n if (!dictionary) continue; // `t(...)` may belong to another library\n const keyPath = rest.join(\".\");\n const exists = dictionary.paths.some((p) => p === keyPath || p.startsWith(`${keyPath}.`));\n if (!exists) {\n issues.push({\n file,\n level: \"error\",\n code: \"unknown-path\",\n message: `Unknown translation path \"${ref.value}\"`,\n range: rangeOf(ref.start, ref.end),\n dictionary: name,\n path: rest,\n });\n }\n }\n }\n\n // 3. Possibly unused dictionaries and keys (heuristic: warnings only)\n if (options.unused !== false) {\n for (const dictionary of dictionaries) {\n if (!tokens.has(dictionary.name)) {\n issues.push({\n file: dictionary.file,\n level: \"warning\",\n code: \"unused-dictionary\",\n message: `Dictionary \"${dictionary.name}\" is never referenced`,\n range: dictionary.df ? dictionaryLocation(dictionary.df) : undefined,\n dictionary: dictionary.name,\n });\n continue;\n }\n for (const keyPath of dictionary.paths) {\n const last = keyPath.split(\".\").pop()!;\n if (tokens.has(last)) continue;\n const holder = dictionary.locales.find((l) => dictionary.leaves.get(l)?.has(keyPath));\n issues.push({\n file: dictionary.file,\n level: \"warning\",\n code: \"unused-key\",\n message: `Key \"${keyPath}\" is possibly unused`,\n range:\n dictionary.df && holder\n ? locationOf(dictionary.df, holder, keyPath.split(\".\"))\n : undefined,\n dictionary: dictionary.name,\n path: keyPath.split(\".\"),\n });\n }\n }\n }\n }\n\n return { issues, dictionaries, files, sourceFilesScanned: sourceFiles.length };\n}\n\n/** Project root-relative path with forward slashes, for display. */\nexport function relativeFile(root: string, file: string): string {\n return path.relative(root, file);\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport { parseModule } from \"magicast\";\nimport {\n findProperty,\n isObjectNode,\n propertyKeyName,\n unwrapNode,\n type AstNode,\n} from \"./dictionary-edit.js\";\n\n/**\n * The parts of `dialex.config` that tooling needs, read **without running the file**. Editors must\n * not execute workspace code (it may be untrusted), so values are read from the syntax tree and\n * only literals are understood.\n */\nexport interface StaticConfig {\n defaultLocale: string;\n locales: string[];\n include: string | string[];\n fallbacks: Record<string, string[]>;\n prefixDefault: boolean;\n lazy: boolean;\n}\n\nexport interface StaticConfigResult {\n config: StaticConfig;\n /** The file the values came from, if any. */\n file?: string;\n /** Things that could not be read statically, for example `locales: getLocales()`. */\n notes: string[];\n}\n\nconst CONFIG_NAMES = [\"dialex.config\", \"i18n.config\"];\nconst EXTENSIONS = [\"ts\", \"mts\", \"cts\", \"js\", \"mjs\", \"cjs\", \"json\"];\n\nexport const DEFAULT_STATIC_CONFIG: StaticConfig = {\n defaultLocale: \"en\",\n locales: [],\n include: \"**/*.content.ts\",\n fallbacks: {},\n prefixDefault: true,\n lazy: false,\n};\n\nconst NOT_LITERAL = Symbol(\"not literal\");\n\nfunction literal(node: AstNode | undefined): unknown {\n node = unwrapNode(node as AstNode);\n switch (node?.type) {\n case \"StringLiteral\":\n case \"NumericLiteral\":\n case \"BooleanLiteral\":\n return node.value;\n case \"Literal\":\n return node.value;\n case \"TemplateLiteral\":\n return node.expressions.length === 0 ? (node.quasis[0]?.value?.cooked ?? \"\") : NOT_LITERAL;\n case \"ArrayExpression\": {\n const items = node.elements.map((e: AstNode) => literal(e));\n return items.includes(NOT_LITERAL) ? NOT_LITERAL : items;\n }\n case \"ObjectExpression\": {\n const result: Record<string, unknown> = {};\n for (const prop of node.properties) {\n const key = propertyKeyName(prop);\n const value = key === undefined ? NOT_LITERAL : literal(prop.value);\n if (value === NOT_LITERAL) return NOT_LITERAL;\n result[key as string] = value;\n }\n return result;\n }\n default:\n return NOT_LITERAL;\n }\n}\n\n/** The object literal passed to `defineConfig({...})`, or exported directly. */\nfunction findConfigObject(declaration: AstNode): AstNode | undefined {\n const node = unwrapNode(declaration);\n if (node?.type === \"CallExpression\") return findConfigObject(node.arguments[0]);\n return isObjectNode(node) ? node : undefined;\n}\n\nconst isStringArray = (value: unknown): value is string[] =>\n Array.isArray(value) && value.every((v) => typeof v === \"string\");\n\nfunction apply(object: Record<string, unknown>, config: StaticConfig, notes: string[]) {\n const accept = <K extends keyof StaticConfig>(\n key: K,\n valid: (value: unknown) => boolean,\n expected: string,\n ) => {\n if (!(key in object)) return;\n const value = object[key];\n if (valid(value)) (config as any)[key] = value;\n else notes.push(`\"${key}\" could not be read statically (expected ${expected}).`);\n };\n\n accept(\"defaultLocale\", (v) => typeof v === \"string\" && v !== \"\", \"a string literal\");\n accept(\"locales\", isStringArray, \"an array of string literals\");\n accept(\n \"include\",\n (v) => typeof v === \"string\" || isStringArray(v),\n \"a string or array of strings\",\n );\n accept(\n \"fallbacks\",\n (v) =>\n typeof v === \"object\" && v !== null && Object.values(v).every((list) => isStringArray(list)),\n \"an object of string arrays\",\n );\n accept(\"prefixDefault\", (v) => typeof v === \"boolean\", \"true or false\");\n accept(\"lazy\", (v) => typeof v === \"boolean\", \"true or false\");\n}\n\n/** Reads a config file's source text. Exposed for tests and for unsaved buffers. */\nexport function parseStaticConfig(text: string, file = \"dialex.config.ts\"): StaticConfigResult {\n const notes: string[] = [];\n const config: StaticConfig = { ...DEFAULT_STATIC_CONFIG };\n\n if (file.endsWith(\".json\")) {\n try {\n const data = JSON.parse(text);\n if (data && typeof data === \"object\") apply(data, config, notes);\n } catch (error) {\n notes.push(`Could not parse ${path.basename(file)}: ${(error as Error).message}`);\n }\n return { config, file, notes };\n }\n\n try {\n const exported = (parseModule(text).exports as any).default;\n const object = findConfigObject(exported?.$ast?.declaration ?? exported?.$ast);\n if (!object) {\n notes.push(`${path.basename(file)} does not export a config object literal.`);\n } else {\n const values: Record<string, unknown> = {};\n for (const key of [\n \"defaultLocale\",\n \"locales\",\n \"include\",\n \"fallbacks\",\n \"prefixDefault\",\n \"lazy\",\n ]) {\n const prop = findProperty(object, key);\n if (!prop) continue;\n const value = literal(prop.value);\n if (value === NOT_LITERAL)\n notes.push(`\"${key}\" could not be read statically (not a literal).`);\n else values[key] = value;\n }\n apply(values, config, notes);\n }\n } catch (error) {\n notes.push(`Could not parse ${path.basename(file)}: ${(error as Error).message}`);\n }\n\n return { config, file, notes };\n}\n\n/** Reads `dialex.config.*` (or `i18n.config.*`) from `root`, or from `configFile` if given. */\nexport function readStaticConfig(root: string, configFile?: string): StaticConfigResult {\n const candidates = configFile\n ? [path.resolve(root, configFile)]\n : CONFIG_NAMES.flatMap((name) => EXTENSIONS.map((ext) => path.join(root, `${name}.${ext}`)));\n\n for (const file of candidates) {\n if (fs.existsSync(file)) return parseStaticConfig(fs.readFileSync(file, \"utf-8\"), file);\n }\n return { config: { ...DEFAULT_STATIC_CONFIG }, notes: [] };\n}\n","import path from \"node:path\";\nimport fg from \"fast-glob\";\nimport { resolveI18nConfig } from \"dialexjs/scanner\";\nimport type { I18nConfig } from \"dialexjs\";\nimport { loadDictionaryFile, type DictionaryFile } from \"./dictionary-edit.js\";\nimport { readStaticConfig } from \"./static-config.js\";\n\nexport interface ProjectDictionary {\n /** Path relative to the project root. */\n rel: string;\n name: string;\n df: DictionaryFile;\n}\n\nexport interface Project {\n root: string;\n config: I18nConfig;\n dictionaries: ProjectDictionary[];\n /** Dictionary files that could not be parsed into an editable shape. */\n unsupported: string[];\n /** Config values that could not be read statically (static loading only). */\n notes: string[];\n}\n\nasync function loadDictionaries(root: string, config: I18nConfig) {\n const include = config.include || \"**/*.content.ts\";\n const files = fg.sync(include, {\n cwd: root,\n absolute: true,\n ignore: [\"**/node_modules/**\", \"**/dist/**\", \"**/.next/**\"],\n });\n\n const dictionaries: ProjectDictionary[] = [];\n const unsupported: string[] = [];\n\n for (const file of files) {\n const rel = path.relative(root, file);\n try {\n const df = await loadDictionaryFile(file);\n if (!df || !df.name) unsupported.push(rel);\n else dictionaries.push({ rel, name: df.name, df });\n } catch {\n unsupported.push(rel); // syntax error: reported by the analysis, nothing to edit here\n }\n }\n\n return { dictionaries, unsupported };\n}\n\n/**\n * Resolves the config (running `dialex.config.*` through the loader, which executes it) and loads\n * every dictionary file for AST-level reading and editing.\n */\nexport async function loadProject(root: string, configFile?: string): Promise<Project> {\n const config = resolveI18nConfig(root, configFile ? { configFile } : {});\n return { root, config, notes: [], ...(await loadDictionaries(root, config)) };\n}\n\n/**\n * Like `loadProject`, but reads the config from the syntax tree without executing it. Use this in\n * editors and anywhere project code must not run.\n */\nexport async function loadStaticProject(root: string, configFile?: string): Promise<Project> {\n const { config, notes } = readStaticConfig(root, configFile);\n return { root, config, notes, ...(await loadDictionaries(root, config)) };\n}\n\n/** `home` + `[\"nav\", \"about\"]` -> `home.nav.about` */\nexport const toKey = (dictionary: string, keyPath: string[]) => [dictionary, ...keyPath].join(\".\");\n"],"mappings":";;;;;;;;;;AAEA,MAAa,SAAS;CACpB,OAAO,QAAgB,QAAQ,IAAI,GAAG,KAAK,IAAI,IAAI,GAAG;CACtD,UAAU,QAAgB,QAAQ,IAAI,GAAG,MAAM,IAAI,IAAI,GAAG,KAAK,GAAG,CAAC;CACnE,OA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;GAAG,CAAC;EACnD,QAAQ;GACN,YAAY,KAAK,GAAG;EACtB;CACF;CAEA,OAAO;EAAE;EAAc;CAAY;AACrC;;;;;AAMA,eAAsB,YAAY,MAAc,YAAuC;CACrF,MAAM,SAAS,kBAAkB,MAAM,aAAa,EAAE,WAAW,IAAI,CAAC,CAAC;CACvE,OAAO;EAAE;EAAM;EAAQ,OAAO,CAAC;EAAG,GAAI,MAAM,iBAAiB,MAAM,MAAM;CAAG;AAC9E;;;;;AAMA,eAAsB,kBAAkB,MAAc,YAAuC;CAC3F,MAAM,EAAE,QAAQ,UAAU,iBAAiB,MAAM,UAAU;CAC3D,OAAO;EAAE;EAAM;EAAQ;EAAO,GAAI,MAAM,iBAAiB,MAAM,MAAM;CAAG;AAC1E;;AAGA,MAAa,SAAS,YAAoB,YAAsB,CAAC,YAAY,GAAG,OAAO,CAAC,CAAC,KAAK,GAAG"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dialexjs/cli",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.3",
|
|
4
4
|
"description": "High-performance CLI tool for Dialex internationalization (codegen, scaffolding, CI parity checking)",
|
|
5
5
|
"homepage": "https://github.com/awaiden/dialex#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -13,7 +13,8 @@
|
|
|
13
13
|
"url": "git+https://github.com/awaiden/dialex.git"
|
|
14
14
|
},
|
|
15
15
|
"bin": {
|
|
16
|
-
"dialex": "./dist/index.mjs"
|
|
16
|
+
"dialex": "./dist/index.mjs",
|
|
17
|
+
"dx": "./dist/index.mjs"
|
|
17
18
|
},
|
|
18
19
|
"files": [
|
|
19
20
|
"dist"
|
|
@@ -38,7 +39,7 @@
|
|
|
38
39
|
"@clack/prompts": "^1.8.1",
|
|
39
40
|
"chokidar": "^5.0.0",
|
|
40
41
|
"commander": "^15.0.0",
|
|
41
|
-
"dialexjs": "0.2.
|
|
42
|
+
"dialexjs": "0.2.3",
|
|
42
43
|
"fast-glob": "^3.3.3",
|
|
43
44
|
"magicast": "^0.5.5",
|
|
44
45
|
"picocolors": "^1.1.1",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"project-gkFBurqG.mjs","names":["unwrapNode","propertyKeyName","isObjectNode","findProperty"],"sources":["../src/utils/logger.ts","../src/commands/generate.ts","../src/utils/dictionary-edit.ts","../src/utils/icu-check.ts","../src/analysis.ts","../src/utils/static-config.ts","../src/utils/project.ts"],"sourcesContent":["import pc from \"picocolors\";\n\nexport const logger = {\n info: (msg: string) => console.log(pc.blue(\"ℹ \") + msg),\n success: (msg: string) => console.log(pc.green(\"✔ \") + pc.bold(msg)),\n warn: (msg: string) => console.warn(pc.yellow(\"⚠ \") + msg),\n error: (msg: string) => console.error(pc.red(\"✖ \") + pc.bold(msg)),\n log: (msg: string) => console.log(msg),\n};\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport fg from \"fast-glob\";\nimport chokidar from \"chokidar\";\nimport { resolveI18nConfig, generateDts } from \"dialexjs/scanner\";\nimport { logger } from \"../utils/logger.js\";\n\nexport interface GenerateOptions {\n cwd?: string;\n watch?: boolean;\n output?: string;\n config?: string;\n json?: boolean;\n}\n\nexport function generateDictionaries(\n root: string,\n options: GenerateOptions = {},\n): {\n files: string[];\n outputPath: string;\n dtsPath: string;\n} {\n const inlineConfig = options.config ? { configFile: options.config } : {};\n const config = resolveI18nConfig(root, inlineConfig);\n const include = config.include || \"**/*.content.ts\";\n\n const files = fg.sync(include, {\n cwd: root,\n absolute: true,\n ignore: [\"**/node_modules/**\", \"**/dist/**\", \"**/.next/**\"],\n });\n\n const srcDir = fs.existsSync(path.join(root, \"src\")) ? path.join(root, \"src\") : root;\n const targetOutput = options.output\n ? path.resolve(root, options.output)\n : path.join(srcDir, \"i18n.generated.ts\");\n\n const targetDir = path.dirname(targetOutput);\n\n // 1. Generate TypeScript environment declarations\n generateDts(root, files, config.locales);\n const dtsPath = path.join(srcDir, \"dialex-env.d.ts\");\n\n // 2. Build standalone generated module content\n const importLines: string[] = [];\n const dictIdentifiers: string[] = [];\n\n files.forEach((file, idx) => {\n let rel = path.relative(targetDir, file).replace(/\\\\/g, \"/\");\n rel = rel.replace(/\\.ts$/, \".js\");\n if (!rel.startsWith(\".\")) {\n rel = \"./\" + rel;\n }\n const id = `dict_${idx}`;\n importLines.push(`import ${id} from \"${rel}\";`);\n dictIdentifiers.push(id);\n });\n\n const dictList =\n dictIdentifiers.length <= 1\n ? `[${dictIdentifiers.join(\", \")}]`\n : `[\\n ${dictIdentifiers.join(\",\\n \")}\\n]`;\n\n const content = `// Auto-generated by dialex CLI. Do not edit directly.\n/* eslint-disable */\n// @ts-nocheck\n${importLines.join(\"\\n\")}\n\nexport const dictionaries = ${dictList};\n\nexport const dictionaryMap = {\n${dictIdentifiers.map((id) => ` [${id}.name]: ${id}.dictionary,`).join(\"\\n\")}\n};\n\nexport default dictionaries;\n`;\n\n fs.mkdirSync(targetDir, { recursive: true });\n const existing = fs.existsSync(targetOutput) ? fs.readFileSync(targetOutput, \"utf-8\") : \"\";\n if (existing !== content) {\n fs.writeFileSync(targetOutput, content, \"utf-8\");\n }\n\n return { files, outputPath: targetOutput, dtsPath };\n}\n\nexport async function runGenerate(options: GenerateOptions = {}) {\n const root = options.cwd || process.cwd();\n const quiet = options.json === true;\n\n const doGenerate = () => {\n try {\n const { files, outputPath, dtsPath } = generateDictionaries(root, options);\n if (quiet) {\n console.log(\n JSON.stringify(\n {\n success: true,\n files: files.map((f) => path.relative(root, f)),\n outputPath: path.relative(root, outputPath),\n dtsPath: path.relative(root, dtsPath),\n },\n null,\n 2,\n ),\n );\n } else {\n logger.success(\n `Generated dictionaries for ${files.length} file${files.length === 1 ? \"\" : \"s\"}:`,\n );\n logger.info(`→ ${path.relative(root, outputPath)}`);\n logger.info(`→ ${path.relative(root, dtsPath)}`);\n }\n return true;\n } catch (err: any) {\n if (quiet) {\n console.log(\n JSON.stringify(\n {\n success: false,\n error: err.message || String(err),\n },\n null,\n 2,\n ),\n );\n } else {\n logger.error(`Generation failed: ${err.message || String(err)}`);\n }\n return false;\n }\n };\n\n const ok = doGenerate();\n if (!ok && !options.watch) {\n process.exit(1);\n }\n\n if (options.watch) {\n logger.info(\"Watching for dictionary changes (-w, --watch)...\");\n const inlineConfig = options.config ? { configFile: options.config } : {};\n const config = resolveI18nConfig(root, inlineConfig);\n const pattern = config.include || \"**/*.content.ts\";\n\n const watcher = chokidar.watch(pattern, {\n cwd: root,\n ignoreInitial: true,\n ignored: [\"**/node_modules/**\", \"**/dist/**\", \"**/.next/**\"],\n });\n\n watcher.on(\"all\", (event, filePath) => {\n logger.info(`[${event}] ${filePath} changed, regenerating...`);\n doGenerate();\n });\n }\n}\n","import fs from \"node:fs\";\nimport { loadFile, writeFile, generateCode, parseExpression, parseModule } from \"magicast\";\n\n/**\n * AST-level helpers for reading and editing `.content.ts` dictionary files.\n *\n * Magicast's proxy layer cannot represent every value (for example template-literal\n * functions), so these helpers work on the underlying AST nodes and use Magicast only\n * to parse and print, which preserves the rest of the file's formatting.\n *\n * Supported shapes:\n * - `export default defineDictionary(\"name\", { en: {...}, tr: {...} })`\n * - `export default defineDictionary({ name: \"name\", dictionary: { ... } })`\n * - `export default { name: \"name\", dictionary: { ... } }`\n */\n\ntype Node = { type: string; [key: string]: any };\n\nexport const TODO_PREFIX = \"[TODO] \";\n\nconst IDENTIFIER = /^[A-Za-z_$][\\w$]*$/;\n\nexport interface DictionaryFile {\n file: string;\n /** Dictionary name from `defineDictionary(\"name\", ...)` or the `name` property, if literal. */\n name?: string;\n mod: Awaited<ReturnType<typeof loadFile>>;\n /** The object whose keys are locales. */\n localesObj: Node;\n /** Whether the file ended with a newline when loaded; restored on save. */\n endsWithNewline: boolean;\n /**\n * `false` when part of the dictionary cannot be read statically (spreads, computed keys, or a\n * locale whose content is not an object literal). Leaf lists and parity checks are unreliable\n * for such files.\n */\n complete: boolean;\n}\n\n/** A zero-based line/column range, as used by editors. */\nexport interface SourceRange {\n start: { line: number; column: number };\n end: { line: number; column: number };\n}\n\nexport type LeafKind = \"string\" | \"function\" | \"other\";\n\nexport interface Leaf {\n path: string[];\n kind: LeafKind;\n /** Present when `kind` is `\"string\"`. */\n value?: string;\n}\n\nfunction unwrap(node: Node): Node {\n while (\n node &&\n (node.type === \"TSAsExpression\" ||\n node.type === \"TSSatisfiesExpression\" ||\n node.type === \"ParenthesizedExpression\")\n ) {\n node = node.expression;\n }\n return node;\n}\n\nconst isObject = (node: Node) => node?.type === \"ObjectExpression\";\n\nfunction keyName(prop: Node): string | undefined {\n const key = prop?.key;\n if (!key || prop.computed) return undefined;\n if (key.type === \"Identifier\") return key.name;\n if (key.type === \"StringLiteral\" || (key.type === \"Literal\" && typeof key.value === \"string\")) {\n return key.value;\n }\n if (key.type === \"NumericLiteral\") return String(key.value);\n return undefined;\n}\n\nconst isPropLike = (p: Node) =>\n p?.type === \"ObjectProperty\" || p?.type === \"Property\" || p?.type === \"ObjectMethod\";\n\nfunction findProp(obj: Node, key: string): Node | undefined {\n return obj.properties.find((p: Node) => isPropLike(p) && keyName(p) === key);\n}\n\nfunction stringValue(node: Node): string | undefined {\n node = unwrap(node);\n if (node?.type === \"StringLiteral\") return node.value;\n if (node?.type === \"Literal\" && typeof node.value === \"string\") return node.value;\n if (node?.type === \"TemplateLiteral\" && node.expressions.length === 0) {\n return node.quasis[0]?.value?.cooked ?? undefined;\n }\n return undefined;\n}\n\nfunction leafKind(node: Node): LeafKind {\n node = unwrap(node);\n if (stringValue(node) !== undefined) return \"string\";\n if (\n node?.type === \"ArrowFunctionExpression\" ||\n node?.type === \"FunctionExpression\" ||\n node?.type === \"ObjectMethod\"\n ) {\n return \"function\";\n }\n return \"other\";\n}\n\nfunction dictionaryProp(obj: Node): Node | undefined {\n const prop = findProp(obj, \"dictionary\");\n const value = unwrap(prop?.value);\n return isObject(value) ? value : undefined;\n}\n\nfunction locateName(declaration: Node): string | undefined {\n const decl = unwrap(declaration);\n if (decl?.type === \"CallExpression\") {\n const first = unwrap(decl.arguments[0]);\n if (isObject(first)) return stringValue(findProp(first, \"name\")?.value);\n return stringValue(first);\n }\n if (isObject(decl)) return stringValue(findProp(decl, \"name\")?.value);\n return undefined;\n}\n\nfunction locateLocalesObject(declaration: Node): Node | undefined {\n const decl = unwrap(declaration);\n if (decl?.type === \"CallExpression\") {\n const first = unwrap(decl.arguments[0]);\n const second = unwrap(decl.arguments[1]);\n if (isObject(second)) return second;\n if (isObject(first)) return dictionaryProp(first);\n return undefined;\n }\n if (isObject(decl)) return dictionaryProp(decl);\n return undefined;\n}\n\n/** Quotes a property key only when it is not a valid identifier. */\nfunction keyCode(key: string): string {\n return IDENTIFIER.test(key) ? key : JSON.stringify(key);\n}\n\n/** Builds a detached `key: <value>` property node from source text. */\nfunction makeProp(key: string, valueCode: string): Node {\n const expr: Node = parseExpression(`({ ${keyCode(key)}: ${valueCode} })`);\n return expr.$ast.properties[0];\n}\n\nfunction makeStringNode(value: string): Node {\n return makeProp(\"_\", JSON.stringify(value)).value;\n}\n\n/**\n * A dictionary is statically readable when every locale is an object literal and no object on the\n * way down uses spreads or computed keys.\n */\nfunction isStaticallyComplete(localesObj: Node): boolean {\n const walk = (obj: Node): boolean =>\n obj.properties.every((prop: Node) => {\n if (!isPropLike(prop) || keyName(prop) === undefined) return false;\n if (prop.type === \"ObjectMethod\") return true;\n const value = unwrap(prop.value);\n return isObject(value) ? walk(value) : true;\n });\n\n return localesObj.properties.every((prop: Node) => {\n if (!isPropLike(prop) || keyName(prop) === undefined || prop.type === \"ObjectMethod\")\n return false;\n const value = unwrap(prop.value);\n return isObject(value) && walk(value);\n });\n}\n\n/**\n * Parses dictionary source text (for example an unsaved editor buffer). Returns `undefined` when\n * the file does not have an editable shape; throws on syntax errors.\n */\nexport function parseDictionaryText(file: string, text: string): DictionaryFile | undefined {\n const mod = parseModule(text);\n const exported: Node = (mod.exports as any).default;\n const ast: Node = exported?.$ast;\n if (!ast) return undefined;\n const declaration = ast.declaration ?? ast;\n const localesObj = locateLocalesObject(declaration);\n return localesObj\n ? {\n file,\n mod,\n localesObj,\n name: locateName(declaration),\n endsWithNewline: text.endsWith(\"\\n\"),\n complete: isStaticallyComplete(localesObj),\n }\n : undefined;\n}\n\n/** Loads a dictionary file; returns `undefined` when its shape is not editable. */\nexport async function loadDictionaryFile(file: string): Promise<DictionaryFile | undefined> {\n return parseDictionaryText(file, fs.readFileSync(file, \"utf-8\"));\n}\n\n/** The source text with all edits applied, without writing anything. */\nexport function renderDictionaryFile(df: DictionaryFile): string {\n const code = generateCode(df.mod as any).code;\n return df.endsWithNewline && !code.endsWith(\"\\n\") ? `${code}\\n` : code;\n}\n\nexport async function saveDictionaryFile(df: DictionaryFile): Promise<void> {\n await writeFile(df.mod, df.file);\n if (df.endsWithNewline) {\n const text = fs.readFileSync(df.file, \"utf-8\");\n if (!text.endsWith(\"\\n\")) fs.writeFileSync(df.file, text + \"\\n\", \"utf-8\");\n }\n}\n\nexport function listLocales(df: DictionaryFile): string[] {\n return df.localesObj.properties\n .filter(isPropLike)\n .map(keyName)\n .filter((k: string | undefined): k is string => k !== undefined);\n}\n\nfunction localeObject(df: DictionaryFile, locale: string): Node | undefined {\n const value = unwrap(findProp(df.localesObj, locale)?.value);\n return isObject(value) ? value : undefined;\n}\n\n/** Lists every leaf (string, function, or other value) of a locale, in source order. */\nexport function listLeaves(df: DictionaryFile, locale: string): Leaf[] {\n const root = localeObject(df, locale);\n if (!root) return [];\n\n const leaves: Leaf[] = [];\n const walk = (obj: Node, prefix: string[]) => {\n for (const prop of obj.properties) {\n if (!isPropLike(prop)) continue;\n const name = keyName(prop);\n if (name === undefined) continue;\n const path = [...prefix, name];\n const value = prop.type === \"ObjectMethod\" ? prop : unwrap(prop.value);\n if (isObject(value)) {\n walk(value, path);\n } else {\n const kind = leafKind(value);\n leaves.push({ path, kind, ...(kind === \"string\" ? { value: stringValue(value) } : {}) });\n }\n }\n };\n walk(root, []);\n return leaves;\n}\n\nfunction getProp(df: DictionaryFile, locale: string, path: string[]): Node | undefined {\n let obj = localeObject(df, locale);\n for (let i = 0; obj && i < path.length; i++) {\n const prop = findProp(obj, path[i]);\n if (!prop) return undefined;\n if (i === path.length - 1) return prop;\n const next = unwrap(prop.value);\n obj = isObject(next) ? next : undefined;\n }\n return undefined;\n}\n\nexport function hasPath(df: DictionaryFile, locale: string, path: string[]): boolean {\n return getProp(df, locale, path) !== undefined;\n}\n\nexport function getString(df: DictionaryFile, locale: string, path: string[]): string | undefined {\n const prop = getProp(df, locale, path);\n return prop && prop.type !== \"ObjectMethod\" ? stringValue(prop.value) : undefined;\n}\n\nfunction ensureLocale(df: DictionaryFile, locale: string): Node {\n let obj = localeObject(df, locale);\n if (!obj) {\n const prop = makeProp(locale, \"{}\");\n df.localesObj.properties.push(prop);\n obj = prop.value as Node;\n }\n return obj;\n}\n\n/** Returns the object that should contain the last path segment, creating objects as needed. */\nfunction ensureParent(df: DictionaryFile, locale: string, path: string[]): Node | undefined {\n let obj = ensureLocale(df, locale);\n for (const segment of path.slice(0, -1)) {\n let prop = findProp(obj, segment);\n if (!prop) {\n prop = makeProp(segment, \"{}\");\n obj.properties.push(prop);\n }\n const next = unwrap(prop.value);\n if (!isObject(next)) return undefined;\n obj = next;\n }\n return obj;\n}\n\nexport type SetResult = \"created\" | \"updated\" | \"skipped\";\n\n/**\n * Sets a string value at `path`. Existing function or non-string values are left alone\n * (`\"skipped\"`) because they cannot be translated as plain text.\n */\nexport function setString(\n df: DictionaryFile,\n locale: string,\n path: string[],\n value: string,\n): SetResult {\n const parent = ensureParent(df, locale, path);\n if (!parent) return \"skipped\";\n\n const last = path[path.length - 1];\n const existing = findProp(parent, last);\n if (existing) {\n if (existing.type === \"ObjectMethod\" || leafKind(existing.value) !== \"string\") {\n return \"skipped\";\n }\n existing.value = makeStringNode(value);\n return \"updated\";\n }\n parent.properties.push(makeProp(last, JSON.stringify(value)));\n return \"created\";\n}\n\n/**\n * Copies the leaf at `path` from one locale to another. String values can be rewritten with\n * `mapString` (for example to add a `[TODO]` marker); other values are copied verbatim.\n * Returns `false` when the source has no such leaf or the target already has one.\n */\nexport function copyLeaf(\n df: DictionaryFile,\n fromLocale: string,\n toLocale: string,\n path: string[],\n mapString?: (value: string) => string,\n): boolean {\n const source = getProp(df, fromLocale, path);\n if (!source || hasPath(df, toLocale, path)) return false;\n\n const parent = ensureParent(df, toLocale, path);\n if (!parent) return false;\n\n const last = path[path.length - 1];\n const text = source.type === \"ObjectMethod\" ? undefined : stringValue(source.value);\n if (text !== undefined && mapString) {\n parent.properties.push(makeProp(last, JSON.stringify(mapString(text))));\n } else {\n const code = generateCode(source as any).code;\n const expr: Node = parseExpression(`({ ${code} })`);\n parent.properties.push(expr.$ast.properties[0]);\n }\n return true;\n}\n\n/** Leaf paths of a runtime dictionary value (plain objects recurse; everything else is a leaf). */\nexport function flattenPaths(value: unknown, prefix: string[] = []): string[][] {\n if (value && typeof value === \"object\" && !Array.isArray(value)) {\n return Object.entries(value).flatMap(([k, v]) => flattenPaths(v, [...prefix, k]));\n }\n return prefix.length > 0 ? [prefix] : [];\n}\n\nconst toRange = (loc: Node | undefined): SourceRange | undefined =>\n loc\n ? {\n start: { line: loc.start.line - 1, column: loc.start.column },\n end: { line: loc.end.line - 1, column: loc.end.column },\n }\n : undefined;\n\n/**\n * Where a locale (no `path`) or a key within it is written. The range covers the property key, so\n * it is a good place to attach a diagnostic or jump to.\n */\nexport function locationOf(\n df: DictionaryFile,\n locale: string,\n path: string[] = [],\n): SourceRange | undefined {\n const prop = path.length === 0 ? findProp(df.localesObj, locale) : getProp(df, locale, path);\n return toRange((prop?.key ?? prop)?.loc);\n}\n\n/** The source text of the dictionary object itself (the object whose keys are locales). */\nexport function dictionaryLocation(df: DictionaryFile): SourceRange | undefined {\n return toRange(df.localesObj.loc);\n}\n\n/** The source code of a leaf's value (a function's source, or a string with its quotes). */\nexport function getLeafSource(\n df: DictionaryFile,\n locale: string,\n path: string[],\n): string | undefined {\n const prop = getProp(df, locale, path);\n if (!prop) return undefined;\n return generateCode((prop.type === \"ObjectMethod\" ? prop : prop.value) as any).code;\n}\n\n// AST helpers shared with the static config reader.\nexport {\n unwrap as unwrapNode,\n isObject as isObjectNode,\n keyName as propertyKeyName,\n findProp as findProperty,\n};\nexport type { Node as AstNode };\n","import {\n argumentSignature,\n findPlurals,\n getArguments,\n isIcuStructured,\n parseMessage,\n type IcuNode,\n} from \"dialexjs/icu\";\n\nexport interface IcuFinding {\n level: \"error\" | \"warning\";\n code: \"invalid-icu\" | \"icu-args-mismatch\" | \"icu-plural-categories\";\n locale: string;\n /** Dotted key including the dictionary name, e.g. `cart.items`. */\n key: string;\n message: string;\n}\n\n/** `locale -> dotted path within the dictionary -> string value` */\nexport type LocaleStrings = Map<string, Map<string, string>>;\n\n/** CLDR order. `resolvedOptions().pluralCategories` order differs between Node versions. */\nconst CATEGORY_ORDER = [\"zero\", \"one\", \"two\", \"few\", \"many\"];\n\nfunction requiredCategories(locale: string, ordinal: boolean): string[] {\n try {\n return new Intl.PluralRules(locale, { type: ordinal ? \"ordinal\" : \"cardinal\" })\n .resolvedOptions()\n .pluralCategories.filter((c) => c !== \"other\")\n .sort((a, b) => CATEGORY_ORDER.indexOf(a) - CATEGORY_ORDER.indexOf(b));\n } catch {\n return []; // not a valid BCP 47 tag; nothing to compare against\n }\n}\n\n/**\n * Validates ICU messages across the locales of one dictionary:\n *\n * - invalid syntax: an error for messages that clearly use ICU (plural/select/number/date/time),\n * a warning for plain `{placeholders}` that do not parse (they may not be meant as ICU);\n * - every locale must use the same arguments as the reference locale;\n * - plural options should cover the categories the locale's plural rules need.\n */\nexport function checkIcu(\n dictionary: string,\n strings: LocaleStrings,\n defaultLocale: string,\n): IcuFinding[] {\n const findings: IcuFinding[] = [];\n const parsed = new Map<string, Map<string, IcuNode[]>>();\n\n for (const [locale, entries] of strings) {\n const ok = new Map<string, IcuNode[]>();\n for (const [path, value] of entries) {\n if (!value.includes(\"{\")) continue;\n const key = `${dictionary}.${path}`;\n try {\n ok.set(path, parseMessage(value));\n } catch (error) {\n const structured = isIcuStructured(value);\n findings.push({\n level: structured ? \"error\" : \"warning\",\n code: \"invalid-icu\",\n locale,\n key,\n message: structured\n ? `Invalid ICU message \"${key}\" (${locale}): ${(error as Error).message}`\n : `\"${key}\" (${locale}) contains braces but is not valid ICU, so t() values cannot be applied: ${(error as Error).message}`,\n });\n }\n }\n parsed.set(locale, ok);\n }\n\n // Compare every locale against the reference (default locale first)\n const order = [defaultLocale, ...[...parsed.keys()].filter((l) => l !== defaultLocale)];\n const paths = new Set([...parsed.values()].flatMap((m) => [...m.keys()]));\n\n for (const path of paths) {\n const key = `${dictionary}.${path}`;\n const reference = order.find((l) => parsed.get(l)?.has(path));\n if (!reference) continue;\n const expected = argumentSignature(parsed.get(reference)!.get(path)!);\n\n for (const locale of order) {\n const nodes = parsed.get(locale)?.get(path);\n if (nodes && locale !== reference) {\n const found = argumentSignature(nodes);\n if (found !== expected) {\n findings.push({\n level: \"error\",\n code: \"icu-args-mismatch\",\n locale,\n key,\n message: `Locale \"${locale}\" uses different arguments than \"${reference}\" for \"${key}\" (expected ${expected || \"none\"}, found ${found || \"none\"})`,\n });\n }\n }\n if (!nodes) continue;\n\n for (const plural of findPlurals(nodes)) {\n const missing = requiredCategories(locale, plural.ordinal).filter(\n (c) => !(c in plural.options),\n );\n if (missing.length > 0) {\n findings.push({\n level: \"warning\",\n code: \"icu-plural-categories\",\n locale,\n key,\n message: `Locale \"${locale}\" plural \"${plural.name}\" in \"${key}\" has no ${missing.map((c) => `\"${c}\"`).join(\", \")} option (used by this language; \"other\" will be shown instead)`,\n });\n }\n }\n }\n }\n\n return findings;\n}\n\n/** Arguments of a message, or `undefined` when it does not parse. */\nexport function tryGetArguments(message: string) {\n try {\n return getArguments(parseMessage(message));\n } catch {\n return undefined;\n }\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\nimport fg from \"fast-glob\";\nimport {\n TODO_PREFIX,\n dictionaryLocation,\n flattenPaths,\n listLeaves,\n listLocales,\n loadDictionaryFile,\n locationOf,\n type DictionaryFile,\n type SourceRange,\n} from \"./utils/dictionary-edit.js\";\nimport { checkIcu, type LocaleStrings } from \"./utils/icu-check.js\";\n\n/**\n * Project analysis shared by `dialex check` and the editor extension.\n *\n * It reads dictionaries from the syntax tree, so it never runs project code. Dictionaries that\n * cannot be read that way (spreads, computed keys, imported values) are skipped with an `info`\n * issue, unless `runtime: true` is passed, in which case they are imported and read from the\n * evaluated module (the CLI does this; editors must not).\n */\n\nexport type IssueLevel = \"error\" | \"warning\" | \"info\";\n\nexport type IssueCode =\n | \"invalid-dictionary\"\n | \"unanalyzable\"\n | \"missing-locale\"\n | \"missing-key\"\n | \"invalid-locale\"\n | \"todo-placeholder\"\n | \"invalid-icu\"\n | \"icu-args-mismatch\"\n | \"icu-plural-categories\"\n | \"unknown-dictionary\"\n | \"unknown-path\"\n | \"unused-key\"\n | \"unused-dictionary\";\n\nexport interface AnalysisIssue {\n /** Absolute path of the file the issue is in. */\n file: string;\n level: IssueLevel;\n code: IssueCode;\n message: string;\n /** Where to point, when known. Lines and columns are zero-based. */\n range?: SourceRange;\n /** The dictionary the issue is about, when it is about one. */\n dictionary?: string;\n locale?: string;\n /** Key path within the dictionary. */\n path?: string[];\n /** For `missing-key`: a locale that has the key, to copy it from. */\n sourceLocale?: string;\n}\n\nexport interface AnalysisConfig {\n defaultLocale?: string;\n locales?: string[];\n include?: string | string[];\n}\n\nexport interface AnalysisOptions {\n root: string;\n config: AnalysisConfig;\n /** Source globs to scan for dictionary references. Pass `[]` to skip scanning. */\n src?: string[];\n /** Import dictionaries the syntax tree cannot fully describe. Runs project code. */\n runtime?: boolean;\n /** Extra ignore globs, relative to `root`. */\n ignore?: string[];\n /** Report possibly unused keys and dictionaries. @default true */\n unused?: boolean;\n}\n\nexport interface LeafInfo {\n kind: \"string\" | \"function\" | \"other\";\n value?: string;\n}\n\nexport interface AnalyzedDictionary {\n name: string;\n /** Absolute path. */\n file: string;\n /** Locales in source order. */\n locales: string[];\n /** `locale -> dotted path -> leaf` */\n leaves: Map<string, Map<string, LeafInfo>>;\n /** Union of dotted leaf paths across locales, in order of first appearance. */\n paths: string[];\n /** The parsed file, present when it was read statically. */\n df?: DictionaryFile;\n}\n\nexport interface AnalysisResult {\n issues: AnalysisIssue[];\n dictionaries: AnalyzedDictionary[];\n /** Absolute paths of every dictionary file that matched. */\n files: string[];\n sourceFilesScanned: number;\n}\n\nconst DICTIONARY_IGNORE = [\"**/node_modules/**\", \"**/dist/**\", \"**/.next/**\"];\n\nexport const DEFAULT_SOURCE_GLOB = \"**/*.{ts,tsx,js,jsx,mjs,cjs,vue,svelte,astro,mdx}\";\nconst SOURCE_IGNORE = [\n ...DICTIONARY_IGNORE,\n \"**/.nuxt/**\",\n \"**/.output/**\",\n \"**/.svelte-kit/**\",\n \"**/.astro/**\",\n \"**/coverage/**\",\n \"**/graphify-out/**\",\n \"**/*.d.ts\",\n \"**/i18n.generated.*\",\n \"**/dialex.config.*\",\n \"**/i18n.config.*\",\n];\n\n/** `getDictionary(\"x\")`, `useDictionary(\"x\")`, `@I18nDictionary(\"x\")` */\nconst DICTIONARY_CALL =\n /\\b(?:getDictionary|useDictionary|I18nDictionary)\\(\\s*([\"'`])([^\"'`$\\n]+)\\1/dg;\n/** `t(\"dictionary.path.to.key\")` */\nconst T_CALL = /(?<![\\w$.])t\\(\\s*([\"'`])([\\w-]+(?:\\.[\\w-]+)+)\\1/dg;\n\nexport interface Reference {\n /** A dictionary name, or a full `dictionary.key.path`. */\n kind: \"dictionary\" | \"path\";\n value: string;\n /** Offsets of the string's contents (without the quotes) in the scanned text. */\n start: number;\n end: number;\n}\n\n/** Finds `getDictionary(\"x\")`-style and `t(\"x.y.z\")` references in source text. */\nexport function scanReferences(text: string): Reference[] {\n const references: Reference[] = [];\n const collect = (pattern: RegExp, kind: Reference[\"kind\"]) => {\n for (const match of text.matchAll(pattern)) {\n const [start, end] = match.indices![2] as [number, number];\n references.push({ kind, value: match[2], start, end });\n }\n };\n collect(DICTIONARY_CALL, \"dictionary\");\n collect(T_CALL, \"path\");\n return references.sort((a, b) => a.start - b.start);\n}\n\nfunction lineStarts(text: string): number[] {\n const starts = [0];\n for (let i = 0; i < text.length; i++) if (text.charCodeAt(i) === 10) starts.push(i + 1);\n return starts;\n}\n\nfunction positionAt(starts: number[], offset: number) {\n let low = 0;\n let high = starts.length - 1;\n while (low < high) {\n const mid = Math.ceil((low + high) / 2);\n if (starts[mid] <= offset) low = mid;\n else high = mid - 1;\n }\n return { line: low, column: offset - starts[low] };\n}\n\ninterface DictionaryData {\n name: string;\n locales: string[];\n leaves: Map<string, Map<string, LeafInfo>>;\n df?: DictionaryFile;\n}\n\ntype Loaded =\n | { ok: true; data: DictionaryData }\n | { ok: false; level: IssueLevel; code: IssueCode; message: string };\n\nfunction fromSyntaxTree(df: DictionaryFile): DictionaryData {\n const locales = listLocales(df);\n const leaves = new Map<string, Map<string, LeafInfo>>();\n for (const locale of locales) {\n const entries = new Map<string, LeafInfo>();\n for (const leaf of listLeaves(df, locale)) {\n entries.set(leaf.path.join(\".\"), { kind: leaf.kind, value: leaf.value });\n }\n leaves.set(locale, entries);\n }\n return { name: df.name!, locales, leaves, df };\n}\n\nasync function fromRuntime(file: string): Promise<Loaded> {\n try {\n const mod = await import(`${pathToFileURL(file).href}?t=${Date.now()}_${Math.random()}`);\n const definition = mod.default || mod;\n if (!definition || typeof definition !== \"object\" || !definition.dictionary) {\n return {\n ok: false,\n level: \"error\",\n code: \"invalid-dictionary\",\n message: \"Default export does not appear to be a valid defineDictionary output.\",\n };\n }\n\n const dictionary = definition.dictionary as Record<string, Record<string, any>>;\n const leaves = new Map<string, Map<string, LeafInfo>>();\n const invalid: string[] = [];\n\n for (const [locale, content] of Object.entries(dictionary)) {\n if (!content || typeof content !== \"object\") {\n invalid.push(locale);\n continue;\n }\n const entries = new Map<string, LeafInfo>();\n for (const leafPath of flattenPaths(content)) {\n let value: any = content;\n for (const segment of leafPath) value = value?.[segment];\n entries.set(\n leafPath.join(\".\"),\n typeof value === \"string\"\n ? { kind: \"string\", value }\n : { kind: typeof value === \"function\" ? \"function\" : \"other\" },\n );\n }\n leaves.set(locale, entries);\n }\n\n if (invalid.length > 0) {\n return {\n ok: false,\n level: \"error\",\n code: \"invalid-locale\",\n message: invalid.map((l) => `Locale \"${l}\" content is empty or invalid.`).join(\"\\n\"),\n };\n }\n\n return {\n ok: true,\n data: { name: String(definition.name ?? \"\"), locales: [...leaves.keys()], leaves },\n };\n } catch (error: any) {\n return {\n ok: false,\n level: \"error\",\n code: \"invalid-dictionary\",\n message: `Failed to import dictionary: ${error.message || String(error)}`,\n };\n }\n}\n\nasync function loadDictionaryData(file: string, runtime: boolean): Promise<Loaded> {\n let astError: Error | undefined;\n try {\n const df = await loadDictionaryFile(file);\n if (df?.complete && df.name) return { ok: true, data: fromSyntaxTree(df) };\n } catch (error) {\n astError = error as Error;\n }\n\n if (runtime) return fromRuntime(file);\n\n return astError\n ? {\n ok: false,\n level: \"error\",\n code: \"invalid-dictionary\",\n message: `Failed to parse dictionary: ${astError.message}`,\n }\n : {\n ok: false,\n level: \"info\",\n code: \"unanalyzable\",\n message:\n \"This dictionary uses spreads, computed keys, imported values, or a computed name, so it cannot be analyzed statically.\",\n };\n}\n\nexport async function analyzeProject(options: AnalysisOptions): Promise<AnalysisResult> {\n const { root, config } = options;\n const include = config.include || \"**/*.content.ts\";\n const configuredLocales = config.locales || [];\n const defaultLocale = config.defaultLocale || \"en\";\n const extraIgnore = options.ignore ?? [];\n\n const files = fg.sync(include, {\n cwd: root,\n absolute: true,\n ignore: [...DICTIONARY_IGNORE, ...extraIgnore],\n });\n\n const issues: AnalysisIssue[] = [];\n const dictionaries: AnalyzedDictionary[] = [];\n\n // 1. Dictionaries: parity, placeholders, ICU\n for (const file of files) {\n const loaded = await loadDictionaryData(file, options.runtime === true);\n if (!loaded.ok) {\n for (const message of loaded.message.split(\"\\n\")) {\n issues.push({ file, level: loaded.level, code: loaded.code, message });\n }\n continue;\n }\n\n const { data } = loaded;\n const { df } = data;\n const at = (locale?: string, keyPath?: string[]) =>\n df && locale ? locationOf(df, locale, keyPath) : undefined;\n const add = (issue: Omit<AnalysisIssue, \"file\" | \"dictionary\">) =>\n issues.push({ ...issue, file, dictionary: data.name });\n\n for (const required of configuredLocales) {\n if (!data.locales.includes(required)) {\n add({\n level: \"error\",\n code: \"missing-locale\",\n message: `Missing configured locale \"${required}\"`,\n range: df ? dictionaryLocation(df) : undefined,\n locale: required,\n });\n }\n }\n\n const paths: string[] = [];\n const seen = new Set<string>();\n for (const locale of data.locales) {\n for (const leafPath of data.leaves.get(locale)!.keys()) {\n if (!seen.has(leafPath)) {\n seen.add(leafPath);\n paths.push(leafPath);\n }\n }\n }\n\n for (const locale of data.locales) {\n const present = data.leaves.get(locale)!;\n for (const leafPath of paths) {\n if (present.has(leafPath)) continue;\n const sourceLocale = [defaultLocale, ...data.locales].find(\n (l) => l !== locale && data.leaves.get(l)?.has(leafPath),\n );\n add({\n level: \"error\",\n code: \"missing-key\",\n message: `Locale \"${locale}\" is missing key \"${leafPath}\"`,\n range: at(locale),\n locale,\n path: leafPath.split(\".\"),\n sourceLocale,\n });\n }\n }\n\n const strings: LocaleStrings = new Map();\n for (const locale of data.locales) {\n const entries = new Map<string, string>();\n strings.set(locale, entries);\n for (const [leafPath, leaf] of data.leaves.get(locale)!) {\n if (leaf.kind !== \"string\" || leaf.value === undefined) continue;\n entries.set(leafPath, leaf.value);\n if (leaf.value.startsWith(TODO_PREFIX)) {\n add({\n level: \"warning\",\n code: \"todo-placeholder\",\n message: `Locale \"${locale}\" key \"${leafPath}\" still has a ${TODO_PREFIX.trim()} placeholder`,\n range: at(locale, leafPath.split(\".\")),\n locale,\n path: leafPath.split(\".\"),\n });\n }\n }\n }\n\n for (const finding of checkIcu(data.name, strings, defaultLocale)) {\n const keyPath = finding.key.slice(data.name.length + 1).split(\".\");\n add({\n level: finding.level,\n code: finding.code,\n message: finding.message,\n range: at(finding.locale, keyPath),\n locale: finding.locale,\n path: keyPath,\n });\n }\n\n dictionaries.push({\n name: data.name,\n file,\n locales: data.locales,\n leaves: data.leaves,\n paths,\n df,\n });\n }\n\n // 2. Source code: references to dictionaries and keys\n const known = new Map(dictionaries.map((d) => [d.name, d]));\n const dictionaryFiles = new Set(files);\n const sourceGlobs = options.src ?? [DEFAULT_SOURCE_GLOB];\n const sourceFiles =\n sourceGlobs.length === 0\n ? []\n : fg\n .sync(sourceGlobs, {\n cwd: root,\n absolute: true,\n ignore: [...SOURCE_IGNORE, ...extraIgnore],\n })\n .filter((f) => !dictionaryFiles.has(f));\n\n if (sourceFiles.length > 0) {\n const tokens = new Set<string>();\n\n for (const file of sourceFiles) {\n let text: string;\n try {\n text = fs.readFileSync(file, \"utf-8\");\n } catch {\n continue;\n }\n for (const token of text.match(/[\\w$-]+/g) ?? []) tokens.add(token);\n\n const starts = lineStarts(text);\n const rangeOf = (start: number, end: number): SourceRange => ({\n start: positionAt(starts, start),\n end: positionAt(starts, end),\n });\n\n for (const ref of scanReferences(text)) {\n if (ref.kind === \"dictionary\") {\n if (!known.has(ref.value)) {\n issues.push({\n file,\n level: \"error\",\n code: \"unknown-dictionary\",\n message: `Unknown dictionary \"${ref.value}\"`,\n range: rangeOf(ref.start, ref.end),\n dictionary: ref.value,\n });\n }\n continue;\n }\n\n const [name, ...rest] = ref.value.split(\".\");\n const dictionary = known.get(name);\n if (!dictionary) continue; // `t(...)` may belong to another library\n const keyPath = rest.join(\".\");\n const exists = dictionary.paths.some((p) => p === keyPath || p.startsWith(`${keyPath}.`));\n if (!exists) {\n issues.push({\n file,\n level: \"error\",\n code: \"unknown-path\",\n message: `Unknown translation path \"${ref.value}\"`,\n range: rangeOf(ref.start, ref.end),\n dictionary: name,\n path: rest,\n });\n }\n }\n }\n\n // 3. Possibly unused dictionaries and keys (heuristic: warnings only)\n if (options.unused !== false) {\n for (const dictionary of dictionaries) {\n if (!tokens.has(dictionary.name)) {\n issues.push({\n file: dictionary.file,\n level: \"warning\",\n code: \"unused-dictionary\",\n message: `Dictionary \"${dictionary.name}\" is never referenced`,\n range: dictionary.df ? dictionaryLocation(dictionary.df) : undefined,\n dictionary: dictionary.name,\n });\n continue;\n }\n for (const keyPath of dictionary.paths) {\n const last = keyPath.split(\".\").pop()!;\n if (tokens.has(last)) continue;\n const holder = dictionary.locales.find((l) => dictionary.leaves.get(l)?.has(keyPath));\n issues.push({\n file: dictionary.file,\n level: \"warning\",\n code: \"unused-key\",\n message: `Key \"${keyPath}\" is possibly unused`,\n range:\n dictionary.df && holder\n ? locationOf(dictionary.df, holder, keyPath.split(\".\"))\n : undefined,\n dictionary: dictionary.name,\n path: keyPath.split(\".\"),\n });\n }\n }\n }\n }\n\n return { issues, dictionaries, files, sourceFilesScanned: sourceFiles.length };\n}\n\n/** Project root-relative path with forward slashes, for display. */\nexport function relativeFile(root: string, file: string): string {\n return path.relative(root, file);\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport { parseModule } from \"magicast\";\nimport {\n findProperty,\n isObjectNode,\n propertyKeyName,\n unwrapNode,\n type AstNode,\n} from \"./dictionary-edit.js\";\n\n/**\n * The parts of `dialex.config` that tooling needs, read **without running the file**. Editors must\n * not execute workspace code (it may be untrusted), so values are read from the syntax tree and\n * only literals are understood.\n */\nexport interface StaticConfig {\n defaultLocale: string;\n locales: string[];\n include: string | string[];\n fallbacks: Record<string, string[]>;\n prefixDefault: boolean;\n lazy: boolean;\n}\n\nexport interface StaticConfigResult {\n config: StaticConfig;\n /** The file the values came from, if any. */\n file?: string;\n /** Things that could not be read statically, for example `locales: getLocales()`. */\n notes: string[];\n}\n\nconst CONFIG_NAMES = [\"dialex.config\", \"i18n.config\"];\nconst EXTENSIONS = [\"ts\", \"mts\", \"cts\", \"js\", \"mjs\", \"cjs\", \"json\"];\n\nexport const DEFAULT_STATIC_CONFIG: StaticConfig = {\n defaultLocale: \"en\",\n locales: [],\n include: \"**/*.content.ts\",\n fallbacks: {},\n prefixDefault: true,\n lazy: false,\n};\n\nconst NOT_LITERAL = Symbol(\"not literal\");\n\nfunction literal(node: AstNode | undefined): unknown {\n node = unwrapNode(node as AstNode);\n switch (node?.type) {\n case \"StringLiteral\":\n case \"NumericLiteral\":\n case \"BooleanLiteral\":\n return node.value;\n case \"Literal\":\n return node.value;\n case \"TemplateLiteral\":\n return node.expressions.length === 0 ? (node.quasis[0]?.value?.cooked ?? \"\") : NOT_LITERAL;\n case \"ArrayExpression\": {\n const items = node.elements.map((e: AstNode) => literal(e));\n return items.includes(NOT_LITERAL) ? NOT_LITERAL : items;\n }\n case \"ObjectExpression\": {\n const result: Record<string, unknown> = {};\n for (const prop of node.properties) {\n const key = propertyKeyName(prop);\n const value = key === undefined ? NOT_LITERAL : literal(prop.value);\n if (value === NOT_LITERAL) return NOT_LITERAL;\n result[key as string] = value;\n }\n return result;\n }\n default:\n return NOT_LITERAL;\n }\n}\n\n/** The object literal passed to `defineConfig({...})`, or exported directly. */\nfunction findConfigObject(declaration: AstNode): AstNode | undefined {\n const node = unwrapNode(declaration);\n if (node?.type === \"CallExpression\") return findConfigObject(node.arguments[0]);\n return isObjectNode(node) ? node : undefined;\n}\n\nconst isStringArray = (value: unknown): value is string[] =>\n Array.isArray(value) && value.every((v) => typeof v === \"string\");\n\nfunction apply(object: Record<string, unknown>, config: StaticConfig, notes: string[]) {\n const accept = <K extends keyof StaticConfig>(\n key: K,\n valid: (value: unknown) => boolean,\n expected: string,\n ) => {\n if (!(key in object)) return;\n const value = object[key];\n if (valid(value)) (config as any)[key] = value;\n else notes.push(`\"${key}\" could not be read statically (expected ${expected}).`);\n };\n\n accept(\"defaultLocale\", (v) => typeof v === \"string\" && v !== \"\", \"a string literal\");\n accept(\"locales\", isStringArray, \"an array of string literals\");\n accept(\n \"include\",\n (v) => typeof v === \"string\" || isStringArray(v),\n \"a string or array of strings\",\n );\n accept(\n \"fallbacks\",\n (v) =>\n typeof v === \"object\" && v !== null && Object.values(v).every((list) => isStringArray(list)),\n \"an object of string arrays\",\n );\n accept(\"prefixDefault\", (v) => typeof v === \"boolean\", \"true or false\");\n accept(\"lazy\", (v) => typeof v === \"boolean\", \"true or false\");\n}\n\n/** Reads a config file's source text. Exposed for tests and for unsaved buffers. */\nexport function parseStaticConfig(text: string, file = \"dialex.config.ts\"): StaticConfigResult {\n const notes: string[] = [];\n const config: StaticConfig = { ...DEFAULT_STATIC_CONFIG };\n\n if (file.endsWith(\".json\")) {\n try {\n const data = JSON.parse(text);\n if (data && typeof data === \"object\") apply(data, config, notes);\n } catch (error) {\n notes.push(`Could not parse ${path.basename(file)}: ${(error as Error).message}`);\n }\n return { config, file, notes };\n }\n\n try {\n const exported = (parseModule(text).exports as any).default;\n const object = findConfigObject(exported?.$ast?.declaration ?? exported?.$ast);\n if (!object) {\n notes.push(`${path.basename(file)} does not export a config object literal.`);\n } else {\n const values: Record<string, unknown> = {};\n for (const key of [\n \"defaultLocale\",\n \"locales\",\n \"include\",\n \"fallbacks\",\n \"prefixDefault\",\n \"lazy\",\n ]) {\n const prop = findProperty(object, key);\n if (!prop) continue;\n const value = literal(prop.value);\n if (value === NOT_LITERAL)\n notes.push(`\"${key}\" could not be read statically (not a literal).`);\n else values[key] = value;\n }\n apply(values, config, notes);\n }\n } catch (error) {\n notes.push(`Could not parse ${path.basename(file)}: ${(error as Error).message}`);\n }\n\n return { config, file, notes };\n}\n\n/** Reads `dialex.config.*` (or `i18n.config.*`) from `root`, or from `configFile` if given. */\nexport function readStaticConfig(root: string, configFile?: string): StaticConfigResult {\n const candidates = configFile\n ? [path.resolve(root, configFile)]\n : CONFIG_NAMES.flatMap((name) => EXTENSIONS.map((ext) => path.join(root, `${name}.${ext}`)));\n\n for (const file of candidates) {\n if (fs.existsSync(file)) return parseStaticConfig(fs.readFileSync(file, \"utf-8\"), file);\n }\n return { config: { ...DEFAULT_STATIC_CONFIG }, notes: [] };\n}\n","import path from \"node:path\";\nimport fg from \"fast-glob\";\nimport { resolveI18nConfig } from \"dialexjs/scanner\";\nimport type { I18nConfig } from \"dialexjs\";\nimport { loadDictionaryFile, type DictionaryFile } from \"./dictionary-edit.js\";\nimport { readStaticConfig } from \"./static-config.js\";\n\nexport interface ProjectDictionary {\n /** Path relative to the project root. */\n rel: string;\n name: string;\n df: DictionaryFile;\n}\n\nexport interface Project {\n root: string;\n config: I18nConfig;\n dictionaries: ProjectDictionary[];\n /** Dictionary files that could not be parsed into an editable shape. */\n unsupported: string[];\n /** Config values that could not be read statically (static loading only). */\n notes: string[];\n}\n\nasync function loadDictionaries(root: string, config: I18nConfig) {\n const include = config.include || \"**/*.content.ts\";\n const files = fg.sync(include, {\n cwd: root,\n absolute: true,\n ignore: [\"**/node_modules/**\", \"**/dist/**\", \"**/.next/**\"],\n });\n\n const dictionaries: ProjectDictionary[] = [];\n const unsupported: string[] = [];\n\n for (const file of files) {\n const rel = path.relative(root, file);\n try {\n const df = await loadDictionaryFile(file);\n if (!df || !df.name) unsupported.push(rel);\n else dictionaries.push({ rel, name: df.name, df });\n } catch {\n unsupported.push(rel); // syntax error: reported by the analysis, nothing to edit here\n }\n }\n\n return { dictionaries, unsupported };\n}\n\n/**\n * Resolves the config (running `dialex.config.*` through the loader, which executes it) and loads\n * every dictionary file for AST-level reading and editing.\n */\nexport async function loadProject(root: string, configFile?: string): Promise<Project> {\n const config = resolveI18nConfig(root, configFile ? { configFile } : {});\n return { root, config, notes: [], ...(await loadDictionaries(root, config)) };\n}\n\n/**\n * Like `loadProject`, but reads the config from the syntax tree without executing it. Use this in\n * editors and anywhere project code must not run.\n */\nexport async function loadStaticProject(root: string, configFile?: string): Promise<Project> {\n const { config, notes } = readStaticConfig(root, configFile);\n return { root, config, notes, ...(await loadDictionaries(root, config)) };\n}\n\n/** `home` + `[\"nav\", \"about\"]` -> `home.nav.about` */\nexport const toKey = (dictionary: string, keyPath: string[]) => [dictionary, ...keyPath].join(\".\");\n"],"mappings":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