@dialexjs/cli 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +86 -3
- package/dist/api.d.mts +229 -0
- package/dist/api.d.mts.map +1 -0
- package/dist/api.mjs +2 -0
- package/dist/index.d.mts +1 -0
- package/dist/index.mjs +1088 -0
- package/dist/index.mjs.map +1 -0
- package/dist/project-D4PmfqxM.mjs +883 -0
- package/dist/project-D4PmfqxM.mjs.map +1 -0
- package/dist/translate/index.d.mts +92 -0
- package/dist/translate/index.d.mts.map +1 -0
- package/dist/translate/index.mjs +289 -0
- package/dist/translate/index.mjs.map +1 -0
- package/package.json +50 -4
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../src/utils/logger.ts","../src/commands/generate.ts","../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 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}\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 content = `// Auto-generated by dialex CLI. Do not edit directly.\n/* eslint-disable */\n// @ts-nocheck\n${importLines.join(\"\\n\")}\n\nexport const dictionaries = [\n ${dictIdentifiers.join(\",\\n \")}\n];\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\n const doGenerate = () => {\n try {\n const { files, outputPath, dtsPath } = generateDictionaries(root, options);\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 } catch (err: any) {\n logger.error(`Generation failed: ${err.message || String(err)}`);\n }\n };\n\n doGenerate();\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 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}\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 } 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. 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}\n\nexport interface ExportResult {\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 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 return { files, keys: orderedKeys.size, skippedFunctions, skippedFiles: project.unsupported };\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}\n\nexport interface ImportEntry {\n locale: string;\n key: string;\n value: string;\n}\n\nexport interface ImportResult {\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 result: ImportResult = {\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 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 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}\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 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 result: TranslateResult = {\n dryRun: options.dryRun === true,\n pending: tasks,\n translated: 0,\n rejected: [],\n };\n\n if (tasks.length === 0) {\n logger.success(`Nothing to translate from \"${source}\".`);\n return result;\n }\n\n if (options.dryRun) {\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 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 logger.info(\n `Translating ${unique.length} string${unique.length === 1 ? \"\" : \"s\"} to \"${locale}\" with ${provider!.name ?? \"provider\"}...`,\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 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 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.1.0\");\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 .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 .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 .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 .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 .action(async (opts) => {\n try {\n await runTranslate(opts);\n } catch (err: any) {\n logger.error(err.message || String(err));\n process.exit(1);\n }\n });\n\nprogram.parse();\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,OAAO,QAAgB,QAAQ,KAAK,GAAG,OAAO,IAAI,IAAI,GAAG;CACzD,QAAQ,QAAgB,QAAQ,MAAM,GAAG,IAAI,IAAI,IAAI,GAAG,KAAK,GAAG,CAAC;CACjE,MAAM,QAAgB,QAAQ,IAAI,GAAG;AACvC;;;ACMA,SAAgB,qBACd,MACA,UAA2B,CAAC,GAK5B;CACA,MAAM,eAAe,QAAQ,SAAS,EAAE,YAAY,QAAQ,OAAO,IAAI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