@dialexjs/cli 0.5.1 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="https://raw.githubusercontent.com/awaiden/dialex/main/assets/logo.png" alt="Dialex" width="96" height="96" />
|
|
3
|
+
</p>
|
|
4
|
+
|
|
1
5
|
# @dialexjs/cli
|
|
2
6
|
|
|
3
7
|
> High-performance CLI tool for Dialex internationalization (codegen, scaffolding, CI parity checking).
|
package/dist/api.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { A as
|
|
1
|
+
import { A as listLeaves, C as writeLock, D as getLeafSource, E as dictionaryLocation, F as renderDictionaryFile, I as saveDictionaryFile, L as setString, M as loadDictionaryFile, N as locationOf, O as getString, P as parseDictionaryText, T as copyLeaf, _ as hashSource, a as renderGenerated, c as parseStaticConfig, f as DEFAULT_SOURCE_GLOB, g as LOCK_FILE, h as scanReferences, i as generateDictionaries, j as listLocales, k as hasPath, l as readStaticConfig, m as relativeFile, n as loadStaticProject, p as analyzeProject, r as toKey, s as DEFAULT_STATIC_CONFIG, t as loadProject, v as isStale, w as TODO_PREFIX, x as readLock } from "./project-DquSNdz8.mjs";
|
|
2
2
|
export { DEFAULT_SOURCE_GLOB, DEFAULT_STATIC_CONFIG, LOCK_FILE, TODO_PREFIX, analyzeProject, copyLeaf, dictionaryLocation, generateDictionaries, getLeafSource, getString, hasPath, hashSource, isStale, listLeaves, listLocales, loadDictionaryFile, loadProject, loadStaticProject, locationOf, parseDictionaryText, parseStaticConfig, readLock, readStaticConfig, relativeFile, renderDictionaryFile, renderGenerated, saveDictionaryFile, scanReferences, setString, toKey, writeLock };
|
package/dist/index.mjs
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { A as
|
|
2
|
+
import { A as listLeaves, C as writeLock, I as saveDictionaryFile, L as setString, M as loadDictionaryFile, O as getString, S as record, T as copyLeaf, a as renderGenerated, b as lockPath, d as logger, g as LOCK_FILE, i as generateDictionaries, j as listLocales, k as hasPath, o as runGenerate, p as analyzeProject, r as toKey, t as loadProject, u as resolveDialexConfig, v as isStale, w as TODO_PREFIX, x as readLock, y as lockFor } from "./project-DquSNdz8.mjs";
|
|
3
3
|
import { Command } from "commander";
|
|
4
4
|
import fs from "node:fs";
|
|
5
5
|
import path from "node:path";
|
|
6
|
-
import { resolveDialexConfig } from "dialexjs/scanner";
|
|
7
6
|
import fg from "fast-glob";
|
|
8
7
|
import pc from "picocolors";
|
|
9
8
|
import { fileURLToPath } from "node:url";
|
|
@@ -12,7 +11,7 @@ import { argumentSignature, getArguments, isIcuStructured, parseMessage } from "
|
|
|
12
11
|
import * as p from "@clack/prompts";
|
|
13
12
|
import { addNuxtModule } from "magicast/helpers";
|
|
14
13
|
//#region package.json
|
|
15
|
-
var version = "0.
|
|
14
|
+
var version = "0.6.0";
|
|
16
15
|
//#endregion
|
|
17
16
|
//#region src/commands/check.ts
|
|
18
17
|
const DICTIONARY_IGNORE = [
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["pkg.version"],"sources":["../package.json","../src/commands/check.ts","../src/commands/export.ts","../src/commands/import.ts","../src/utils/detector.ts","../src/utils/package-json.ts","../src/commands/init.ts","../src/commands/lock.ts","../src/translate/placeholders.ts","../src/commands/translate.ts","../src/index.ts"],"sourcesContent":["","import fs from \"node:fs\";\nimport path from \"node:path\";\n\nimport { resolveDialexConfig } from \"dialexjs/scanner\";\nimport fg from \"fast-glob\";\nimport pc from \"picocolors\";\n\nimport { analyzeProject, type AnalysisIssue } from \"../analysis.js\";\nimport {\n TODO_PREFIX,\n copyLeaf,\n hasPath,\n listLeaves,\n listLocales,\n loadDictionaryFile,\n saveDictionaryFile,\n} from \"../utils/dictionary-edit.js\";\nimport { logger } from \"../utils/logger.js\";\nimport { renderGenerated } from \"./generate.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 /** Report translations whose source text changed since they were translated as errors. */\n failOnStale?: boolean;\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`, plus generated files it rewrote. */\n fixed: number;\n}\n\nconst DICTIONARY_IGNORE = [\n \"**/node_modules/**\",\n \"**/dist/**\",\n \"**/.next/**\",\n \"**/dialex.locales/**\",\n];\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\n/**\n * What a formatter (Prettier, Biome, oxfmt) can change without changing the code: whitespace,\n * quote style, quoted object keys and trailing commas. Comparing this form keeps `check` quiet\n * when your pre-commit hook formats the generated files.\n */\nexport function normalizeGenerated(text: string): string {\n return text\n .replace(/'/g, '\"')\n .replace(/\"([A-Za-z_$][\\w$]*)\"\\s*:/g, \"$1:\")\n .replace(/\\s+/g, \"\")\n .replace(/,(?=[\\]})])/g, \"\");\n}\n\n/**\n * Generated files that exist but no longer match the dictionaries and config. Nothing builds them\n * for you any more, so a stale `dialex.generated.ts` would otherwise fail silently at runtime.\n * With `fix` they are rewritten.\n */\nfunction staleGeneratedFiles(\n root: string,\n options: CheckOptions,\n): { stale: { file: string; message: string }[]; rewritten: number } {\n let rendered;\n try {\n rendered = renderGenerated(root, { config: options.config });\n } catch {\n return { stale: [], rewritten: 0 }; // not renderable (for example lazy mode with an unreadable name); `generate` reports it\n }\n const stale: { file: string; message: string }[] = [];\n let rewritten = 0;\n const targets: [string, string | undefined][] = [\n [rendered.outputPath, rendered.content],\n [rendered.dtsPath, rendered.dtsContent],\n ];\n // Per-locale modules belong to the same generation: once the generated file exists they must too\n if (fs.existsSync(rendered.outputPath)) {\n for (const extra of rendered.extraFiles) targets.push([extra.path, extra.content]);\n }\n for (const [file, content] of targets) {\n if (content === undefined) continue;\n const isExtra = rendered.extraFiles.some((f) => f.path === file);\n if (!fs.existsSync(file)) {\n if (!isExtra) continue;\n if (options.fix) {\n fs.mkdirSync(path.dirname(file), { recursive: true });\n fs.writeFileSync(file, content, \"utf-8\");\n rewritten++;\n } else {\n stale.push({\n file: path.relative(root, file),\n message: \"Missing. Run `dx generate` (or `dx check --fix`).\",\n });\n }\n continue;\n }\n if (normalizeGenerated(fs.readFileSync(file, \"utf-8\")) === normalizeGenerated(content))\n continue;\n if (options.fix) {\n fs.writeFileSync(file, content, \"utf-8\");\n rewritten++;\n } else {\n stale.push({\n file: path.relative(root, file),\n message:\n \"Out of date with your dictionaries or config. Run `dx generate` (or `dx check --fix`).\",\n });\n }\n }\n return { stale, rewritten };\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 = resolveDialexConfig(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 generated = staleGeneratedFiles(root, options);\n fixed += generated.rewritten;\n if (generated.rewritten > 0 && !quiet) {\n logger.success(\n `Regenerated ${generated.rewritten} out-of-date generated file${generated.rewritten === 1 ? \"\" : \"s\"}`,\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 (options.failOnStale && issue.code === \"stale-translation\") issue.level = \"error\";\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 for (const { file, message } of generated.stale) {\n let diag = byFile.get(file);\n if (!diag) {\n diag = { file, errors: [], warnings: [], annotations: [] };\n byFile.set(file, diag);\n }\n diag.errors.push(message);\n diag.annotations.push({ level: \"error\", message });\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\";\n\nimport { listLeaves, listLocales } from \"../utils/dictionary-edit.js\";\nimport { logger } from \"../utils/logger.js\";\nimport { loadProject, toKey } from \"../utils/project.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 || \"dialex-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\";\n\nimport { argumentSignature, parseMessage } from \"dialexjs/icu\";\n\nimport {\n getString,\n hasPath,\n listLocales,\n saveDictionaryFile,\n setString,\n} from \"../utils/dictionary-edit.js\";\nimport { lockFor, readLock, record, writeLock } from \"../utils/lockfile.js\";\nimport { logger } from \"../utils/logger.js\";\nimport { loadProject } from \"../utils/project.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 // With a lock file, imported translations are recorded against the current source text.\n const lockInUse = readLock(root) !== undefined;\n const sourceLocale = readLock(root)?.sourceLocale ?? project.config.defaultLocale ?? \"en\";\n const { lock } = lockFor(root, sourceLocale);\n let recorded = 0;\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 const sourceText = getString(dict.df, sourceLocale, keyPath);\n if (lockInUse && locale !== sourceLocale && sourceText !== undefined) {\n record(lock, locale, key, sourceText);\n recorded++;\n }\n }\n }\n if (recorded > 0) writeLock(root, lock);\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 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 { fileURLToPath } from \"node:url\";\n\n/** Version of this CLI, which the other Dialex packages share. Read from the nearest package.json. */\nexport function cliVersion(): string | undefined {\n let dir = path.dirname(fileURLToPath(import.meta.url));\n for (let i = 0; i < 4; i++) {\n try {\n const pkg = JSON.parse(fs.readFileSync(path.join(dir, \"package.json\"), \"utf-8\"));\n if (pkg.name === \"@dialexjs/cli\") return pkg.version;\n } catch {\n // keep walking up\n }\n dir = path.dirname(dir);\n }\n return undefined;\n}\n\n/** The install command for the package manager a project uses, judged by its lockfile. */\nexport function installCommand(root: string): string {\n const has = (file: string) => fs.existsSync(path.join(root, file));\n if (has(\"bun.lock\") || has(\"bun.lockb\")) return \"bun install\";\n if (has(\"pnpm-lock.yaml\")) return \"pnpm install\";\n if (has(\"yarn.lock\")) return \"yarn install\";\n return \"npm install\";\n}\n\ntype Dependencies = Record<string, string>;\n\nconst sorted = (deps: Dependencies): Dependencies =>\n Object.fromEntries(Object.entries(deps).sort(([a], [b]) => a.localeCompare(b)));\n\n/**\n * Adds the packages a Dialex project needs: `dialexjs` as a dependency and the CLI as a dev\n * dependency (the `dx:generate` script runs it). Packages already listed anywhere are left alone.\n * Returns the names it added.\n */\nexport function addRequiredPackages(pkg: Record<string, any>, version = cliVersion()): string[] {\n const range = version ? `^${version}` : \"latest\";\n const listed = (name: string) =>\n [pkg.dependencies, pkg.devDependencies, pkg.peerDependencies].some(\n (deps) => deps && name in deps,\n );\n const added: string[] = [];\n\n if (!listed(\"dialexjs\")) {\n pkg.dependencies = sorted({ ...pkg.dependencies, dialexjs: range });\n added.push(\"dialexjs\");\n }\n if (!listed(\"@dialexjs/cli\")) {\n pkg.devDependencies = sorted({ ...pkg.devDependencies, \"@dialexjs/cli\": range });\n added.push(\"@dialexjs/cli\");\n }\n return added;\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\n\nimport * as p from \"@clack/prompts\";\nimport { parseModule, loadFile, writeFile } from \"magicast\";\nimport { addNuxtModule } from \"magicast/helpers\";\nimport pc from \"picocolors\";\n\nimport { detectFramework, type SupportedFramework } from \"../utils/detector.js\";\nimport { logger } from \"../utils/logger.js\";\nimport { addRequiredPackages, installCommand } from \"../utils/package-json.js\";\nimport { generateDictionaries } from \"./generate.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. Nuxt reads the generated file through its module; other frameworks need no config edits\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 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: required packages and the generate script\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 added = addRequiredPackages(pkg);\n pkg.scripts = pkg.scripts || {};\n const addScript = !pkg.scripts[\"dx:generate\"];\n if (addScript) pkg.scripts[\"dx:generate\"] = \"dx generate\";\n\n if (added.length > 0 || addScript) {\n fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + \"\\n\", \"utf-8\");\n }\n if (added.length > 0) {\n logger.success(`Added ${added.join(\" and \")} to package.json`);\n logger.info(`Run ${pc.bold(installCommand(root))} to install them.`);\n }\n if (addScript) logger.success('Added \"dx:generate\" script to package.json');\n } catch {\n logger.warn(\"Could not update package.json; add dialexjs and @dialexjs/cli manually.\");\n }\n } else {\n logger.warn(\"No package.json found; install dialexjs and @dialexjs/cli in your project.\");\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 { dialex } from \"dialexjs/hono\";\nimport dictionaries from \"./src/dialex.generated.js\";\n\nconst app = new Hono();\napp.use(\"*\", dialex({ 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 { dialexPlugin } from \"dialexjs/fastify\";\nimport dictionaries from \"./src/dialex.generated.js\";\n\nconst app = Fastify();\nawait app.register(dialexPlugin, { 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 { dialex } from \"dialexjs/express\";\nimport dictionaries from \"./src/dialex.generated.js\";\n\nconst app = express();\napp.use(dialex({ 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 { dialex } from \"dialexjs/koa\";\nimport dictionaries from \"./src/dialex.generated.js\";\n\nconst app = new Koa();\napp.use(dialex({ 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 { DialexModule } from \"dialexjs/nestjs\";\nimport dictionaries from \"./src/dialex.generated.js\";\n\n@Module({\n imports: [DialexModule.forRoot({ dictionaries })],\n})\nexport class AppModule {}\n`);\n break;\n case \"next\":\n logger.log(`\n// src/dialex.ts\nimport { createDialexServer } from \"dialexjs/server\";\nimport { dialex } from \"./dialex.generated\";\n\nexport const { getDictionary, getT } = createDialexServer(dialex);\n\n// app/[locale]/page.tsx (Server Component)\nimport { getDictionary } from \"../../dialex\";\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// For client components, render the provider inside a \"use client\" file:\n// \"use client\";\n// import { DialexProvider } from \"dialexjs/react\";\n// import { dialex } from \"./dialex.generated\";\n// export const Providers = ({ children }) => <DialexProvider {...dialex}>{children}</DialexProvider>;\n`);\n break;\n case \"react\":\n logger.log(`\n// src/main.tsx\nimport { createRoot } from \"react-dom/client\";\nimport { DialexProvider } from \"dialexjs/react\";\nimport { dialex } from \"./dialex.generated\";\nimport App from \"./App\";\n\ncreateRoot(document.getElementById(\"root\")!).render(\n <DialexProvider {...dialex}>\n <App />\n </DialexProvider>,\n);\n\n// In components: const dict = useDictionary(\"home\")\n`);\n break;\n case \"elysia\":\n logger.log(`\nimport { Elysia } from \"elysia\";\nimport { dialex } from \"dialexjs/elysia\";\nimport dictionaries from \"./src/dialex.generated.js\";\n\nnew Elysia()\n .use(dialex({ 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 { dialexHandle } from \"dialexjs/sveltekit\";\nimport dictionaries from \"./dialex.generated.js\";\n\nexport const handle = dialexHandle({ 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 { dialex } from \"dialexjs/astro\";\nimport dictionaries from \"./dialex.generated.js\";\n\nexport const onRequest = dialex({ 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 { createDialex } from \"dialexjs/vue\";\nimport { dialex } from \"./dialex.generated\";\nimport App from \"./App.vue\";\n\ncreateApp(App).use(createDialex({ ...dialex })).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 logger.info(\n \"Keep dialex.generated.ts current: run `dx generate --watch` while you develop, or use the Dialex VS Code extension, which regenerates on save.\",\n );\n\n if (isInteractive) {\n p.outro(pc.green(\"✔ dialex is configured and ready to go!\"));\n }\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\n\nimport pc from \"picocolors\";\n\nimport { TODO_PREFIX, listLeaves, listLocales } from \"../utils/dictionary-edit.js\";\nimport { LOCK_FILE, isStale, lockFor, lockPath, record, writeLock } from \"../utils/lockfile.js\";\nimport { logger } from \"../utils/logger.js\";\nimport { loadProject, toKey } from \"../utils/project.js\";\n\nexport interface LockOptions {\n cwd?: string;\n config?: string;\n /** Locale the translations were made from. Defaults to `translate.sourceLocale`, then `defaultLocale`. */\n source?: string;\n /** Also accept translations that are out of date (say they are fine as they are). */\n all?: boolean;\n /** Print machine-readable JSON instead of human output. */\n json?: boolean;\n}\n\nexport interface LockResult {\n success: boolean;\n sourceLocale: string;\n /** Translations newly recorded as up to date. */\n recorded: number;\n /** Keys that are still out of date (only without `--all`). */\n stale: string[];\n}\n\n/**\n * Records the current translations as up to date with the current source text, so later edits to\n * the source can be noticed. Translations that are already out of date are left alone unless\n * `--all` is given. Run it once when you adopt the lock file, and after reviewing stale ones.\n */\nexport async function runLock(options: LockOptions = {}): Promise<LockResult> {\n const root = options.cwd || process.cwd();\n const project = await loadProject(root, options.config);\n const source =\n options.source ??\n project.config.translate?.sourceLocale ??\n project.config.defaultLocale ??\n \"en\";\n const { lock } = lockFor(root, source);\n\n const result: LockResult = { success: true, sourceLocale: source, recorded: 0, stale: [] };\n\n for (const dict of project.dictionaries) {\n const sourceText = new Map(\n listLeaves(dict.df, source)\n .filter((leaf) => leaf.kind === \"string\" && leaf.value !== undefined)\n .map((leaf) => [leaf.path.join(\".\"), leaf.value!]),\n );\n\n for (const locale of listLocales(dict.df)) {\n if (locale === source) continue;\n for (const leaf of listLeaves(dict.df, locale)) {\n if (leaf.kind !== \"string\" || leaf.value === undefined) continue;\n if (leaf.value.startsWith(TODO_PREFIX)) continue; // not translated yet\n const text = sourceText.get(leaf.path.join(\".\"));\n if (text === undefined) continue;\n\n const key = toKey(dict.name, leaf.path);\n const known = lock.locales[locale]?.[key] !== undefined;\n if (known && isStale(lock, locale, key, text)) {\n if (!options.all) {\n result.stale.push(`${locale}:${key}`);\n continue;\n }\n } else if (known) {\n continue; // already recorded and current\n }\n record(lock, locale, key, text);\n result.recorded++;\n }\n }\n }\n\n if (result.recorded > 0 || !fs.existsSync(lockPath(root))) writeLock(root, lock);\n\n if (options.json) {\n console.log(JSON.stringify(result, null, 2));\n } else {\n logger.success(\n `Recorded ${result.recorded} translation${result.recorded === 1 ? \"\" : \"s\"} in ${path.basename(LOCK_FILE)} (source \"${source}\")`,\n );\n if (result.stale.length > 0) {\n logger.warn(\n `${result.stale.length} out of date and left as they are: ${result.stale.slice(0, 5).join(\", \")}${result.stale.length > 5 ? \", ...\" : \"\"}`,\n );\n logger.log(\n ` ${pc.dim(\"Re-translate them with\")} dialex translate --stale${pc.dim(\", or accept them with\")} dialex lock --all`,\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 type { TranslateProvider } from \"dialexjs\";\nimport { isIcuStructured } from \"dialexjs/icu\";\nimport pc from \"picocolors\";\n\nimport { preservesPlaceholders } from \"../translate/placeholders.js\";\nimport {\n TODO_PREFIX,\n listLeaves,\n listLocales,\n saveDictionaryFile,\n setString,\n} from \"../utils/dictionary-edit.js\";\nimport { isStale, lockFor, record, writeLock } from \"../utils/lockfile.js\";\nimport { logger } from \"../utils/logger.js\";\nimport { loadProject, toKey, type ProjectDictionary } from \"../utils/project.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 * Also re-translate strings whose source text changed since they were translated, according to\n * `dialex.lock.json`. Only these strings may replace an existing translation.\n */\n stale?: boolean;\n}\n\nexport interface PendingTranslation {\n file: string;\n locale: string;\n key: string;\n source: string;\n /** The translation existed but its source text has changed since. */\n stale?: boolean;\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 const { lock, replaced } = lockFor(root, source);\n if (replaced && !options.json) {\n logger.warn(\n `dialex.lock.json was recorded from another source locale; starting a new one from \"${source}\".`,\n );\n }\n\n // 1. Collect strings that are missing or still marked [TODO] (and, with --stale, out of date)\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 key = toKey(dict.name, leaf.path);\n const placeholder =\n !current || (current.kind === \"string\" && current.value?.startsWith(TODO_PREFIX));\n const stale =\n !placeholder &&\n options.stale === true &&\n current?.kind === \"string\" &&\n isStale(lock, locale, key, leaf.value!);\n if (placeholder || stale) {\n tasks.push({\n dict,\n path: leaf.path,\n file: dict.rel,\n locale,\n key,\n source: leaf.value!,\n ...(stale ? { stale: true } : {}),\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(\n ` ${pc.dim(t.locale)} ${t.key} ${pc.dim(JSON.stringify(t.source))}${t.stale ? pc.yellow(\" (out of date)\") : \"\"}`,\n );\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 record(lock, locale, task.key, task.source);\n result.translated++;\n touched.add(task.dict);\n }\n }\n\n for (const dict of touched) await saveDictionaryFile(dict.df);\n if (result.translated > 0) writeLock(root, lock);\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\";\n\nimport pkg from \"../package.json\" with { type: \"json\" };\nimport { runCheck } from \"./commands/check.js\";\nimport { runExport } from \"./commands/export.js\";\nimport { runGenerate } from \"./commands/generate.js\";\nimport { runImport } from \"./commands/import.js\";\nimport { runInit } from \"./commands/init.js\";\nimport { runLock } from \"./commands/lock.js\";\nimport { runTranslate } from \"./commands/translate.js\";\nimport { logger } from \"./utils/logger.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(pkg.version);\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(\"--fail-on-stale\", \"Treat translations whose source text changed as errors\")\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\", \"dialex-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(\n \"--stale\",\n \"Also re-translate strings whose source text changed since they were translated\",\n )\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\n .command(\"lock\")\n .description(\"Record translations as up to date with the current source text (dialex.lock.json)\")\n .option(\"-s, --source <locale>\", \"Locale the translations were made from\")\n .option(\"--all\", \"Also accept translations that are already out of date\")\n .option(\"--json\", \"Print machine-readable JSON\")\n .option(\"-c, --config <path>\", \"Custom config path\")\n .action(async (opts) => {\n try {\n await runLock(opts);\n } catch (err: any) {\n logger.error(err.message || String(err));\n process.exit(1);\n }\n });\n\nprogram.parse();\n"],"mappings":";;;;;;;;;;;;;;;;;AC2DA,MAAM,oBAAoB;CACxB;CACA;CACA;CACA;AACF;AAEA,SAAS,SAAS,MAAuB,OAAsB;CAC7D,MAAM,QAAQ,MAAM,UAAU,UAAU,UAAU;CAClD,CAAC,UAAU,UAAU,KAAK,SAAS,KAAK,SAAA,CAAU,KAAK,MAAM,OAAO;CACpE,KAAK,YAAY,KAAK;EACpB;EACA,SAAS,MAAM;EACf,MAAM,MAAM,QAAQ,MAAM,MAAM,MAAM,OAAO,IAAI,KAAA;CACnD,CAAC;AACH;;;;;AAMA,eAAe,WACb,OACA,mBACA,eACiB;CACjB,IAAI,QAAQ;CAEZ,KAAK,MAAM,QAAQ,OAAO;EACxB,MAAM,KAAK,MAAM,mBAAmB,IAAI;EAExC,IAAI,CAAC,IAAI,UAAU;EAEnB,MAAM,UAAU,YAAY,EAAE;EAC9B,MAAM,UAA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C,yBACA,kEACF,CAAC,CACA,OAAO,aAAa,4DAA4D,CAAC,CACjF,OACC,WACA,gFACF,CAAC,CACA,OAAO,uBAAuB,oBAAoB,CAAC,CACnD,OAAO,UAAU,6BAA6B,CAAC,CAC/C,OAAO,OAAO,SAAS;CACtB,IAAI;EACF,MAAM,aAAa,IAAI;CACzB,SAAS,KAAU;EACjB,IAAI,KAAK,MACP,QAAQ,IAAI,KAAK,UAAU;GAAE,SAAS;GAAO,OAAO,IAAI,WAAW,OAAO,GAAG;EAAE,GAAG,MAAM,CAAC,CAAC;OAE1F,OAAO,MAAM,IAAI,WAAW,OAAO,GAAG,CAAC;EAEzC,QAAQ,KAAK,CAAC;CAChB;AACF,CAAC;AAEH,QACG,QAAQ,MAAM,CAAC,CACf,YAAY,mFAAmF,CAAC,CAChG,OAAO,yBAAyB,wCAAwC,CAAC,CACzE,OAAO,SAAS,uDAAuD,CAAC,CACxE,OAAO,UAAU,6BAA6B,CAAC,CAC/C,OAAO,uBAAuB,oBAAoB,CAAC,CACnD,OAAO,OAAO,SAAS;CACtB,IAAI;EACF,MAAM,QAAQ,IAAI;CACpB,SAAS,KAAU;EACjB,OAAO,MAAM,IAAI,WAAW,OAAO,GAAG,CAAC;EACvC,QAAQ,KAAK,CAAC;CAChB;AACF,CAAC;AAEH,QAAQ,MAAM"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["pkg.version"],"sources":["../package.json","../src/commands/check.ts","../src/commands/export.ts","../src/commands/import.ts","../src/utils/detector.ts","../src/utils/package-json.ts","../src/commands/init.ts","../src/commands/lock.ts","../src/translate/placeholders.ts","../src/commands/translate.ts","../src/index.ts"],"sourcesContent":["","import fs from \"node:fs\";\nimport path from \"node:path\";\n\nimport fg from \"fast-glob\";\nimport pc from \"picocolors\";\n\nimport { analyzeProject, type AnalysisIssue } from \"../analysis.js\";\nimport {\n TODO_PREFIX,\n copyLeaf,\n hasPath,\n listLeaves,\n listLocales,\n loadDictionaryFile,\n saveDictionaryFile,\n} from \"../utils/dictionary-edit.js\";\nimport { logger } from \"../utils/logger.js\";\nimport { resolveDialexConfig } from \"../utils/scanner.js\";\nimport { renderGenerated } from \"./generate.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 /** Report translations whose source text changed since they were translated as errors. */\n failOnStale?: boolean;\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`, plus generated files it rewrote. */\n fixed: number;\n}\n\nconst DICTIONARY_IGNORE = [\n \"**/node_modules/**\",\n \"**/dist/**\",\n \"**/.next/**\",\n \"**/dialex.locales/**\",\n];\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\n/**\n * What a formatter (Prettier, Biome, oxfmt) can change without changing the code: whitespace,\n * quote style, quoted object keys and trailing commas. Comparing this form keeps `check` quiet\n * when your pre-commit hook formats the generated files.\n */\nexport function normalizeGenerated(text: string): string {\n return text\n .replace(/'/g, '\"')\n .replace(/\"([A-Za-z_$][\\w$]*)\"\\s*:/g, \"$1:\")\n .replace(/\\s+/g, \"\")\n .replace(/,(?=[\\]})])/g, \"\");\n}\n\n/**\n * Generated files that exist but no longer match the dictionaries and config. Nothing builds them\n * for you any more, so a stale `dialex.generated.ts` would otherwise fail silently at runtime.\n * With `fix` they are rewritten.\n */\nfunction staleGeneratedFiles(\n root: string,\n options: CheckOptions,\n): { stale: { file: string; message: string }[]; rewritten: number } {\n let rendered;\n try {\n rendered = renderGenerated(root, { config: options.config });\n } catch {\n return { stale: [], rewritten: 0 }; // not renderable (for example lazy mode with an unreadable name); `generate` reports it\n }\n const stale: { file: string; message: string }[] = [];\n let rewritten = 0;\n const targets: [string, string | undefined][] = [\n [rendered.outputPath, rendered.content],\n [rendered.dtsPath, rendered.dtsContent],\n ];\n // Per-locale modules belong to the same generation: once the generated file exists they must too\n if (fs.existsSync(rendered.outputPath)) {\n for (const extra of rendered.extraFiles) targets.push([extra.path, extra.content]);\n }\n for (const [file, content] of targets) {\n if (content === undefined) continue;\n const isExtra = rendered.extraFiles.some((f) => f.path === file);\n if (!fs.existsSync(file)) {\n if (!isExtra) continue;\n if (options.fix) {\n fs.mkdirSync(path.dirname(file), { recursive: true });\n fs.writeFileSync(file, content, \"utf-8\");\n rewritten++;\n } else {\n stale.push({\n file: path.relative(root, file),\n message: \"Missing. Run `dx generate` (or `dx check --fix`).\",\n });\n }\n continue;\n }\n if (normalizeGenerated(fs.readFileSync(file, \"utf-8\")) === normalizeGenerated(content))\n continue;\n if (options.fix) {\n fs.writeFileSync(file, content, \"utf-8\");\n rewritten++;\n } else {\n stale.push({\n file: path.relative(root, file),\n message:\n \"Out of date with your dictionaries or config. Run `dx generate` (or `dx check --fix`).\",\n });\n }\n }\n return { stale, rewritten };\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 = resolveDialexConfig(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 generated = staleGeneratedFiles(root, options);\n fixed += generated.rewritten;\n if (generated.rewritten > 0 && !quiet) {\n logger.success(\n `Regenerated ${generated.rewritten} out-of-date generated file${generated.rewritten === 1 ? \"\" : \"s\"}`,\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 (options.failOnStale && issue.code === \"stale-translation\") issue.level = \"error\";\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 for (const { file, message } of generated.stale) {\n let diag = byFile.get(file);\n if (!diag) {\n diag = { file, errors: [], warnings: [], annotations: [] };\n byFile.set(file, diag);\n }\n diag.errors.push(message);\n diag.annotations.push({ level: \"error\", message });\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\";\n\nimport { listLeaves, listLocales } from \"../utils/dictionary-edit.js\";\nimport { logger } from \"../utils/logger.js\";\nimport { loadProject, toKey } from \"../utils/project.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 || \"dialex-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\";\n\nimport { argumentSignature, parseMessage } from \"dialexjs/icu\";\n\nimport {\n getString,\n hasPath,\n listLocales,\n saveDictionaryFile,\n setString,\n} from \"../utils/dictionary-edit.js\";\nimport { lockFor, readLock, record, writeLock } from \"../utils/lockfile.js\";\nimport { logger } from \"../utils/logger.js\";\nimport { loadProject } from \"../utils/project.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 // With a lock file, imported translations are recorded against the current source text.\n const lockInUse = readLock(root) !== undefined;\n const sourceLocale = readLock(root)?.sourceLocale ?? project.config.defaultLocale ?? \"en\";\n const { lock } = lockFor(root, sourceLocale);\n let recorded = 0;\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 const sourceText = getString(dict.df, sourceLocale, keyPath);\n if (lockInUse && locale !== sourceLocale && sourceText !== undefined) {\n record(lock, locale, key, sourceText);\n recorded++;\n }\n }\n }\n if (recorded > 0) writeLock(root, lock);\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 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 { fileURLToPath } from \"node:url\";\n\n/** Version of this CLI, which the other Dialex packages share. Read from the nearest package.json. */\nexport function cliVersion(): string | undefined {\n let dir = path.dirname(fileURLToPath(import.meta.url));\n for (let i = 0; i < 4; i++) {\n try {\n const pkg = JSON.parse(fs.readFileSync(path.join(dir, \"package.json\"), \"utf-8\"));\n if (pkg.name === \"@dialexjs/cli\") return pkg.version;\n } catch {\n // keep walking up\n }\n dir = path.dirname(dir);\n }\n return undefined;\n}\n\n/** The install command for the package manager a project uses, judged by its lockfile. */\nexport function installCommand(root: string): string {\n const has = (file: string) => fs.existsSync(path.join(root, file));\n if (has(\"bun.lock\") || has(\"bun.lockb\")) return \"bun install\";\n if (has(\"pnpm-lock.yaml\")) return \"pnpm install\";\n if (has(\"yarn.lock\")) return \"yarn install\";\n return \"npm install\";\n}\n\ntype Dependencies = Record<string, string>;\n\nconst sorted = (deps: Dependencies): Dependencies =>\n Object.fromEntries(Object.entries(deps).sort(([a], [b]) => a.localeCompare(b)));\n\n/**\n * Adds the packages a Dialex project needs: `dialexjs` as a dependency and the CLI as a dev\n * dependency (the `dx:generate` script runs it). Packages already listed anywhere are left alone.\n * Returns the names it added.\n */\nexport function addRequiredPackages(pkg: Record<string, any>, version = cliVersion()): string[] {\n const range = version ? `^${version}` : \"latest\";\n const listed = (name: string) =>\n [pkg.dependencies, pkg.devDependencies, pkg.peerDependencies].some(\n (deps) => deps && name in deps,\n );\n const added: string[] = [];\n\n if (!listed(\"dialexjs\")) {\n pkg.dependencies = sorted({ ...pkg.dependencies, dialexjs: range });\n added.push(\"dialexjs\");\n }\n if (!listed(\"@dialexjs/cli\")) {\n pkg.devDependencies = sorted({ ...pkg.devDependencies, \"@dialexjs/cli\": range });\n added.push(\"@dialexjs/cli\");\n }\n return added;\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\n\nimport * as p from \"@clack/prompts\";\nimport { parseModule, loadFile, writeFile } from \"magicast\";\nimport { addNuxtModule } from \"magicast/helpers\";\nimport pc from \"picocolors\";\n\nimport { detectFramework, type SupportedFramework } from \"../utils/detector.js\";\nimport { logger } from \"../utils/logger.js\";\nimport { addRequiredPackages, installCommand } from \"../utils/package-json.js\";\nimport { generateDictionaries } from \"./generate.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. Nuxt reads the generated file through its module; other frameworks need no config edits\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 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: required packages and the generate script\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 added = addRequiredPackages(pkg);\n pkg.scripts = pkg.scripts || {};\n const addScript = !pkg.scripts[\"dx:generate\"];\n if (addScript) pkg.scripts[\"dx:generate\"] = \"dx generate\";\n\n if (added.length > 0 || addScript) {\n fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + \"\\n\", \"utf-8\");\n }\n if (added.length > 0) {\n logger.success(`Added ${added.join(\" and \")} to package.json`);\n logger.info(`Run ${pc.bold(installCommand(root))} to install them.`);\n }\n if (addScript) logger.success('Added \"dx:generate\" script to package.json');\n } catch {\n logger.warn(\"Could not update package.json; add dialexjs and @dialexjs/cli manually.\");\n }\n } else {\n logger.warn(\"No package.json found; install dialexjs and @dialexjs/cli in your project.\");\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 { dialex } from \"dialexjs/hono\";\nimport dictionaries from \"./src/dialex.generated.js\";\n\nconst app = new Hono();\napp.use(\"*\", dialex({ 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 { dialexPlugin } from \"dialexjs/fastify\";\nimport dictionaries from \"./src/dialex.generated.js\";\n\nconst app = Fastify();\nawait app.register(dialexPlugin, { 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 { dialex } from \"dialexjs/express\";\nimport dictionaries from \"./src/dialex.generated.js\";\n\nconst app = express();\napp.use(dialex({ 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 { dialex } from \"dialexjs/koa\";\nimport dictionaries from \"./src/dialex.generated.js\";\n\nconst app = new Koa();\napp.use(dialex({ 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 { DialexModule } from \"dialexjs/nestjs\";\nimport dictionaries from \"./src/dialex.generated.js\";\n\n@Module({\n imports: [DialexModule.forRoot({ dictionaries })],\n})\nexport class AppModule {}\n`);\n break;\n case \"next\":\n logger.log(`\n// src/dialex.ts\nimport { createDialexServer } from \"dialexjs/server\";\nimport { dialex } from \"./dialex.generated\";\n\nexport const { getDictionary, getT } = createDialexServer(dialex);\n\n// app/[locale]/page.tsx (Server Component)\nimport { getDictionary } from \"../../dialex\";\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// For client components, render the provider inside a \"use client\" file:\n// \"use client\";\n// import { DialexProvider } from \"dialexjs/react\";\n// import { dialex } from \"./dialex.generated\";\n// export const Providers = ({ children }) => <DialexProvider {...dialex}>{children}</DialexProvider>;\n`);\n break;\n case \"react\":\n logger.log(`\n// src/main.tsx\nimport { createRoot } from \"react-dom/client\";\nimport { DialexProvider } from \"dialexjs/react\";\nimport { dialex } from \"./dialex.generated\";\nimport App from \"./App\";\n\ncreateRoot(document.getElementById(\"root\")!).render(\n <DialexProvider {...dialex}>\n <App />\n </DialexProvider>,\n);\n\n// In components: const dict = useDictionary(\"home\")\n`);\n break;\n case \"elysia\":\n logger.log(`\nimport { Elysia } from \"elysia\";\nimport { dialex } from \"dialexjs/elysia\";\nimport dictionaries from \"./src/dialex.generated.js\";\n\nnew Elysia()\n .use(dialex({ 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 { dialexHandle } from \"dialexjs/sveltekit\";\nimport dictionaries from \"./dialex.generated.js\";\n\nexport const handle = dialexHandle({ 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 { dialex } from \"dialexjs/astro\";\nimport dictionaries from \"./dialex.generated.js\";\n\nexport const onRequest = dialex({ 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 { createDialex } from \"dialexjs/vue\";\nimport { dialex } from \"./dialex.generated\";\nimport App from \"./App.vue\";\n\ncreateApp(App).use(createDialex({ ...dialex })).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 logger.info(\n \"Keep dialex.generated.ts current: run `dx generate --watch` while you develop, or use the Dialex VS Code extension, which regenerates on save.\",\n );\n\n if (isInteractive) {\n p.outro(pc.green(\"✔ dialex is configured and ready to go!\"));\n }\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\n\nimport pc from \"picocolors\";\n\nimport { TODO_PREFIX, listLeaves, listLocales } from \"../utils/dictionary-edit.js\";\nimport { LOCK_FILE, isStale, lockFor, lockPath, record, writeLock } from \"../utils/lockfile.js\";\nimport { logger } from \"../utils/logger.js\";\nimport { loadProject, toKey } from \"../utils/project.js\";\n\nexport interface LockOptions {\n cwd?: string;\n config?: string;\n /** Locale the translations were made from. Defaults to `translate.sourceLocale`, then `defaultLocale`. */\n source?: string;\n /** Also accept translations that are out of date (say they are fine as they are). */\n all?: boolean;\n /** Print machine-readable JSON instead of human output. */\n json?: boolean;\n}\n\nexport interface LockResult {\n success: boolean;\n sourceLocale: string;\n /** Translations newly recorded as up to date. */\n recorded: number;\n /** Keys that are still out of date (only without `--all`). */\n stale: string[];\n}\n\n/**\n * Records the current translations as up to date with the current source text, so later edits to\n * the source can be noticed. Translations that are already out of date are left alone unless\n * `--all` is given. Run it once when you adopt the lock file, and after reviewing stale ones.\n */\nexport async function runLock(options: LockOptions = {}): Promise<LockResult> {\n const root = options.cwd || process.cwd();\n const project = await loadProject(root, options.config);\n const source =\n options.source ??\n project.config.translate?.sourceLocale ??\n project.config.defaultLocale ??\n \"en\";\n const { lock } = lockFor(root, source);\n\n const result: LockResult = { success: true, sourceLocale: source, recorded: 0, stale: [] };\n\n for (const dict of project.dictionaries) {\n const sourceText = new Map(\n listLeaves(dict.df, source)\n .filter((leaf) => leaf.kind === \"string\" && leaf.value !== undefined)\n .map((leaf) => [leaf.path.join(\".\"), leaf.value!]),\n );\n\n for (const locale of listLocales(dict.df)) {\n if (locale === source) continue;\n for (const leaf of listLeaves(dict.df, locale)) {\n if (leaf.kind !== \"string\" || leaf.value === undefined) continue;\n if (leaf.value.startsWith(TODO_PREFIX)) continue; // not translated yet\n const text = sourceText.get(leaf.path.join(\".\"));\n if (text === undefined) continue;\n\n const key = toKey(dict.name, leaf.path);\n const known = lock.locales[locale]?.[key] !== undefined;\n if (known && isStale(lock, locale, key, text)) {\n if (!options.all) {\n result.stale.push(`${locale}:${key}`);\n continue;\n }\n } else if (known) {\n continue; // already recorded and current\n }\n record(lock, locale, key, text);\n result.recorded++;\n }\n }\n }\n\n if (result.recorded > 0 || !fs.existsSync(lockPath(root))) writeLock(root, lock);\n\n if (options.json) {\n console.log(JSON.stringify(result, null, 2));\n } else {\n logger.success(\n `Recorded ${result.recorded} translation${result.recorded === 1 ? \"\" : \"s\"} in ${path.basename(LOCK_FILE)} (source \"${source}\")`,\n );\n if (result.stale.length > 0) {\n logger.warn(\n `${result.stale.length} out of date and left as they are: ${result.stale.slice(0, 5).join(\", \")}${result.stale.length > 5 ? \", ...\" : \"\"}`,\n );\n logger.log(\n ` ${pc.dim(\"Re-translate them with\")} dialex translate --stale${pc.dim(\", or accept them with\")} dialex lock --all`,\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 type { TranslateProvider } from \"dialexjs\";\nimport { isIcuStructured } from \"dialexjs/icu\";\nimport pc from \"picocolors\";\n\nimport { preservesPlaceholders } from \"../translate/placeholders.js\";\nimport {\n TODO_PREFIX,\n listLeaves,\n listLocales,\n saveDictionaryFile,\n setString,\n} from \"../utils/dictionary-edit.js\";\nimport { isStale, lockFor, record, writeLock } from \"../utils/lockfile.js\";\nimport { logger } from \"../utils/logger.js\";\nimport { loadProject, toKey, type ProjectDictionary } from \"../utils/project.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 * Also re-translate strings whose source text changed since they were translated, according to\n * `dialex.lock.json`. Only these strings may replace an existing translation.\n */\n stale?: boolean;\n}\n\nexport interface PendingTranslation {\n file: string;\n locale: string;\n key: string;\n source: string;\n /** The translation existed but its source text has changed since. */\n stale?: boolean;\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 const { lock, replaced } = lockFor(root, source);\n if (replaced && !options.json) {\n logger.warn(\n `dialex.lock.json was recorded from another source locale; starting a new one from \"${source}\".`,\n );\n }\n\n // 1. Collect strings that are missing or still marked [TODO] (and, with --stale, out of date)\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 key = toKey(dict.name, leaf.path);\n const placeholder =\n !current || (current.kind === \"string\" && current.value?.startsWith(TODO_PREFIX));\n const stale =\n !placeholder &&\n options.stale === true &&\n current?.kind === \"string\" &&\n isStale(lock, locale, key, leaf.value!);\n if (placeholder || stale) {\n tasks.push({\n dict,\n path: leaf.path,\n file: dict.rel,\n locale,\n key,\n source: leaf.value!,\n ...(stale ? { stale: true } : {}),\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(\n ` ${pc.dim(t.locale)} ${t.key} ${pc.dim(JSON.stringify(t.source))}${t.stale ? pc.yellow(\" (out of date)\") : \"\"}`,\n );\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 record(lock, locale, task.key, task.source);\n result.translated++;\n touched.add(task.dict);\n }\n }\n\n for (const dict of touched) await saveDictionaryFile(dict.df);\n if (result.translated > 0) writeLock(root, lock);\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\";\n\nimport pkg from \"../package.json\" with { type: \"json\" };\nimport { runCheck } from \"./commands/check.js\";\nimport { runExport } from \"./commands/export.js\";\nimport { runGenerate } from \"./commands/generate.js\";\nimport { runImport } from \"./commands/import.js\";\nimport { runInit } from \"./commands/init.js\";\nimport { runLock } from \"./commands/lock.js\";\nimport { runTranslate } from \"./commands/translate.js\";\nimport { logger } from \"./utils/logger.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(pkg.version);\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(\"--fail-on-stale\", \"Treat translations whose source text changed as errors\")\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\", \"dialex-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(\n \"--stale\",\n \"Also re-translate strings whose source text changed since they were translated\",\n )\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\n .command(\"lock\")\n .description(\"Record translations as up to date with the current source text (dialex.lock.json)\")\n .option(\"-s, --source <locale>\", \"Locale the translations were made from\")\n .option(\"--all\", \"Also accept translations that are already out of date\")\n .option(\"--json\", \"Print machine-readable JSON\")\n .option(\"-c, --config <path>\", \"Custom config path\")\n .action(async (opts) => {\n try {\n await runLock(opts);\n } catch (err: any) {\n logger.error(err.message || String(err));\n process.exit(1);\n }\n });\n\nprogram.parse();\n"],"mappings":";;;;;;;;;;;;;;;;AC2DA,MAAM,oBAAoB;CACxB;CACA;CACA;CACA;AACF;AAEA,SAAS,SAAS,MAAuB,OAAsB;CAC7D,MAAM,QAAQ,MAAM,UAAU,UAAU,UAAU;CAClD,CAAC,UAAU,UAAU,KAAK,SAAS,KAAK,SAAA,CAAU,KAAK,MAAM,OAAO;CACpE,KAAK,YAAY,KAAK;EACpB;EACA,SAAS,MAAM;EACf,MAAM,MAAM,QAAQ,MAAM,MAAM,MAAM,OAAO,IAAI,KAAA;CACnD,CAAC;AACH;;;;;AAMA,eAAe,WACb,OACA,mBACA,eACiB;CACjB,IAAI,QAAQ;CAEZ,KAAK,MAAM,QAAQ,OAAO;EACxB,MAAM,KAAK,MAAM,mBAAmB,IAAI;EAExC,IAAI,CAAC,IA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