@fluenti/cli 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +170 -0
- package/dist/catalog.d.ts +21 -0
- package/dist/catalog.d.ts.map +1 -0
- package/dist/cli.cjs +8 -0
- package/dist/cli.cjs.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +590 -0
- package/dist/cli.js.map +1 -0
- package/dist/compile-CzSTgY0T.cjs +13 -0
- package/dist/compile-CzSTgY0T.cjs.map +1 -0
- package/dist/compile-McMlpGSK.js +733 -0
- package/dist/compile-McMlpGSK.js.map +1 -0
- package/dist/compile.d.ts +19 -0
- package/dist/compile.d.ts.map +1 -0
- package/dist/config.d.ts +21 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/index.cjs +2 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +10 -0
- package/dist/index.js.map +1 -0
- package/dist/json-format.d.ts +6 -0
- package/dist/json-format.d.ts.map +1 -0
- package/dist/migrate.d.ts +9 -0
- package/dist/migrate.d.ts.map +1 -0
- package/dist/po-format.d.ts +6 -0
- package/dist/po-format.d.ts.map +1 -0
- package/dist/translate.d.ts +14 -0
- package/dist/translate.d.ts.map +1 -0
- package/dist/tsx-extractor.d.ts +3 -0
- package/dist/tsx-extractor.d.ts.map +1 -0
- package/dist/vue-extractor.d.ts +4 -0
- package/dist/vue-extractor.d.ts.map +1 -0
- package/package.json +73 -0
package/dist/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","names":[],"sources":["../src/translate.ts","../src/migrate.ts","../src/cli.ts"],"sourcesContent":["import { execFile } from 'node:child_process'\nimport { promisify } from 'node:util'\nimport consola from 'consola'\nimport type { CatalogData } from './catalog'\n\nconst execFileAsync = promisify(execFile)\n\nexport type AIProvider = 'claude' | 'codex'\n\nfunction buildPrompt(\n sourceLocale: string,\n targetLocale: string,\n messages: Record<string, string>,\n): string {\n const json = JSON.stringify(messages, null, 2)\n return [\n `You are a professional translator. Translate the following messages from \"${sourceLocale}\" to \"${targetLocale}\".`,\n '',\n `Input (JSON):`,\n json,\n '',\n 'Rules:',\n '- Output ONLY valid JSON with the same keys and translated values.',\n '- Keep ICU MessageFormat placeholders like {name}, {count}, {gender} unchanged.',\n '- Keep HTML tags unchanged.',\n '- Do not add any explanation or markdown formatting, output raw JSON only.',\n ].join('\\n')\n}\n\nasync function invokeAI(provider: AIProvider, prompt: string): Promise<string> {\n const maxBuffer = 10 * 1024 * 1024\n\n try {\n if (provider === 'claude') {\n const { stdout } = await execFileAsync('claude', ['-p', prompt], { maxBuffer })\n return stdout\n } else {\n const { stdout } = await execFileAsync('codex', ['-p', prompt, '--full-auto'], { maxBuffer })\n return stdout\n }\n } catch (error: unknown) {\n const err = error as Error & { code?: string }\n if (err.code === 'ENOENT') {\n throw new Error(\n `\"${provider}\" CLI not found. Please install it first:\\n` +\n (provider === 'claude'\n ? ' npm install -g @anthropic-ai/claude-code'\n : ' npm install -g @openai/codex'),\n )\n }\n throw error\n }\n}\n\nfunction extractJSON(text: string): Record<string, string> {\n // Try to find a JSON object in the response\n const match = text.match(/\\{[\\s\\S]*\\}/)\n if (!match) {\n throw new Error('No JSON object found in AI response')\n }\n const parsed = JSON.parse(match[0])\n if (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed)) {\n throw new Error('AI response is not a valid JSON object')\n }\n return parsed as Record<string, string>\n}\n\nfunction getUntranslatedEntries(catalog: CatalogData): Record<string, string> {\n const entries: Record<string, string> = {}\n for (const [id, entry] of Object.entries(catalog)) {\n if (entry.obsolete) continue\n if (!entry.translation || entry.translation.length === 0) {\n entries[id] = entry.message ?? id\n }\n }\n return entries\n}\n\nfunction chunkEntries(\n entries: Record<string, string>,\n batchSize: number,\n): Array<Record<string, string>> {\n const keys = Object.keys(entries)\n const chunks: Array<Record<string, string>> = []\n\n for (let i = 0; i < keys.length; i += batchSize) {\n const chunk: Record<string, string> = {}\n for (const key of keys.slice(i, i + batchSize)) {\n chunk[key] = entries[key]!\n }\n chunks.push(chunk)\n }\n\n return chunks\n}\n\nexport interface TranslateOptions {\n provider: AIProvider\n sourceLocale: string\n targetLocale: string\n catalog: CatalogData\n batchSize: number\n}\n\nexport async function translateCatalog(options: TranslateOptions): Promise<{\n catalog: CatalogData\n translated: number\n}> {\n const { provider, sourceLocale, targetLocale, catalog, batchSize } = options\n\n const untranslated = getUntranslatedEntries(catalog)\n const count = Object.keys(untranslated).length\n\n if (count === 0) {\n return { catalog, translated: 0 }\n }\n\n consola.info(` ${count} untranslated messages, translating with ${provider}...`)\n\n const batches = chunkEntries(untranslated, batchSize)\n let totalTranslated = 0\n\n for (let i = 0; i < batches.length; i++) {\n const batch = batches[i]!\n const batchKeys = Object.keys(batch)\n\n if (batches.length > 1) {\n consola.info(` Batch ${i + 1}/${batches.length} (${batchKeys.length} messages)`)\n }\n\n const prompt = buildPrompt(sourceLocale, targetLocale, batch)\n const response = await invokeAI(provider, prompt)\n const translations = extractJSON(response)\n\n for (const key of batchKeys) {\n if (translations[key] && typeof translations[key] === 'string') {\n catalog[key] = {\n ...catalog[key],\n translation: translations[key],\n }\n totalTranslated++\n } else {\n consola.warn(` Missing translation for key: ${key}`)\n }\n }\n }\n\n return { catalog, translated: totalTranslated }\n}\n","import { execFile } from 'node:child_process'\nimport { promisify } from 'node:util'\nimport { readFileSync, existsSync } from 'node:fs'\nimport { resolve, join } from 'node:path'\nimport fg from 'fast-glob'\nimport consola from 'consola'\nimport type { AIProvider } from './translate'\n\nconst execFileAsync = promisify(execFile)\n\nexport type SupportedLibrary =\n | 'vue-i18n'\n | 'nuxt-i18n'\n | 'react-i18next'\n | 'next-intl'\n | 'next-i18next'\n | 'lingui'\n\ninterface LibraryInfo {\n name: SupportedLibrary\n framework: string\n configPatterns: string[]\n localePatterns: string[]\n sourcePatterns: string[]\n migrationGuide: string // relative path from packages/\n}\n\nconst LIBRARY_INFO: Record<SupportedLibrary, LibraryInfo> = {\n 'vue-i18n': {\n name: 'vue-i18n',\n framework: 'Vue',\n configPatterns: ['i18n.ts', 'i18n.js', 'i18n/index.ts', 'i18n/index.js', 'src/i18n.ts', 'src/i18n.js', 'src/i18n/index.ts', 'src/plugins/i18n.ts'],\n localePatterns: ['locales/*.json', 'src/locales/*.json', 'i18n/*.json', 'src/i18n/*.json', 'lang/*.json', 'src/lang/*.json', 'locales/*.yaml', 'locales/*.yml'],\n sourcePatterns: ['src/**/*.vue'],\n migrationGuide: 'vue/llms-migration.txt',\n },\n 'nuxt-i18n': {\n name: 'nuxt-i18n',\n framework: 'Nuxt',\n configPatterns: ['nuxt.config.ts', 'nuxt.config.js', 'i18n.config.ts', 'i18n.config.js'],\n localePatterns: ['locales/*.json', 'lang/*.json', 'i18n/*.json', 'locales/*.yaml', 'locales/*.yml'],\n sourcePatterns: ['pages/**/*.vue', 'components/**/*.vue', 'layouts/**/*.vue'],\n migrationGuide: 'nuxt/llms-migration.txt',\n },\n 'react-i18next': {\n name: 'react-i18next',\n framework: 'React',\n configPatterns: ['i18n.ts', 'i18n.js', 'src/i18n.ts', 'src/i18n.js', 'src/i18n/index.ts', 'src/i18n/config.ts'],\n localePatterns: ['locales/*.json', 'src/locales/*.json', 'public/locales/**/*.json', 'translations/*.json', 'src/translations/*.json'],\n sourcePatterns: ['src/**/*.tsx', 'src/**/*.jsx', 'src/**/*.ts'],\n migrationGuide: 'react/llms-migration.txt',\n },\n 'next-intl': {\n name: 'next-intl',\n framework: 'Next.js',\n configPatterns: ['next.config.ts', 'next.config.js', 'next.config.mjs', 'i18n.ts', 'src/i18n.ts', 'i18n/request.ts', 'src/i18n/request.ts'],\n localePatterns: ['messages/*.json', 'locales/*.json', 'src/messages/*.json', 'src/locales/*.json'],\n sourcePatterns: ['app/**/*.tsx', 'src/app/**/*.tsx', 'pages/**/*.tsx', 'components/**/*.tsx'],\n migrationGuide: 'next-plugin/llms-migration.txt',\n },\n 'next-i18next': {\n name: 'next-i18next',\n framework: 'Next.js',\n configPatterns: ['next-i18next.config.js', 'next-i18next.config.mjs', 'next.config.ts', 'next.config.js'],\n localePatterns: ['public/locales/**/*.json'],\n sourcePatterns: ['pages/**/*.tsx', 'src/pages/**/*.tsx', 'components/**/*.tsx', 'src/components/**/*.tsx'],\n migrationGuide: 'next-plugin/llms-migration.txt',\n },\n 'lingui': {\n name: 'lingui',\n framework: 'React',\n configPatterns: ['lingui.config.ts', 'lingui.config.js', '.linguirc'],\n localePatterns: ['locales/*.po', 'src/locales/*.po', 'locales/*/messages.po', 'src/locales/*/messages.po'],\n sourcePatterns: ['src/**/*.tsx', 'src/**/*.jsx', 'src/**/*.ts'],\n migrationGuide: 'react/llms-migration.txt',\n },\n}\n\nconst SUPPORTED_NAMES = Object.keys(LIBRARY_INFO) as SupportedLibrary[]\n\nfunction resolveLibrary(from: string): SupportedLibrary | undefined {\n const normalized = from.toLowerCase().replace(/^@nuxtjs\\//, 'nuxt-').replace(/^@/, '')\n return SUPPORTED_NAMES.find((name) => name === normalized)\n}\n\ninterface DetectedFiles {\n configFiles: Array<{ path: string; content: string }>\n localeFiles: Array<{ path: string; content: string }>\n sampleSources: Array<{ path: string; content: string }>\n packageJson: string | undefined\n}\n\nasync function detectFiles(info: LibraryInfo): Promise<DetectedFiles> {\n const result: DetectedFiles = {\n configFiles: [],\n localeFiles: [],\n sampleSources: [],\n packageJson: undefined,\n }\n\n // Read package.json\n const pkgPath = resolve('package.json')\n if (existsSync(pkgPath)) {\n result.packageJson = readFileSync(pkgPath, 'utf-8')\n }\n\n // Find config files\n for (const pattern of info.configPatterns) {\n const fullPath = resolve(pattern)\n if (existsSync(fullPath)) {\n result.configFiles.push({\n path: pattern,\n content: readFileSync(fullPath, 'utf-8'),\n })\n }\n }\n\n // Find locale files (limit to 10 to avoid huge prompts)\n const localeGlobs = await fg(info.localePatterns, { absolute: false })\n for (const file of localeGlobs.slice(0, 10)) {\n const fullPath = resolve(file)\n const content = readFileSync(fullPath, 'utf-8')\n // Truncate large files\n result.localeFiles.push({\n path: file,\n content: content.length > 5000 ? content.slice(0, 5000) + '\\n... (truncated)' : content,\n })\n }\n\n // Find sample source files (limit to 5 for prompt size)\n const sourceGlobs = await fg(info.sourcePatterns, { absolute: false })\n for (const file of sourceGlobs.slice(0, 5)) {\n const fullPath = resolve(file)\n const content = readFileSync(fullPath, 'utf-8')\n result.sampleSources.push({\n path: file,\n content: content.length > 3000 ? content.slice(0, 3000) + '\\n... (truncated)' : content,\n })\n }\n\n return result\n}\n\nfunction loadMigrationGuide(guidePath: string): string {\n // Try to find the migration guide relative to the CLI package\n const candidates = [\n resolve('node_modules', '@fluenti', 'cli', '..', '..', guidePath),\n join(__dirname, '..', '..', '..', guidePath),\n join(__dirname, '..', '..', guidePath),\n ]\n\n for (const candidate of candidates) {\n if (existsSync(candidate)) {\n return readFileSync(candidate, 'utf-8')\n }\n }\n\n return ''\n}\n\nfunction buildMigratePrompt(\n library: LibraryInfo,\n detected: DetectedFiles,\n migrationGuide: string,\n): string {\n const sections: string[] = []\n\n sections.push(\n `You are a migration assistant helping convert a ${library.framework} project from \"${library.name}\" to Fluenti (@fluenti).`,\n '',\n 'Your task:',\n '1. Generate a `fluenti.config.ts` file based on the existing i18n configuration',\n '2. Convert each locale/translation file to Fluenti PO format',\n '3. List the code changes needed (file by file) to migrate source code from the old API to Fluenti API',\n '',\n )\n\n if (migrationGuide) {\n sections.push(\n '=== MIGRATION GUIDE ===',\n migrationGuide,\n '',\n )\n }\n\n if (detected.packageJson) {\n sections.push(\n '=== package.json ===',\n detected.packageJson,\n '',\n )\n }\n\n if (detected.configFiles.length > 0) {\n sections.push('=== EXISTING CONFIG FILES ===')\n for (const file of detected.configFiles) {\n sections.push(`--- ${file.path} ---`, file.content, '')\n }\n }\n\n if (detected.localeFiles.length > 0) {\n sections.push('=== EXISTING LOCALE FILES ===')\n for (const file of detected.localeFiles) {\n sections.push(`--- ${file.path} ---`, file.content, '')\n }\n }\n\n if (detected.sampleSources.length > 0) {\n sections.push('=== SAMPLE SOURCE FILES ===')\n for (const file of detected.sampleSources) {\n sections.push(`--- ${file.path} ---`, file.content, '')\n }\n }\n\n sections.push(\n '',\n '=== OUTPUT FORMAT ===',\n 'Respond with the following sections, each starting with the exact header shown:',\n '',\n '### FLUENTI_CONFIG',\n '```ts',\n '// The fluenti.config.ts content',\n '```',\n '',\n '### LOCALE_FILES',\n 'For each locale file, output:',\n '#### LOCALE: {locale_code}',\n '```po',\n '// The PO file content',\n '```',\n '',\n '### MIGRATION_STEPS',\n 'A numbered checklist of specific code changes needed, with before/after examples.',\n '',\n '### INSTALL_COMMANDS',\n '```bash',\n '// The install and uninstall commands',\n '```',\n )\n\n return sections.join('\\n')\n}\n\nasync function invokeAI(provider: AIProvider, prompt: string): Promise<string> {\n const maxBuffer = 10 * 1024 * 1024\n\n try {\n if (provider === 'claude') {\n const { stdout } = await execFileAsync('claude', ['-p', prompt], { maxBuffer })\n return stdout\n } else {\n const { stdout } = await execFileAsync('codex', ['-p', prompt, '--full-auto'], { maxBuffer })\n return stdout\n }\n } catch (error: unknown) {\n const err = error as Error & { code?: string }\n if (err.code === 'ENOENT') {\n throw new Error(\n `\"${provider}\" CLI not found. Please install it first:\\n` +\n (provider === 'claude'\n ? ' npm install -g @anthropic-ai/claude-code'\n : ' npm install -g @openai/codex'),\n )\n }\n throw error\n }\n}\n\ninterface MigrateResult {\n config: string | undefined\n localeFiles: Array<{ locale: string; content: string }>\n steps: string | undefined\n installCommands: string | undefined\n}\n\nfunction parseResponse(response: string): MigrateResult {\n const result: MigrateResult = {\n config: undefined,\n localeFiles: [],\n steps: undefined,\n installCommands: undefined,\n }\n\n // Extract fluenti.config.ts\n const configMatch = response.match(/### FLUENTI_CONFIG[\\s\\S]*?```(?:ts|typescript)?\\n([\\s\\S]*?)```/)\n if (configMatch) {\n result.config = configMatch[1]!.trim()\n }\n\n // Extract locale files\n const localeSection = response.match(/### LOCALE_FILES([\\s\\S]*?)(?=### MIGRATION_STEPS|### INSTALL_COMMANDS|$)/)\n if (localeSection) {\n const localeRegex = /#### LOCALE:\\s*(\\S+)\\s*\\n```(?:po)?\\n([\\s\\S]*?)```/g\n let match\n while ((match = localeRegex.exec(localeSection[1]!)) !== null) {\n result.localeFiles.push({\n locale: match[1]!,\n content: match[2]!.trim(),\n })\n }\n }\n\n // Extract migration steps\n const stepsMatch = response.match(/### MIGRATION_STEPS\\s*\\n([\\s\\S]*?)(?=### INSTALL_COMMANDS|$)/)\n if (stepsMatch) {\n result.steps = stepsMatch[1]!.trim()\n }\n\n // Extract install commands\n const installMatch = response.match(/### INSTALL_COMMANDS[\\s\\S]*?```(?:bash|sh)?\\n([\\s\\S]*?)```/)\n if (installMatch) {\n result.installCommands = installMatch[1]!.trim()\n }\n\n return result\n}\n\nexport interface MigrateOptions {\n from: string\n provider: AIProvider\n write: boolean\n}\n\nexport async function runMigrate(options: MigrateOptions): Promise<void> {\n const { from, provider, write } = options\n\n const library = resolveLibrary(from)\n if (!library) {\n consola.error(`Unsupported library \"${from}\". Supported libraries:`)\n for (const name of SUPPORTED_NAMES) {\n consola.log(` - ${name}`)\n }\n return\n }\n\n const info = LIBRARY_INFO[library]\n consola.info(`Migrating from ${info.name} (${info.framework}) to Fluenti`)\n\n // Detect existing files\n consola.info('Scanning project for existing i18n files...')\n const detected = await detectFiles(info)\n\n if (detected.configFiles.length === 0 && detected.localeFiles.length === 0) {\n consola.warn(`No ${info.name} configuration or locale files found.`)\n consola.info('Make sure you are running this command from the project root directory.')\n return\n }\n\n consola.info(`Found: ${detected.configFiles.length} config file(s), ${detected.localeFiles.length} locale file(s), ${detected.sampleSources.length} source file(s)`)\n\n // Load migration guide\n const migrationGuide = loadMigrationGuide(info.migrationGuide)\n\n // Build prompt and invoke AI\n consola.info(`Generating migration plan with ${provider}...`)\n const prompt = buildMigratePrompt(info, detected, migrationGuide)\n const response = await invokeAI(provider, prompt)\n const result = parseResponse(response)\n\n // Display install commands\n if (result.installCommands) {\n consola.log('')\n consola.box({\n title: 'Install Commands',\n message: result.installCommands,\n })\n }\n\n // Write or display fluenti.config.ts\n if (result.config) {\n if (write) {\n const { writeFileSync } = await import('node:fs')\n const configPath = resolve('fluenti.config.ts')\n writeFileSync(configPath, result.config, 'utf-8')\n consola.success(`Written: ${configPath}`)\n } else {\n consola.log('')\n consola.box({\n title: 'fluenti.config.ts',\n message: result.config,\n })\n }\n }\n\n // Write or display locale files\n if (result.localeFiles.length > 0) {\n if (write) {\n const { writeFileSync, mkdirSync } = await import('node:fs')\n const catalogDir = './locales'\n mkdirSync(resolve(catalogDir), { recursive: true })\n for (const file of result.localeFiles) {\n const outPath = resolve(catalogDir, `${file.locale}.po`)\n writeFileSync(outPath, file.content, 'utf-8')\n consola.success(`Written: ${outPath}`)\n }\n } else {\n for (const file of result.localeFiles) {\n consola.log('')\n consola.box({\n title: `locales/${file.locale}.po`,\n message: file.content.length > 500\n ? file.content.slice(0, 500) + '\\n... (use --write to save full file)'\n : file.content,\n })\n }\n }\n }\n\n // Display migration steps\n if (result.steps) {\n consola.log('')\n consola.box({\n title: 'Migration Steps',\n message: result.steps,\n })\n }\n\n if (!write && (result.config || result.localeFiles.length > 0)) {\n consola.log('')\n consola.info('Run with --write to save generated files to disk:')\n consola.log(` fluenti migrate --from ${from} --write`)\n }\n}\n","#!/usr/bin/env node\nimport { defineCommand, runMain } from 'citty'\nimport consola from 'consola'\nimport fg from 'fast-glob'\nimport { readFileSync, writeFileSync, mkdirSync, existsSync } from 'node:fs'\nimport { resolve, dirname, extname } from 'node:path'\nimport { extractFromVue } from './vue-extractor'\nimport { extractFromTsx } from './tsx-extractor'\nimport { updateCatalog } from './catalog'\nimport type { CatalogData } from './catalog'\nimport { readJsonCatalog, writeJsonCatalog } from './json-format'\nimport { readPoCatalog, writePoCatalog } from './po-format'\nimport { compileCatalog, compileIndex, collectAllIds } from './compile'\nimport { translateCatalog } from './translate'\nimport type { AIProvider } from './translate'\nimport { runMigrate } from './migrate'\nimport type { ExtractedMessage, FluentiConfig } from '@fluenti/core'\n\nconst defaultConfig: FluentiConfig = {\n sourceLocale: 'en',\n locales: ['en'],\n catalogDir: './locales',\n format: 'po',\n include: ['./src/**/*.{vue,tsx,jsx,ts,js}'],\n compileOutDir: './locales/compiled',\n}\n\nasync function loadConfig(configPath?: string): Promise<FluentiConfig> {\n const paths = configPath\n ? [resolve(configPath)]\n : [\n resolve('fluenti.config.ts'),\n resolve('fluenti.config.js'),\n resolve('fluenti.config.mjs'),\n ]\n\n for (const p of paths) {\n if (existsSync(p)) {\n try {\n const { createJiti } = await import('jiti')\n const jiti = createJiti(import.meta.url)\n const mod = await jiti.import(p) as { default?: Partial<FluentiConfig> }\n const userConfig = mod.default ?? mod as unknown as Partial<FluentiConfig>\n return { ...defaultConfig, ...userConfig }\n } catch {\n consola.warn(`Failed to load config from ${p}, using defaults`)\n }\n }\n }\n\n return defaultConfig\n}\n\nfunction readCatalog(filePath: string, format: 'json' | 'po'): CatalogData {\n if (!existsSync(filePath)) return {}\n const content = readFileSync(filePath, 'utf-8')\n return format === 'json' ? readJsonCatalog(content) : readPoCatalog(content)\n}\n\nfunction writeCatalog(filePath: string, catalog: CatalogData, format: 'json' | 'po'): void {\n mkdirSync(dirname(filePath), { recursive: true })\n const content = format === 'json' ? writeJsonCatalog(catalog) : writePoCatalog(catalog)\n writeFileSync(filePath, content, 'utf-8')\n}\n\nfunction extractFromFile(filePath: string, code: string): ExtractedMessage[] {\n const ext = extname(filePath)\n if (ext === '.vue') return extractFromVue(code, filePath)\n return extractFromTsx(code, filePath)\n}\n\nconst extract = defineCommand({\n meta: { name: 'extract', description: 'Extract messages from source files' },\n args: {\n config: { type: 'string', description: 'Path to config file' },\n },\n async run({ args }) {\n const config = await loadConfig(args.config)\n consola.info(`Extracting messages from ${config.include.join(', ')}`)\n\n const files = await fg(config.include, { absolute: true })\n const allMessages: ExtractedMessage[] = []\n\n for (const file of files) {\n const code = readFileSync(file, 'utf-8')\n const messages = extractFromFile(file, code)\n allMessages.push(...messages)\n }\n\n consola.info(`Found ${allMessages.length} messages in ${files.length} files`)\n\n const ext = config.format === 'json' ? '.json' : '.po'\n\n for (const locale of config.locales) {\n const catalogPath = resolve(config.catalogDir, `${locale}${ext}`)\n const existing = readCatalog(catalogPath, config.format)\n const { catalog, result } = updateCatalog(existing, allMessages)\n writeCatalog(catalogPath, catalog, config.format)\n consola.success(\n `${locale}: ${result.added} added, ${result.unchanged} unchanged, ${result.obsolete} obsolete`,\n )\n }\n },\n})\n\nconst compile = defineCommand({\n meta: { name: 'compile', description: 'Compile message catalogs to JS modules' },\n args: {\n config: { type: 'string', description: 'Path to config file' },\n },\n async run({ args }) {\n const config = await loadConfig(args.config)\n const ext = config.format === 'json' ? '.json' : '.po'\n\n mkdirSync(config.compileOutDir, { recursive: true })\n\n // Collect all catalogs and build union of IDs\n const allCatalogs: Record<string, CatalogData> = {}\n for (const locale of config.locales) {\n const catalogPath = resolve(config.catalogDir, `${locale}${ext}`)\n allCatalogs[locale] = readCatalog(catalogPath, config.format)\n }\n\n const allIds = collectAllIds(allCatalogs)\n consola.info(`Compiling ${allIds.length} messages across ${config.locales.length} locales`)\n\n for (const locale of config.locales) {\n const compiled = compileCatalog(\n allCatalogs[locale]!,\n locale,\n allIds,\n config.sourceLocale,\n )\n const outPath = resolve(config.compileOutDir, `${locale}.js`)\n writeFileSync(outPath, compiled, 'utf-8')\n consola.success(`Compiled ${locale} → ${outPath}`)\n }\n\n // Generate index.js with locale list and lazy loaders\n const indexCode = compileIndex(config.locales, config.compileOutDir)\n const indexPath = resolve(config.compileOutDir, 'index.js')\n writeFileSync(indexPath, indexCode, 'utf-8')\n consola.success(`Generated index → ${indexPath}`)\n },\n})\n\nconst stats = defineCommand({\n meta: { name: 'stats', description: 'Show translation progress' },\n args: {\n config: { type: 'string', description: 'Path to config file' },\n },\n async run({ args }) {\n const config = await loadConfig(args.config)\n const ext = config.format === 'json' ? '.json' : '.po'\n\n const rows: Array<{ locale: string; total: number; translated: number; pct: string }> = []\n\n for (const locale of config.locales) {\n const catalogPath = resolve(config.catalogDir, `${locale}${ext}`)\n const catalog = readCatalog(catalogPath, config.format)\n const entries = Object.values(catalog).filter((e) => !e.obsolete)\n const total = entries.length\n const translated = entries.filter((e) => e.translation && e.translation.length > 0).length\n const pct = total > 0 ? ((translated / total) * 100).toFixed(1) + '%' : '—'\n rows.push({ locale, total, translated, pct })\n }\n\n consola.log('')\n consola.log(' Locale │ Total │ Translated │ Progress')\n consola.log(' ────────┼───────┼────────────┼─────────')\n for (const row of rows) {\n consola.log(\n ` ${row.locale.padEnd(8)}│ ${String(row.total).padStart(5)} │ ${String(row.translated).padStart(10)} │ ${row.pct}`,\n )\n }\n consola.log('')\n },\n})\n\nconst translate = defineCommand({\n meta: { name: 'translate', description: 'Translate messages using AI (Claude Code or Codex CLI)' },\n args: {\n config: { type: 'string', description: 'Path to config file' },\n provider: { type: 'string', description: 'AI provider: claude or codex', default: 'claude' },\n locale: { type: 'string', description: 'Translate a specific locale only' },\n 'batch-size': { type: 'string', description: 'Messages per batch', default: '50' },\n },\n async run({ args }) {\n const config = await loadConfig(args.config)\n const provider = args.provider as AIProvider\n\n if (provider !== 'claude' && provider !== 'codex') {\n consola.error(`Invalid provider \"${provider}\". Use \"claude\" or \"codex\".`)\n return\n }\n\n const batchSize = parseInt(args['batch-size'] ?? '50', 10)\n if (isNaN(batchSize) || batchSize < 1) {\n consola.error('Invalid batch-size. Must be a positive integer.')\n return\n }\n\n const targetLocales = args.locale\n ? [args.locale]\n : config.locales.filter((l: string) => l !== config.sourceLocale)\n\n if (targetLocales.length === 0) {\n consola.warn('No target locales to translate.')\n return\n }\n\n consola.info(`Translating with ${provider} (batch size: ${batchSize})`)\n const ext = config.format === 'json' ? '.json' : '.po'\n\n for (const locale of targetLocales) {\n consola.info(`\\n[${locale}]`)\n const catalogPath = resolve(config.catalogDir, `${locale}${ext}`)\n const catalog = readCatalog(catalogPath, config.format)\n\n const { catalog: updated, translated } = await translateCatalog({\n provider,\n sourceLocale: config.sourceLocale,\n targetLocale: locale,\n catalog,\n batchSize,\n })\n\n if (translated > 0) {\n writeCatalog(catalogPath, updated, config.format)\n consola.success(` ${locale}: ${translated} messages translated`)\n } else {\n consola.success(` ${locale}: already fully translated`)\n }\n }\n },\n})\n\nconst migrate = defineCommand({\n meta: { name: 'migrate', description: 'Migrate from another i18n library using AI' },\n args: {\n from: { type: 'string', description: 'Source library: vue-i18n, nuxt-i18n, react-i18next, next-intl, next-i18next, lingui', required: true },\n provider: { type: 'string', description: 'AI provider: claude or codex', default: 'claude' },\n write: { type: 'boolean', description: 'Write generated files to disk', default: false },\n },\n async run({ args }) {\n const provider = args.provider as AIProvider\n if (provider !== 'claude' && provider !== 'codex') {\n consola.error(`Invalid provider \"${provider}\". Use \"claude\" or \"codex\".`)\n return\n }\n\n await runMigrate({\n from: args.from!,\n provider,\n write: args.write ?? false,\n })\n },\n})\n\nconst main = defineCommand({\n meta: {\n name: 'fluenti',\n version: '0.0.1',\n description: 'Compile-time i18n for modern frameworks',\n },\n subCommands: { extract, compile, stats, translate, migrate },\n})\n\nrunMain(main)\n"],"mappings":";;;;;;;;;;AAKA,IAAM,IAAgB,EAAU,EAAS;AAIzC,SAAS,EACP,GACA,GACA,GACQ;CACR,IAAM,IAAO,KAAK,UAAU,GAAU,MAAM,EAAE;AAC9C,QAAO;EACL,6EAA6E,EAAa,QAAQ,EAAa;EAC/G;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACD,CAAC,KAAK,KAAK;;AAGd,eAAe,EAAS,GAAsB,GAAiC;CAC7E,IAAM,IAAY,KAAK,OAAO;AAE9B,KAAI;AACF,MAAI,MAAa,UAAU;GACzB,IAAM,EAAE,cAAW,MAAM,EAAc,UAAU,CAAC,MAAM,EAAO,EAAE,EAAE,cAAW,CAAC;AAC/E,UAAO;SACF;GACL,IAAM,EAAE,c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AAc;GAC5B,MAAM;IAAE,MAAM;IAAW,aAAa;IAA8C;GACpF,MAAM;IACJ,MAAM;KAAE,MAAM;KAAU,aAAa;KAAuF,UAAU;KAAM;IAC5I,UAAU;KAAE,MAAM;KAAU,aAAa;KAAgC,SAAS;KAAU;IAC5F,OAAO;KAAE,MAAM;KAAW,aAAa;KAAiC,SAAS;KAAO;IACzF;GACD,MAAM,IAAI,EAAE,WAAQ;IAClB,IAAM,IAAW,EAAK;AACtB,QAAI,MAAa,YAAY,MAAa,SAAS;AACjD,OAAQ,MAAM,qBAAqB,EAAS,6BAA6B;AACzE;;AAGF,UAAM,EAAW;KACf,MAAM,EAAK;KACX;KACA,OAAO,EAAK,SAAS;KACtB,CAAC;;GAEL,CAAC;EAQ4D;CAC7D,CAAC,CAEW"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));let c=require(`@vue/compiler-sfc`),l=require(`@fluenti/core/internal`),u=require(`@fluenti/core`),d=require(`gettext-parser`);d=s(d);var f=new Set([`@fluenti/react`,`@fluenti/vue`,`@fluenti/solid`,`@fluenti/next/__generated`]);function p(e){let t=e.trim();if(/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(t))return t;if(/^[a-zA-Z_$][a-zA-Z0-9_$.]*$/.test(t)&&!t.endsWith(`.`)){let e=t.split(`.`);return e[e.length-1]}return``}function ee(e,t){let n=``,r=0;for(let i=0;i<e.length;i++){if(n+=e[i],i>=t.length)continue;let a=p(t[i]);if(a===``){n+=`{${r}}`,r++;continue}n+=`{${a}}`}return n}function m(e,t,n){if(!e.message)return;let r=n.loc?.start.line??1,i=(n.loc?.start.column??0)+1;return{id:e.id,message:e.message,...e.context===void 0?{}:{context:e.context},...e.comment===void 0?{}:{comment:e.comment},origin:{file:t,line:r,column:i}}}function h(e){if(e.message)return{id:e.id??(0,l.createMessageId)(e.message,e.context),message:e.message,...e.context===void 0?{}:{context:e.context},...e.comment===void 0?{}:{comment:e.comment}}}function g(e){if(e.type===`StringLiteral`)return h({message:e.value});if(e.type===`TemplateLiteral`){let t=e;return t.expressions.length===0?h({message:t.quasis.map(e=>e.value.cooked??e.value.raw).join(``)}):void 0}if(e.type!==`ObjectExpression`)return;let t={};for(let n of e.properties){if(n.type!==`ObjectProperty`)continue;let e=n;if(e.computed||!k(e.key))continue;let r=e.key.name;if(![`id`,`message`,`context`,`comment`].includes(r))continue;let i=y(e.value);i!==void 0&&(t[r]=i)}if(t.message)return h(t)}function _(e){let t=[`zero`,`one`,`two`,`few`,`many`,`other`],n=e.value??e.count??`count`,r=[],i=e.offset;for(let n of t){let t=e[n];if(t===void 0)continue;let i=n===`zero`?`=0`:n;r.push(`${i} {${t}}`)}return r.length===0?``:`{${n}, plural, ${i?`offset:${i} `:``}${r.join(` `)}}`}function v(e){let t=0;function n(e){let r=``;for(let i of e){if(i.type===`JSXText`){r+=te(i.value);continue}if(i.type===`JSXElement`){let e=t++,a=n(i.children);if(a===void 0)return;r+=`<${e}>${a}</${e}>`;continue}if(i.type===`JSXFragment`){let e=n(i.children);if(e===void 0)return;r+=e;continue}if(i.type===`JSXExpressionContainer`){let e=i.expression;if(e.type===`StringLiteral`){r+=e.value;continue}if(e.type===`NumericLiteral`){r+=String(e.value);continue}return}}return r}let r=n(e);if(r!==void 0)return r.replace(/\s+/g,` `).trim()||void 0}function te(e){return e.replace(/\s+/g,` `)}function y(e){if(e.type===`StringLiteral`)return e.value;if(e.type===`NumericLiteral`)return String(e.value);if(e.type===`JSXExpressionContainer`)return y(e.expression);if(e.type===`TemplateLiteral`){let t=e;if(t.expressions.length===0)return t.quasis.map(e=>e.value.cooked??e.value.raw).join(``)}}function b(e,t){if(!(e.start==null||e.end==null))return e.type===`JSXExpressionContainer`?b(e.expression,t):t.slice(e.start,e.end).trim()}function x(e,t){for(let n of e.attributes){if(n.type!==`JSXAttribute`)continue;let e=n;if(e.name.type===`JSXIdentifier`&&e.name.name===t)return e}}function ne(e,t){let n={};for(let r of[`id`,`value`,`count`,`offset`,`zero`,`one`,`two`,`few`,`many`,`other`]){let i=x(e,r);if(!i?.value)continue;let a=y(i.value);if(a!==void 0){n[r]=a;continue}let o=b(i.value,t);o!==void 0&&(r===`value`||r===`count`||r===`offset`)&&(n[r]=o)}return n}function S(e,t){let n=ee(t.quasi.quasis.map(e=>e.value.cooked??e.value.raw),t.quasi.expressions.map(t=>t.start==null||t.end==null?``:e.slice(t.start,t.end)));return{id:(0,l.createMessageId)(n),message:n}}function re(e){let t=new Set,n=Array.isArray(e.body)?e.body:[];for(let e of n)if(w(e)&&f.has(e.source.value))for(let n of e.specifiers)T(n)&&E(n)===`t`&&t.add(n.local.name);return t}function C(e,t){let n=(0,l.parseSourceModule)(e);if(!n)return[];let r=[],i=re(n);return(0,l.walkSourceAst)(n,n=>{if(n.type===`TaggedTemplateExpression`){let a=n;if(k(a.tag)&&(a.tag.name===`t`||i.has(a.tag.name))){let n=m(S(e,a),t,a);n&&r.push(n)}return}if(n.type===`CallExpression`){let e=n;if(k(e.callee)&&(e.callee.name===`t`||i.has(e.callee.name))){if(i.has(e.callee.name)&&e.arguments[0]?.type!==`ObjectExpression`)return;let n=e.arguments[0]?g(e.arguments[0]):void 0,a=n?m(n,t,e):void 0;a&&r.push(a)}return}if(n.type!==`JSXElement`)return;let a=n,o=a.openingElement,s=D(o.name);if(s===`Trans`){let e=x(o,`message`),n=x(o,`id`),i=x(o,`context`),s=x(o,`comment`),c=e?.value?O({id:n?.value?y(n.value):void 0,message:y(e.value),context:i?.value?y(i.value):void 0,comment:s?.value?y(s.value):void 0}):O({id:n?.value?y(n.value):void 0,message:v(a.children),context:i?.value?y(i.value):void 0,comment:s?.value?y(s.value):void 0}),l=c?m(c,t,a):void 0;l&&r.push(l);return}if(s===`Plural`){let n=ne(o,e),i=_(n);if(!i)return;let s=m({id:n.id??(0,l.createMessageId)(i),message:i},t,a);s&&r.push(s)}}),r}function w(e){return(0,l.isSourceNode)(e)&&e.type===`ImportDeclaration`}function T(e){return(0,l.isSourceNode)(e)&&e.type===`ImportSpecifier`}function E(e){if(e.imported.type===`Identifier`)return e.imported.name;if(e.imported.type===`StringLiteral`)return e.imported.value}function D(e){if(e.type===`JSXIdentifier`)return String(e.name)}function O(e){let t={};return e.id!==void 0&&(t.id=e.id),e.message!==void 0&&(t.message=e.message),e.context!==void 0&&(t.context=e.context),e.comment!==void 0&&(t.comment=e.comment),h(t)}function k(e){return(0,l.isSourceNode)(e)&&e.type===`Identifier`}var A=1,j=2,M=7,N=6;function P(e){return e.filter(e=>e.type===j).map(e=>(e.content??``).trim()).join(``)}function F(e,t){let n=e.split(`|`).map(e=>e.trim()),r=[`one`,`other`,`zero`,`few`,`many`],i=[];if(n.length===2)i.push(`one {${n[0]}}`),i.push(`other {${n[1]}}`);else for(let e=0;e<n.length&&e<r.length;e++)i.push(`${r[e]} {${n[e]}}`);return`{${t}, plural, ${i.join(` `)}}`}function I(e){let t=e.count??`count`,n=[`zero`,`one`,`two`,`few`,`many`,`other`],r=[],i=e.offset;for(let t of n)if(e[t]!==void 0){let n=t===`zero`?`=0`:t;r.push(`${n} {${e[t]}}`)}return r.length===0?``:`{${t}, plural, ${i?`offset:${i} `:``}${r.join(` `)}}`}function L(e,t,n){if(e.type===A){let r=e.props?.find(e=>e.type===M&&z(e)===`t`);if(r){let i=new Set([`plural`]),a=(r.modifiers??[]).map(e=>typeof e==`string`?e:e.content),o=a.includes(`plural`),s=a.filter(e=>!i.has(e)),c=r.arg?.content,u=c?[c,...s].join(`.`):void 0,d=P(e.children??[]);if(o){let e=F(d,r.exp?.content??`count`),i=u??(0,l.createMessageId)(e);n.push({id:i,message:e,origin:{file:t,line:r.loc.start.line,column:r.loc.start.column}})}else if(d){let e=u??(0,l.createMessageId)(d);n.push({id:e,message:d,origin:{file:t,line:r.loc.start.line,column:r.loc.start.column}})}}if(e.tag===`Trans`){let r=e.props?.find(e=>e.type===N&&z(e)===`message`),i=e.props?.find(e=>e.type===N&&z(e)===`id`),a=e.props?.find(e=>e.type===N&&z(e)===`context`),o=e.props?.find(e=>e.type===N&&z(e)===`comment`),s=a?.value?.content,c=o?.value?.content;if(r?.value){let a=r.value.content,o=i?.value?.content??(0,l.createMessageId)(a,s);n.push({id:o,message:a,...s===void 0?{}:{context:s},...c===void 0?{}:{comment:c},origin:{file:t,line:e.loc.start.line,column:e.loc.start.column}})}else if(e.children&&e.children.length>0){let r=R(e.children);if(r.message){let a=i?.value?.content??(0,l.createMessageId)(r.message,s);n.push({id:a,message:r.message,...s===void 0?{}:{context:s},...c===void 0?{}:{comment:c},origin:{file:t,line:e.loc.start.line,column:e.loc.start.column}})}}}if(e.tag===`Plural`){let r={},i,a;for(let t of e.props??[])t.type===N&&t.value&&(r[z(t)]=t.value.content),t.type===M&&z(t)===`bind`&&t.arg?.content===`value`&&t.exp&&(i=t.exp.content),t.type===M&&z(t)===`bind`&&t.arg?.content===`offset`&&t.exp&&(a=t.exp.content);let o=i??r.count??`count`,s=a??r.offset,c=I({...r,count:o,...s===void 0?{}:{offset:s}});if(c){let i=r.id??(0,l.createMessageId)(c);n.push({id:i,message:c,origin:{file:t,line:e.loc.start.line,column:e.loc.start.column}})}}}if(e.children)for(let r of e.children)L(r,t,n)}function R(e){let t=0,n=!1;return{message:e.map(e=>{if(e.type===j)return(e.content??``).trim()?e.content??``:``;if(e.type===A&&e.tag){n=!0;let r=t++;return`<${r}>${R(e.children??[]).message}</${r}>`}return``}).join(``).trim(),hasElements:n}}function z(e){return typeof e.name==`string`?e.name:e.name.content}function B(e,t){let n=[],r=/\{\{([\s\S]*?)\}\}/g,i;for(;(i=r.exec(e))!==null;){let r=i[1]?.trim();if(!r)continue;let a=C(r,t);if(a.length===0)continue;let o=e.slice(0,i.index).split(`
|
|
2
|
+
`).length-1;for(let e of a)n.push({...e,origin:{...e.origin,line:e.origin.line+o}})}return n}function V(e,t){let n=[],{descriptor:r}=(0,c.parse)(e,{filename:t});if(r.template?.ast&&L(r.template.ast,t,n),r.template?.content){let e=C(r.template.content,t),i=r.template.loc.start.line-1,a=new Set(n.map(e=>e.id));for(let t of e)a.has(t.id)||n.push({...t,origin:{...t.origin,line:t.origin.line+i}});let o=B(r.template.content,t);for(let e of o)a.has(e.id)||n.push({...e,origin:{...e.origin,line:e.origin.line+i}})}if(r.scriptSetup?.content){let e=C(r.scriptSetup.content,t),i=r.scriptSetup.loc.start.line-1;for(let t of e)n.push({...t,origin:{...t.origin,line:t.origin.line+i}})}if(r.script?.content){let e=C(r.script.content,t),i=r.script.loc.start.line-1;for(let t of e)n.push({...t,origin:{...t.origin,line:t.origin.line+i}})}return n}function H(e,t){let n=new Set(t.map(e=>e.id)),r=new Set,i={},a=0,o=0,s=0;for(let n of t){let t=e[n.id],s=t?void 0:U(e,n,r),c=`${n.origin.file}:${n.origin.line}`,l=t??s?.entry;s&&r.add(s.id),l?(i[n.id]={...l,message:n.message??l.message,context:n.context,comment:n.comment,origin:c,obsolete:!1},o++):(i[n.id]={message:n.message,context:n.context,comment:n.comment,origin:c},a++)}for(let[t,r]of Object.entries(e))n.has(t)||(i[t]={...r,obsolete:!0},s++);return{catalog:i,result:{added:a,unchanged:o,obsolete:s}}}function U(e,t,n){if(!t.context)return;let r=`${t.origin.file}:${t.origin.line}`;for(let[i,a]of Object.entries(e))if(!n.has(i)&&a.context===void 0&&a.message===t.message&&W(a.origin,r))return{id:i,entry:a}}function W(e,t){return e?e===t?!0:G(e)===G(t):!1}function G(e){return e.match(/^(.*):\d+$/)?.[1]??e}function K(e){let t=JSON.parse(e),n={};for(let[e,r]of Object.entries(t))if(typeof r==`object`&&r){let t=r;n[e]={message:typeof t.message==`string`?t.message:void 0,context:typeof t.context==`string`?t.context:void 0,comment:typeof t.comment==`string`?t.comment:void 0,translation:typeof t.translation==`string`?t.translation:void 0,origin:typeof t.origin==`string`?t.origin:void 0,obsolete:typeof t.obsolete==`boolean`?t.obsolete:void 0}}return n}function ie(e){let t={};for(let[n,r]of Object.entries(e)){let e={};r.message!==void 0&&(e.message=r.message),r.context!==void 0&&(e.context=r.context),r.comment!==void 0&&(e.comment=r.comment),r.translation!==void 0&&(e.translation=r.translation),r.origin!==void 0&&(e.origin=r.origin),r.obsolete&&(e.obsolete=!0),t[n]=e}return JSON.stringify(t,null,2)+`
|
|
3
|
+
`}var q=`fluenti-id:`;function J(e){let t=d.po.parse(e),n={},r=t.translations??{};for(let[e,t]of Object.entries(r))for(let[r,i]of Object.entries(t)){if(!r)continue;let t=e||i.msgctxt||void 0,a=i.msgstr?.[0]??void 0,o=i.comments?.reference??void 0,s=i.comments?.flag?.includes(`fuzzy`)??!1,{comment:c,customId:l,sourceMessage:d}=ae(i.comments?.extracted),f=d&&(0,u.hashMessage)(d,t)===r?d:void 0,p=l??(f?r:(0,u.hashMessage)(r,t));n[p]={message:f??r,...t===void 0?{}:{context:t},...c===void 0?{}:{comment:c},...a?{translation:a}:{},...o===void 0?{}:{origin:o},...s?{obsolete:s}:{}}}return n}function Y(e){let t={"":{"":{msgid:``,msgstr:[`Content-Type: text/plain; charset=UTF-8
|
|
4
|
+
`]}}};for(let[n,r]of Object.entries(e)){let e={msgid:r.message??n,...r.context===void 0?{}:{msgctxt:r.context},msgstr:[r.translation??``]},i={};r.origin&&(i.reference=r.origin);let a=se(n,r.message??n,r.context,r.comment);a&&(i.extracted=a),r.obsolete&&(i.flag=`fuzzy`),(i.reference||i.extracted||i.flag)&&(e.comments=i);let o=r.context??``;t[o]??={},t[o][e.msgid]=e}let n={headers:{"Content-Type":`text/plain; charset=UTF-8`},translations:t};return d.po.compile(n).toString()}function ae(e){if(!e)return{};let t=e.split(`
|
|
5
|
+
`).map(e=>e.trim()).filter(Boolean),n,r,i=[];for(let e of t){if(e.startsWith(q)){n=e.slice(11).trim()||void 0;continue}if(e.startsWith("msg`")&&e.endsWith("`")){r=e.slice(4,-1);continue}if(e.startsWith(`Trans: `)){r=oe(e.slice(7));continue}i.push(e)}return{...i.length>0?{comment:i.join(`
|
|
6
|
+
`)}:{},...n?{customId:n}:{},...r?{sourceMessage:r}:{}}}function oe(e){let t=[],n=0;return e.replace(/<\/?([a-zA-Z][\w-]*)>/g,(e,r)=>{let i=r;if(e.startsWith(`</`)){for(let e=t.length-1;e>=0;e--){let n=t[e];if(n?.tag===i)return t.splice(e,1),`</${n.index}>`}return e}let a=n++;return t.push({tag:i,index:a}),`<${a}>`})}function se(e,t,n,r){let i=[];return r&&i.push(r),e!==(0,u.hashMessage)(t,n)&&i.push(`${q} ${e}`),i.length>0?i.join(`
|
|
7
|
+
`):void 0}var X=/\{(\w+)\}/g;function ce(e){return X.test(e)}function Z(e){return e.replace(/\\/g,`\\\\`).replace(/'/g,`\\'`).replace(/\n/g,`\\n`).replace(/\r/g,`\\r`)}function le(e){return e.replace(/\\/g,`\\\\`).replace(/`/g,"\\`").replace(/\$\{/g,"\\${").replace(/\n/g,`\\n`).replace(/\r/g,`\\r`)}function ue(e){return e.replace(X,(e,t)=>`\${v.${t}}`)}var de=/\{(\w+),\s*(plural|select|selectordinal)\s*,/;function Q(e){return de.test(e)}function $(e,t){if(e.length===0)return`''`;let n=e.map(e=>fe(e,t));return n.length===1?n[0]:n.join(` + `)}function fe(e,t){switch(e.type){case`text`:return`'${Z(e.value)}'`;case`variable`:return e.name===`#`?`String(__c)`:`String(v.${e.name} ?? '{${e.name}}')`;case`plural`:return pe(e,t);case`select`:return me(e,t);case`function`:return`String(v.${e.variable} ?? '')`}}function pe(e,t){let n=e.offset??0,r=n?`(v.${e.variable} - ${n})`:`v.${e.variable}`,i=[];i.push(`((c) => { const __c = c; `);let a=Object.keys(e.options).filter(e=>e.startsWith(`=`));if(a.length>0)for(let n of a){let r=n.slice(1),a=$(e.options[n],t);i.push(`if (c === ${r}) return ${a}; `)}let o=Object.keys(e.options).filter(e=>!e.startsWith(`=`));if(o.length>1||o.length===1&&o[0]!==`other`){i.push(`const __cat = new Intl.PluralRules('${t}').select(c); `);for(let n of o){if(n===`other`)continue;let r=$(e.options[n],t);i.push(`if (__cat === '${n}') return ${r}; `)}}let s=e.options.other?$(e.options.other,t):`''`;return i.push(`return ${s}; `),i.push(`})(${r})`),i.join(``)}function me(e,t){let n=[];n.push(`((s) => { `);let r=Object.keys(e.options).filter(e=>e!==`other`);for(let i of r){let r=$(e.options[i],t);n.push(`if (s === '${Z(i)}') return ${r}; `)}let i=e.options.other?$(e.options.other,t):`''`;return n.push(`return ${i}; `),n.push(`})(String(v.${e.variable} ?? ''))`),n.join(``)}function he(e,t,n,r){let i=[];i.push(`// @fluenti/compiled v1`);let a=[];for(let o of n){let n=`_${(0,u.hashMessage)(o)}`,s=e[o],c=ge(s,o,t,r);if(c===void 0)i.push(`/* @__PURE__ */ export const ${n} = undefined`);else if(Q(c)){let e=$((0,u.parse)(c),t);i.push(`/* @__PURE__ */ export const ${n} = (v) => ${e}`)}else if(ce(c)){let e=ue(le(c));i.push(`/* @__PURE__ */ export const ${n} = (v) => \`${e}\``)}else i.push(`/* @__PURE__ */ export const ${n} = '${Z(c)}'`);a.push({id:o,exportName:n})}if(a.length===0)return`// @fluenti/compiled v1
|
|
8
|
+
// empty catalog
|
|
9
|
+
export default {}
|
|
10
|
+
`;i.push(``),i.push(`export default {`);for(let{id:e,exportName:t}of a)i.push(` '${Z(e)}': ${t},`);return i.push(`}`),i.push(``),i.join(`
|
|
11
|
+
`)}function ge(e,t,n,r){let i=r??n;if(e){if(e.translation!==void 0&&e.translation.length>0)return e.translation;if(n===i)return e.message??t}}function _e(e,t){let n=[];n.push(`export const locales = ${JSON.stringify(e)}`),n.push(``),n.push(`export const loaders = {`);for(let t of e)n.push(` '${Z(t)}': () => import('./${t}.js'),`);return n.push(`}`),n.push(``),n.join(`
|
|
12
|
+
`)}function ve(e){let t=new Set;for(let n of Object.values(e))for(let[e,r]of Object.entries(n))r.obsolete||t.add(e);return[...t].sort()}Object.defineProperty(exports,`a`,{enumerable:!0,get:function(){return Y}}),Object.defineProperty(exports,`c`,{enumerable:!0,get:function(){return H}}),Object.defineProperty(exports,`d`,{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return J}}),Object.defineProperty(exports,`l`,{enumerable:!0,get:function(){return V}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return he}}),Object.defineProperty(exports,`o`,{enumerable:!0,get:function(){return K}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return _e}}),Object.defineProperty(exports,`s`,{enumerable:!0,get:function(){return ie}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return ve}}),Object.defineProperty(exports,`u`,{enumerable:!0,get:function(){return C}});
|
|
13
|
+
//# sourceMappingURL=compile-CzSTgY0T.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compile-CzSTgY0T.cjs","names":[],"sources":["../src/tsx-extractor.ts","../src/vue-extractor.ts","../src/catalog.ts","../src/json-format.ts","../src/po-format.ts","../src/compile.ts"],"sourcesContent":["import type { ExtractedMessage } from '@fluenti/core'\nimport {\n createMessageId,\n isSourceNode,\n parseSourceModule,\n walkSourceAst,\n type SourceNode,\n} from '@fluenti/core/internal'\n\ninterface IdentifierNode extends SourceNode {\n type: 'Identifier'\n name: string\n}\n\ninterface StringLiteralNode extends SourceNode {\n type: 'StringLiteral'\n value: string\n}\n\ninterface NumericLiteralNode extends SourceNode {\n type: 'NumericLiteral'\n value: number\n}\n\ninterface TemplateElementNode extends SourceNode {\n type: 'TemplateElement'\n value: { raw: string; cooked: string | null }\n}\n\ninterface TemplateLiteralNode extends SourceNode {\n type: 'TemplateLiteral'\n quasis: TemplateElementNode[]\n expressions: SourceNode[]\n}\n\ninterface TaggedTemplateExpressionNode extends SourceNode {\n type: 'TaggedTemplateExpression'\n tag: SourceNode\n quasi: TemplateLiteralNode\n}\n\ninterface CallExpressionNode extends SourceNode {\n type: 'CallExpression'\n callee: SourceNode\n arguments: SourceNode[]\n}\n\ninterface ImportDeclarationNode extends SourceNode {\n type: 'ImportDeclaration'\n source: StringLiteralNode\n specifiers: SourceNode[]\n}\n\ninterface ImportSpecifierNode extends SourceNode {\n type: 'ImportSpecifier'\n imported: IdentifierNode | StringLiteralNode\n local: IdentifierNode\n}\n\ninterface ObjectExpressionNode extends SourceNode {\n type: 'ObjectExpression'\n properties: SourceNode[]\n}\n\ninterface ObjectPropertyNode extends SourceNode {\n type: 'ObjectProperty'\n key: SourceNode\n value: SourceNode\n computed?: boolean\n}\n\ninterface JSXElementNode extends SourceNode {\n type: 'JSXElement'\n openingElement: JSXOpeningElementNode\n children: SourceNode[]\n}\n\ninterface JSXFragmentNode extends SourceNode {\n type: 'JSXFragment'\n children: SourceNode[]\n}\n\ninterface JSXOpeningElementNode extends SourceNode {\n type: 'JSXOpeningElement'\n name: SourceNode\n attributes: SourceNode[]\n}\n\ninterface JSXAttributeNode extends SourceNode {\n type: 'JSXAttribute'\n name: SourceNode\n value?: SourceNode | null\n}\n\ninterface JSXExpressionContainerNode extends SourceNode {\n type: 'JSXExpressionContainer'\n expression: SourceNode\n}\n\ninterface JSXTextNode extends SourceNode {\n type: 'JSXText'\n value: string\n}\n\ninterface ExtractedDescriptor {\n id: string\n message?: string\n context?: string\n comment?: string\n}\n\nconst DIRECT_T_SOURCES = new Set([\n '@fluenti/react',\n '@fluenti/vue',\n '@fluenti/solid',\n '@fluenti/next/__generated',\n])\n\nfunction classifyExpression(expr: string): string {\n const trimmed = expr.trim()\n if (/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(trimmed)) {\n return trimmed\n }\n if (/^[a-zA-Z_$][a-zA-Z0-9_$.]*$/.test(trimmed) && !trimmed.endsWith('.')) {\n const parts = trimmed.split('.')\n return parts[parts.length - 1]!\n }\n return ''\n}\n\nfunction buildICUFromTemplate(\n strings: readonly string[],\n expressions: readonly string[],\n): string {\n let result = ''\n let positionalIndex = 0\n\n for (let index = 0; index < strings.length; index++) {\n result += strings[index]!\n if (index >= expressions.length) continue\n\n const name = classifyExpression(expressions[index]!)\n if (name === '') {\n result += `{${positionalIndex}}`\n positionalIndex++\n continue\n }\n\n result += `{${name}}`\n }\n\n return result\n}\n\nfunction createExtractedMessage(\n descriptor: ExtractedDescriptor,\n filename: string,\n node: SourceNode,\n): ExtractedMessage | undefined {\n if (!descriptor.message) {\n return undefined\n }\n\n const line = node.loc?.start.line ?? 1\n const column = (node.loc?.start.column ?? 0) + 1\n\n return {\n id: descriptor.id,\n message: descriptor.message,\n ...(descriptor.context !== undefined ? { context: descriptor.context } : {}),\n ...(descriptor.comment !== undefined ? { comment: descriptor.comment } : {}),\n origin: { file: filename, line, column },\n }\n}\n\nfunction descriptorFromStaticParts(parts: {\n id?: string\n message?: string\n context?: string\n comment?: string\n}): ExtractedDescriptor | undefined {\n if (!parts.message) {\n return undefined\n }\n\n return {\n id: parts.id ?? createMessageId(parts.message, parts.context),\n message: parts.message,\n ...(parts.context !== undefined ? { context: parts.context } : {}),\n ...(parts.comment !== undefined ? { comment: parts.comment } : {}),\n }\n}\n\nfunction extractDescriptorFromCallArgument(argument: SourceNode): ExtractedDescriptor | undefined {\n if (argument.type === 'StringLiteral') {\n return descriptorFromStaticParts({ message: (argument as StringLiteralNode).value })\n }\n\n if (argument.type === 'TemplateLiteral') {\n const template = argument as TemplateLiteralNode\n if (template.expressions.length === 0) {\n const message = template.quasis.map((quasi) => quasi.value.cooked ?? quasi.value.raw).join('')\n return descriptorFromStaticParts({ message })\n }\n return undefined\n }\n\n if (argument.type !== 'ObjectExpression') {\n return undefined\n }\n\n const staticParts: { id?: string; message?: string; context?: string; comment?: string } = {}\n for (const property of (argument as ObjectExpressionNode).properties) {\n if (property.type !== 'ObjectProperty') continue\n\n const objectProperty = property as ObjectPropertyNode\n if (objectProperty.computed || !isIdentifier(objectProperty.key)) continue\n\n const key = objectProperty.key.name\n if (!['id', 'message', 'context', 'comment'].includes(key)) continue\n\n const value = readStaticStringValue(objectProperty.value)\n if (value === undefined) continue\n staticParts[key as keyof typeof staticParts] = value\n }\n\n if (!staticParts.message) {\n return undefined\n }\n\n return descriptorFromStaticParts(staticParts)\n}\n\nfunction buildPluralICU(props: Record<string, string>): string {\n const categories = ['zero', 'one', 'two', 'few', 'many', 'other'] as const\n const countVar = props['value'] ?? props['count'] ?? 'count'\n const options: string[] = []\n const offset = props['offset']\n\n for (const category of categories) {\n const value = props[category]\n if (value === undefined) continue\n const key = category === 'zero' ? '=0' : category\n options.push(`${key} {${value}}`)\n }\n\n if (options.length === 0) {\n return ''\n }\n\n const offsetPrefix = offset ? `offset:${offset} ` : ''\n return `{${countVar}, plural, ${offsetPrefix}${options.join(' ')}}`\n}\n\nfunction extractRichTextMessage(children: readonly SourceNode[]): string | undefined {\n let nextIndex = 0\n\n function render(nodes: readonly SourceNode[]): string | undefined {\n let message = ''\n\n for (const node of nodes) {\n if (node.type === 'JSXText') {\n message += normalizeJsxText((node as JSXTextNode).value)\n continue\n }\n\n if (node.type === 'JSXElement') {\n const idx = nextIndex++\n const inner = render((node as JSXElementNode).children)\n if (inner === undefined) return undefined\n message += `<${idx}>${inner}</${idx}>`\n continue\n }\n\n if (node.type === 'JSXFragment') {\n const inner = render((node as JSXFragmentNode).children)\n if (inner === undefined) return undefined\n message += inner\n continue\n }\n\n if (node.type === 'JSXExpressionContainer') {\n const expression = (node as JSXExpressionContainerNode).expression\n if (expression.type === 'StringLiteral') {\n message += (expression as StringLiteralNode).value\n continue\n }\n if (expression.type === 'NumericLiteral') {\n message += String((expression as NumericLiteralNode).value)\n continue\n }\n return undefined\n }\n }\n\n return message\n }\n\n const message = render(children)\n if (message === undefined) return undefined\n\n const normalized = message.replace(/\\s+/g, ' ').trim()\n return normalized || undefined\n}\n\nfunction normalizeJsxText(value: string): string {\n return value.replace(/\\s+/g, ' ')\n}\n\nfunction readStaticStringValue(node: SourceNode): string | undefined {\n if (node.type === 'StringLiteral') {\n return (node as StringLiteralNode).value\n }\n\n if (node.type === 'NumericLiteral') {\n return String((node as NumericLiteralNode).value)\n }\n\n if (node.type === 'JSXExpressionContainer') {\n return readStaticStringValue((node as JSXExpressionContainerNode).expression)\n }\n\n if (node.type === 'TemplateLiteral') {\n const template = node as TemplateLiteralNode\n if (template.expressions.length === 0) {\n return template.quasis.map((quasi) => quasi.value.cooked ?? quasi.value.raw).join('')\n }\n }\n\n return undefined\n}\n\nfunction readExpressionSource(node: SourceNode, code: string): string | undefined {\n if (node.start == null || node.end == null) {\n return undefined\n }\n\n if (node.type === 'JSXExpressionContainer') {\n return readExpressionSource((node as JSXExpressionContainerNode).expression, code)\n }\n\n return code.slice(node.start, node.end).trim()\n}\n\nfunction getJsxAttribute(\n openingElement: JSXOpeningElementNode,\n name: string,\n): JSXAttributeNode | undefined {\n for (const attribute of openingElement.attributes) {\n if (attribute.type !== 'JSXAttribute') continue\n\n const jsxAttribute = attribute as JSXAttributeNode\n if (jsxAttribute.name.type === 'JSXIdentifier' && jsxAttribute.name['name'] === name) {\n return jsxAttribute\n }\n }\n\n return undefined\n}\n\nfunction extractPluralProps(\n openingElement: JSXOpeningElementNode,\n code: string,\n): Record<string, string> {\n const props: Record<string, string> = {}\n const propNames = ['id', 'value', 'count', 'offset', 'zero', 'one', 'two', 'few', 'many', 'other']\n\n for (const name of propNames) {\n const attribute = getJsxAttribute(openingElement, name)\n if (!attribute?.value) continue\n\n const staticValue = readStaticStringValue(attribute.value)\n if (staticValue !== undefined) {\n props[name] = staticValue\n continue\n }\n\n const exprValue = readExpressionSource(attribute.value, code)\n if (exprValue !== undefined && (name === 'value' || name === 'count' || name === 'offset')) {\n props[name] = exprValue\n }\n }\n\n return props\n}\n\nfunction extractTaggedTemplateMessage(\n code: string,\n node: TaggedTemplateExpressionNode,\n): ExtractedDescriptor {\n const strings = node.quasi.quasis.map((quasi) => quasi.value.cooked ?? quasi.value.raw)\n const expressions = node.quasi.expressions.map((expression) => {\n if (expression.start == null || expression.end == null) {\n return ''\n }\n return code.slice(expression.start, expression.end)\n })\n const message = buildICUFromTemplate(strings, expressions)\n\n return {\n id: createMessageId(message),\n message,\n }\n}\n\nfunction collectDirectImportTBindings(ast: SourceNode): Set<string> {\n const bindings = new Set<string>()\n const body = Array.isArray(ast['body']) ? ast['body'] : []\n\n for (const entry of body) {\n if (!isImportDeclaration(entry)) continue\n if (!DIRECT_T_SOURCES.has(entry.source.value)) continue\n\n for (const specifier of entry.specifiers) {\n if (!isImportSpecifier(specifier)) continue\n if (readImportedName(specifier) !== 't') continue\n bindings.add(specifier.local.name)\n }\n }\n\n return bindings\n}\n\nexport function extractFromTsx(code: string, filename: string): ExtractedMessage[] {\n const ast = parseSourceModule(code)\n if (!ast) {\n return []\n }\n\n const messages: ExtractedMessage[] = []\n const directImportTBindings = collectDirectImportTBindings(ast)\n\n walkSourceAst(ast, (node: SourceNode) => {\n if (node.type === 'TaggedTemplateExpression') {\n const tagged = node as TaggedTemplateExpressionNode\n if (\n isIdentifier(tagged.tag)\n && (tagged.tag.name === 't' || directImportTBindings.has(tagged.tag.name))\n ) {\n const extracted = createExtractedMessage(\n extractTaggedTemplateMessage(code, tagged),\n filename,\n tagged,\n )\n if (extracted) {\n messages.push(extracted)\n }\n }\n return\n }\n\n if (node.type === 'CallExpression') {\n const call = node as CallExpressionNode\n if (isIdentifier(call.callee) && (call.callee.name === 't' || directImportTBindings.has(call.callee.name))) {\n if (directImportTBindings.has(call.callee.name) && call.arguments[0]?.type !== 'ObjectExpression') {\n return\n }\n const descriptor = call.arguments[0] ? extractDescriptorFromCallArgument(call.arguments[0]) : undefined\n const extracted = descriptor\n ? createExtractedMessage(descriptor, filename, call)\n : undefined\n if (extracted) {\n messages.push(extracted)\n }\n }\n return\n }\n\n if (node.type !== 'JSXElement') {\n return\n }\n\n const element = node as JSXElementNode\n const openingElement = element.openingElement\n const elementName = readJsxElementName(openingElement.name)\n\n if (elementName === 'Trans') {\n const messageAttr = getJsxAttribute(openingElement, 'message')\n const idAttr = getJsxAttribute(openingElement, 'id')\n const contextAttr = getJsxAttribute(openingElement, 'context')\n const commentAttr = getJsxAttribute(openingElement, 'comment')\n\n const descriptor = messageAttr?.value\n ? buildStaticTransDescriptor({\n id: idAttr?.value ? readStaticStringValue(idAttr.value) : undefined,\n message: readStaticStringValue(messageAttr.value),\n context: contextAttr?.value ? readStaticStringValue(contextAttr.value) : undefined,\n comment: commentAttr?.value ? readStaticStringValue(commentAttr.value) : undefined,\n })\n : buildStaticTransDescriptor({\n id: idAttr?.value ? readStaticStringValue(idAttr.value) : undefined,\n message: extractRichTextMessage(element.children),\n context: contextAttr?.value ? readStaticStringValue(contextAttr.value) : undefined,\n comment: commentAttr?.value ? readStaticStringValue(commentAttr.value) : undefined,\n })\n\n const extracted = descriptor\n ? createExtractedMessage(descriptor, filename, element)\n : undefined\n if (extracted) {\n messages.push(extracted)\n }\n return\n }\n\n if (elementName === 'Plural') {\n const props = extractPluralProps(openingElement, code)\n const message = buildPluralICU(props)\n if (!message) {\n return\n }\n\n const extracted = createExtractedMessage(\n {\n id: props['id'] ?? createMessageId(message),\n message,\n },\n filename,\n element,\n )\n if (extracted) {\n messages.push(extracted)\n }\n }\n })\n\n return messages\n}\n\nfunction isImportDeclaration(node: unknown): node is ImportDeclarationNode {\n return isSourceNode(node) && node.type === 'ImportDeclaration'\n}\n\nfunction isImportSpecifier(node: unknown): node is ImportSpecifierNode {\n return isSourceNode(node) && node.type === 'ImportSpecifier'\n}\n\nfunction readImportedName(specifier: ImportSpecifierNode): string | undefined {\n if (specifier.imported.type === 'Identifier') {\n return (specifier.imported as IdentifierNode).name\n }\n if (specifier.imported.type === 'StringLiteral') {\n return (specifier.imported as StringLiteralNode).value\n }\n return undefined\n}\n\nfunction readJsxElementName(node: SourceNode): string | undefined {\n if (node.type === 'JSXIdentifier') {\n return String(node['name'])\n }\n return undefined\n}\n\nfunction buildStaticTransDescriptor(parts: {\n id: string | undefined\n message: string | undefined\n context: string | undefined\n comment: string | undefined\n}): ExtractedDescriptor | undefined {\n const payload: {\n id?: string\n message?: string\n context?: string\n comment?: string\n } = {}\n\n if (parts.id !== undefined) payload.id = parts.id\n if (parts.message !== undefined) payload.message = parts.message\n if (parts.context !== undefined) payload.context = parts.context\n if (parts.comment !== undefined) payload.comment = parts.comment\n\n return descriptorFromStaticParts(payload)\n}\n\nfunction isIdentifier(node: unknown): node is IdentifierNode {\n return isSourceNode(node) && node.type === 'Identifier'\n}\n","import type { ExtractedMessage } from '@fluenti/core'\nimport { parse as parseSFC } from '@vue/compiler-sfc'\nimport { createMessageId } from '@fluenti/core/internal'\nimport { extractFromTsx } from './tsx-extractor'\n\n// Vue template AST node types\nconst ELEMENT_NODE = 1\nconst TEXT_NODE = 2\nconst DIRECTIVE_PROP = 7\nconst ATTRIBUTE_PROP = 6\n\ninterface LocInfo {\n line: number\n column: number\n offset: number\n}\n\ninterface SourceLoc {\n start: LocInfo\n end: LocInfo\n source: string\n}\n\ninterface TemplateNode {\n type: number\n tag?: string\n tagType?: number\n props?: TemplateProp[]\n children?: TemplateNode[]\n content?: string\n loc: SourceLoc\n}\n\ninterface TemplateProp {\n type: number\n name: string | { content: string }\n rawName?: string\n arg?: { content: string; isStatic: boolean }\n exp?: { content: string }\n modifiers?: Array<{ content: string } | string>\n value?: { content: string }\n nameLoc?: SourceLoc\n loc: SourceLoc\n}\n\nfunction getTextContent(children: TemplateNode[]): string {\n return children\n .filter((c) => c.type === TEXT_NODE)\n .map((c) => (c.content ?? '').trim())\n .join('')\n}\n\nfunction buildPluralICUFromPipe(text: string, countVar: string): string {\n const forms = text.split('|').map((s) => s.trim())\n const categories = ['one', 'other', 'zero', 'few', 'many']\n const options: string[] = []\n\n if (forms.length === 2) {\n options.push(`one {${forms[0]}}`)\n options.push(`other {${forms[1]}}`)\n } else {\n for (let i = 0; i < forms.length && i < categories.length; i++) {\n options.push(`${categories[i]} {${forms[i]}}`)\n }\n }\n\n return `{${countVar}, plural, ${options.join(' ')}}`\n}\n\nfunction buildPluralICUFromProps(props: Record<string, string>): string {\n const countVar = props['count'] ?? 'count'\n const categories = ['zero', 'one', 'two', 'few', 'many', 'other']\n const options: string[] = []\n const offset = props['offset']\n\n for (const cat of categories) {\n if (props[cat] !== undefined) {\n const key = cat === 'zero' ? '=0' : cat\n options.push(`${key} {${props[cat]}}`)\n }\n }\n\n if (options.length === 0) return ''\n const offsetPrefix = offset ? `offset:${offset} ` : ''\n return `{${countVar}, plural, ${offsetPrefix}${options.join(' ')}}`\n}\n\nfunction walkTemplate(\n node: TemplateNode,\n filename: string,\n messages: ExtractedMessage[],\n): void {\n if (node.type === ELEMENT_NODE) {\n const vtDirective = node.props?.find(\n (p) => p.type === DIRECTIVE_PROP && getPropName(p) === 't',\n )\n\n if (vtDirective) {\n const RESERVED_MODIFIERS = new Set(['plural'])\n const modifiers = (vtDirective.modifiers ?? []).map(\n (m: string | { content: string }) => (typeof m === 'string' ? m : m.content),\n )\n const isPlural = modifiers.includes('plural')\n // Reconstruct dotted ID: v-t:checkout.title → arg=\"checkout\", modifier=\"title\" → \"checkout.title\"\n // Non-reserved modifiers are treated as ID path segments\n const idSegments = modifiers.filter((m: string) => !RESERVED_MODIFIERS.has(m))\n const argContent = vtDirective.arg?.content\n const explicitId = argContent\n ? [argContent, ...idSegments].join('.')\n : undefined\n const textContent = getTextContent(node.children ?? [])\n\n if (isPlural) {\n const countVar = vtDirective.exp?.content ?? 'count'\n const message = buildPluralICUFromPipe(textContent, countVar)\n const id = explicitId ?? createMessageId(message)\n messages.push({\n id,\n message,\n origin: {\n file: filename,\n line: vtDirective.loc.start.line,\n column: vtDirective.loc.start.column,\n },\n })\n } else if (textContent) {\n const id = explicitId ?? createMessageId(textContent)\n messages.push({\n id,\n message: textContent,\n origin: {\n file: filename,\n line: vtDirective.loc.start.line,\n column: vtDirective.loc.start.column,\n },\n })\n }\n }\n\n if (node.tag === 'Trans') {\n const messageProp = node.props?.find(\n (p) => p.type === ATTRIBUTE_PROP && getPropName(p) === 'message',\n )\n const idProp = node.props?.find(\n (p) => p.type === ATTRIBUTE_PROP && getPropName(p) === 'id',\n )\n const contextProp = node.props?.find(\n (p) => p.type === ATTRIBUTE_PROP && getPropName(p) === 'context',\n )\n const commentProp = node.props?.find(\n (p) => p.type === ATTRIBUTE_PROP && getPropName(p) === 'comment',\n )\n const context = contextProp?.value?.content\n const comment = commentProp?.value?.content\n\n if (messageProp?.value) {\n // Old API: <Trans message=\"...\" />\n const message = messageProp.value.content\n const id = idProp?.value?.content ?? createMessageId(message, context)\n messages.push({\n id,\n message,\n ...(context !== undefined ? { context } : {}),\n ...(comment !== undefined ? { comment } : {}),\n origin: {\n file: filename,\n line: node.loc.start.line,\n column: node.loc.start.column,\n },\n })\n } else if (node.children && node.children.length > 0) {\n // New API: <Trans>content with <a>rich text</a></Trans>\n const richText = extractRichTextFromTemplateChildren(node.children)\n if (richText.message) {\n const id = idProp?.value?.content ?? createMessageId(richText.message, context)\n messages.push({\n id,\n message: richText.message,\n ...(context !== undefined ? { context } : {}),\n ...(comment !== undefined ? { comment } : {}),\n origin: {\n file: filename,\n line: node.loc.start.line,\n column: node.loc.start.column,\n },\n })\n }\n }\n }\n\n if (node.tag === 'Plural') {\n const propsMap: Record<string, string> = {}\n let valueExpr: string | undefined\n let offsetExpr: string | undefined\n for (const prop of node.props ?? []) {\n if (prop.type === ATTRIBUTE_PROP && prop.value) {\n propsMap[getPropName(prop)] = prop.value.content\n }\n // Handle :value=\"expr\" binding (directive prop)\n if (prop.type === DIRECTIVE_PROP && getPropName(prop) === 'bind' && prop.arg?.content === 'value' && prop.exp) {\n valueExpr = prop.exp.content\n }\n if (prop.type === DIRECTIVE_PROP && getPropName(prop) === 'bind' && prop.arg?.content === 'offset' && prop.exp) {\n offsetExpr = prop.exp.content\n }\n }\n\n // Use :value binding expression as count variable, fall back to 'count' static prop\n const countVar = valueExpr ?? propsMap['count'] ?? 'count'\n const offset = offsetExpr ?? propsMap['offset']\n const pluralMessage = buildPluralICUFromProps({\n ...propsMap,\n count: countVar,\n ...(offset !== undefined ? { offset } : {}),\n })\n if (pluralMessage) {\n const id = propsMap['id'] ?? createMessageId(pluralMessage)\n messages.push({\n id,\n message: pluralMessage,\n origin: {\n file: filename,\n line: node.loc.start.line,\n column: node.loc.start.column,\n },\n })\n }\n }\n }\n\n if (node.children) {\n for (const child of node.children) {\n walkTemplate(child, filename, messages)\n }\n }\n}\n\nfunction extractRichTextFromTemplateChildren(\n children: TemplateNode[],\n): { message: string; hasElements: boolean } {\n let elementIndex = 0\n let hasElements = false\n\n const parts = children.map((child) => {\n if (child.type === TEXT_NODE) {\n return (child.content ?? '').trim() ? child.content ?? '' : ''\n }\n if (child.type === ELEMENT_NODE && child.tag) {\n hasElements = true\n const idx = elementIndex++\n const innerText = extractRichTextFromTemplateChildren(child.children ?? []).message\n return `<${idx}>${innerText}</${idx}>`\n }\n return ''\n })\n\n return {\n message: parts.join('').trim(),\n hasElements,\n }\n}\n\nfunction getPropName(prop: TemplateProp): string {\n if (typeof prop.name === 'string') return prop.name\n return prop.name.content\n}\n\nfunction extractTemplateInterpolations(\n content: string,\n filename: string,\n): ExtractedMessage[] {\n const messages: ExtractedMessage[] = []\n const interpolationRegex = /\\{\\{([\\s\\S]*?)\\}\\}/g\n let match: RegExpExecArray | null\n\n while ((match = interpolationRegex.exec(content)) !== null) {\n const expression = match[1]?.trim()\n if (!expression) continue\n\n const extracted = extractFromTsx(expression, filename)\n if (extracted.length === 0) continue\n\n const lineOffset = content.slice(0, match.index).split('\\n').length - 1\n for (const msg of extracted) {\n messages.push({\n ...msg,\n origin: {\n ...msg.origin,\n line: msg.origin.line + lineOffset,\n },\n })\n }\n }\n\n return messages\n}\n\n/** Extract messages from Vue SFC files */\nexport function extractFromVue(code: string, filename: string): ExtractedMessage[] {\n const messages: ExtractedMessage[] = []\n\n const { descriptor } = parseSFC(code, { filename })\n\n if (descriptor.template?.ast) {\n walkTemplate(descriptor.template.ast as unknown as TemplateNode, filename, messages)\n }\n\n // Also extract t() function calls from raw template source\n // (picks up t('source text') in template expressions like {{ t('...') }})\n if (descriptor.template?.content) {\n const templateMessages = extractFromTsx(descriptor.template.content, filename)\n const templateLoc = descriptor.template.loc\n const lineOffset = templateLoc.start.line - 1\n const existingIds = new Set(messages.map((m) => m.id))\n for (const msg of templateMessages) {\n if (!existingIds.has(msg.id)) {\n messages.push({\n ...msg,\n origin: {\n ...msg.origin,\n line: msg.origin.line + lineOffset,\n },\n })\n }\n }\n\n const interpolationMessages = extractTemplateInterpolations(descriptor.template.content, filename)\n for (const msg of interpolationMessages) {\n if (!existingIds.has(msg.id)) {\n messages.push({\n ...msg,\n origin: {\n ...msg.origin,\n line: msg.origin.line + lineOffset,\n },\n })\n }\n }\n }\n\n if (descriptor.scriptSetup?.content) {\n const scriptMessages = extractFromTsx(descriptor.scriptSetup.content, filename)\n const scriptLoc = descriptor.scriptSetup.loc\n const lineOffset = scriptLoc.start.line - 1\n for (const msg of scriptMessages) {\n messages.push({\n ...msg,\n origin: {\n ...msg.origin,\n line: msg.origin.line + lineOffset,\n },\n })\n }\n }\n\n if (descriptor.script?.content) {\n const scriptMessages = extractFromTsx(descriptor.script.content, filename)\n const scriptLoc = descriptor.script.loc\n const lineOffset = scriptLoc.start.line - 1\n for (const msg of scriptMessages) {\n messages.push({\n ...msg,\n origin: {\n ...msg.origin,\n line: msg.origin.line + lineOffset,\n },\n })\n }\n }\n\n return messages\n}\n","import type { ExtractedMessage } from '@fluenti/core'\n\nexport interface CatalogEntry {\n message?: string | undefined\n context?: string | undefined\n comment?: string | undefined\n translation?: string | undefined\n origin?: string | undefined\n obsolete?: boolean | undefined\n}\n\nexport type CatalogData = Record<string, CatalogEntry>\n\nexport interface UpdateResult {\n added: number\n unchanged: number\n obsolete: number\n}\n\n/** Update catalog with newly extracted messages */\nexport function updateCatalog(\n existing: CatalogData,\n extracted: ExtractedMessage[],\n): { catalog: CatalogData; result: UpdateResult } {\n const extractedIds = new Set(extracted.map((m) => m.id))\n const consumedCarryForwardIds = new Set<string>()\n const catalog: CatalogData = {}\n let added = 0\n let unchanged = 0\n let obsolete = 0\n\n for (const msg of extracted) {\n const existingEntry = existing[msg.id]\n const carried = existingEntry\n ? undefined\n : findCarryForwardEntry(existing, msg, consumedCarryForwardIds)\n const origin = `${msg.origin.file}:${msg.origin.line}`\n const baseEntry = existingEntry ?? carried?.entry\n\n if (carried) {\n consumedCarryForwardIds.add(carried.id)\n }\n\n if (baseEntry) {\n catalog[msg.id] = {\n ...baseEntry,\n message: msg.message ?? baseEntry.message,\n context: msg.context,\n comment: msg.comment,\n origin,\n obsolete: false,\n }\n unchanged++\n } else {\n catalog[msg.id] = {\n message: msg.message,\n context: msg.context,\n comment: msg.comment,\n origin,\n }\n added++\n }\n }\n\n for (const [id, entry] of Object.entries(existing)) {\n if (!extractedIds.has(id)) {\n catalog[id] = {\n ...entry,\n obsolete: true,\n }\n obsolete++\n }\n }\n\n return { catalog, result: { added, unchanged, obsolete } }\n}\n\nfunction findCarryForwardEntry(\n existing: CatalogData,\n extracted: ExtractedMessage,\n consumedCarryForwardIds: Set<string>,\n): { id: string; entry: CatalogEntry } | undefined {\n if (!extracted.context) {\n return undefined\n }\n\n const extractedOrigin = `${extracted.origin.file}:${extracted.origin.line}`\n for (const [id, entry] of Object.entries(existing)) {\n if (consumedCarryForwardIds.has(id)) continue\n if (entry.context !== undefined) continue\n if (entry.message !== extracted.message) continue\n if (!sameOrigin(entry.origin, extractedOrigin)) continue\n return { id, entry }\n }\n\n return undefined\n}\n\nfunction sameOrigin(previous: string | undefined, next: string): boolean {\n if (!previous) return false\n if (previous === next) return true\n return originFile(previous) === originFile(next)\n}\n\nfunction originFile(origin: string): string {\n const match = origin.match(/^(.*):\\d+$/)\n return match?.[1] ?? origin\n}\n","import type { CatalogData } from './catalog'\n\n/** Read a JSON catalog file */\nexport function readJsonCatalog(content: string): CatalogData {\n const raw = JSON.parse(content) as Record<string, unknown>\n const catalog: CatalogData = {}\n\n for (const [id, entry] of Object.entries(raw)) {\n if (typeof entry === 'object' && entry !== null) {\n const e = entry as Record<string, unknown>\n catalog[id] = {\n message: typeof e['message'] === 'string' ? e['message'] : undefined,\n context: typeof e['context'] === 'string' ? e['context'] : undefined,\n comment: typeof e['comment'] === 'string' ? e['comment'] : undefined,\n translation: typeof e['translation'] === 'string' ? e['translation'] : undefined,\n origin: typeof e['origin'] === 'string' ? e['origin'] : undefined,\n obsolete: typeof e['obsolete'] === 'boolean' ? e['obsolete'] : undefined,\n }\n }\n }\n\n return catalog\n}\n\n/** Write a catalog to JSON format */\nexport function writeJsonCatalog(catalog: CatalogData): string {\n const output: Record<string, Record<string, unknown>> = {}\n\n for (const [id, entry] of Object.entries(catalog)) {\n const obj: Record<string, unknown> = {}\n if (entry.message !== undefined) obj['message'] = entry.message\n if (entry.context !== undefined) obj['context'] = entry.context\n if (entry.comment !== undefined) obj['comment'] = entry.comment\n if (entry.translation !== undefined) obj['translation'] = entry.translation\n if (entry.origin !== undefined) obj['origin'] = entry.origin\n if (entry.obsolete) obj['obsolete'] = true\n output[id] = obj\n }\n\n return JSON.stringify(output, null, 2) + '\\n'\n}\n","import type { CatalogData } from './catalog'\nimport { hashMessage } from '@fluenti/core'\nimport * as gettextParser from 'gettext-parser'\n\nconst CUSTOM_ID_MARKER = 'fluenti-id:'\n\ninterface POTranslation {\n msgid: string\n msgctxt?: string\n msgstr: string[]\n comments?: {\n reference?: string\n extracted?: string\n flag?: string\n translator?: string\n previous?: string\n }\n}\n\ninterface POData {\n headers?: Record<string, string>\n translations: Record<string, Record<string, POTranslation>>\n}\n\ninterface ParsedExtractedComment {\n comment?: string\n customId?: string\n sourceMessage?: string\n}\n\n/** Read a PO catalog file */\nexport function readPoCatalog(content: string): CatalogData {\n const po = gettextParser.po.parse(content) as POData\n const catalog: CatalogData = {}\n const translations = po.translations ?? {}\n\n for (const [contextKey, entries] of Object.entries(translations)) {\n for (const [msgid, entry] of Object.entries(entries)) {\n if (!msgid) continue\n\n const context = contextKey || entry.msgctxt || undefined\n const translation = entry.msgstr?.[0] ?? undefined\n const origin = entry.comments?.reference ?? undefined\n const isObsolete = entry.comments?.flag?.includes('fuzzy') ?? false\n const { comment, customId, sourceMessage } = parseExtractedComment(entry.comments?.extracted)\n const resolvedSourceMessage = sourceMessage\n && hashMessage(sourceMessage, context) === msgid\n ? sourceMessage\n : undefined\n const id = customId\n ?? (resolvedSourceMessage ? msgid : hashMessage(msgid, context))\n\n catalog[id] = {\n message: resolvedSourceMessage ?? msgid,\n ...(context !== undefined ? { context } : {}),\n ...(comment !== undefined ? { comment } : {}),\n ...(translation ? { translation } : {}),\n ...(origin !== undefined ? { origin } : {}),\n ...(isObsolete ? { obsolete: isObsolete } : {}),\n }\n }\n }\n\n return catalog\n}\n\n/** Write a catalog to PO format */\nexport function writePoCatalog(catalog: CatalogData): string {\n const translations: POData['translations'] = {\n '': {\n '': {\n msgid: '',\n msgstr: ['Content-Type: text/plain; charset=UTF-8\\n'],\n },\n },\n }\n\n for (const [id, entry] of Object.entries(catalog)) {\n const poEntry: POTranslation = {\n msgid: entry.message ?? id,\n ...(entry.context !== undefined ? { msgctxt: entry.context } : {}),\n msgstr: [entry.translation ?? ''],\n }\n\n const comments: POTranslation['comments'] = {}\n if (entry.origin) {\n comments.reference = entry.origin\n }\n const extractedComment = buildExtractedComment(id, entry.message ?? id, entry.context, entry.comment)\n if (extractedComment) {\n comments.extracted = extractedComment\n }\n if (entry.obsolete) {\n comments.flag = 'fuzzy'\n }\n if (comments.reference || comments.extracted || comments.flag) {\n poEntry.comments = comments\n }\n\n const contextKey = entry.context ?? ''\n translations[contextKey] ??= {}\n translations[contextKey][poEntry.msgid] = poEntry\n }\n\n const poData: POData = {\n headers: {\n 'Content-Type': 'text/plain; charset=UTF-8',\n },\n translations,\n }\n\n const buffer = gettextParser.po.compile(poData as Parameters<typeof gettextParser.po.compile>[0])\n return buffer.toString()\n}\n\nfunction parseExtractedComment(\n extracted: string | undefined,\n): ParsedExtractedComment {\n if (!extracted) {\n return {}\n }\n\n const lines = extracted.split('\\n').map((line) => line.trim()).filter(Boolean)\n let customId: string | undefined\n let sourceMessage: string | undefined\n const commentLines: string[] = []\n\n for (const line of lines) {\n if (line.startsWith(CUSTOM_ID_MARKER)) {\n customId = line.slice(CUSTOM_ID_MARKER.length).trim() || undefined\n continue\n }\n if (line.startsWith('msg`') && line.endsWith('`')) {\n sourceMessage = line.slice(4, -1)\n continue\n }\n if (line.startsWith('Trans: ')) {\n sourceMessage = normalizeRichTextComment(line.slice('Trans: '.length))\n continue\n }\n commentLines.push(line)\n }\n\n return {\n ...(commentLines.length > 0 ? { comment: commentLines.join('\\n') } : {}),\n ...(customId ? { customId } : {}),\n ...(sourceMessage ? { sourceMessage } : {}),\n }\n}\n\nfunction normalizeRichTextComment(comment: string): string {\n const stack: Array<{ tag: string; index: number }> = []\n let nextIndex = 0\n\n return comment.replace(/<\\/?([a-zA-Z][\\w-]*)>/g, (match, rawTag: string) => {\n const tag = rawTag\n if (match.startsWith('</')) {\n for (let index = stack.length - 1; index >= 0; index--) {\n const entry = stack[index]\n if (entry?.tag !== tag) continue\n stack.splice(index, 1)\n return `</${entry.index}>`\n }\n return match\n }\n\n const index = nextIndex++\n stack.push({ tag, index })\n return `<${index}>`\n })\n}\n\nfunction buildExtractedComment(\n id: string,\n message: string,\n context: string | undefined,\n comment: string | undefined,\n): string | undefined {\n const lines: string[] = []\n\n if (comment) {\n lines.push(comment)\n }\n\n if (id !== hashMessage(message, context)) {\n lines.push(`${CUSTOM_ID_MARKER} ${id}`)\n }\n\n return lines.length > 0 ? lines.join('\\n') : undefined\n}\n","import type { CatalogData } from './catalog'\nimport { hashMessage } from '@fluenti/core'\nimport { parse } from '@fluenti/core'\nimport type { ASTNode, PluralNode, SelectNode } from '@fluenti/core'\n\nconst ICU_VAR_REGEX = /\\{(\\w+)\\}/g\n\nfunction hasVariables(message: string): boolean {\n return ICU_VAR_REGEX.test(message)\n}\n\n\nfunction escapeStringLiteral(str: string): string {\n return str\n .replace(/\\\\/g, '\\\\\\\\')\n .replace(/'/g, \"\\\\'\")\n .replace(/\\n/g, '\\\\n')\n .replace(/\\r/g, '\\\\r')\n}\n\nfunction escapeTemplateLiteral(str: string): string {\n return str\n .replace(/\\\\/g, '\\\\\\\\')\n .replace(/`/g, '\\\\`')\n .replace(/\\$\\{/g, '\\\\${')\n .replace(/\\n/g, '\\\\n')\n .replace(/\\r/g, '\\\\r')\n}\n\nfunction messageToTemplateString(message: string): string {\n return message.replace(ICU_VAR_REGEX, (_match, name: string) => `\\${v.${name}}`)\n}\n\n\n// ─── ICU → JS code generation for split mode ───────────────────────────────\n\nconst ICU_PLURAL_SELECT_REGEX = /\\{(\\w+),\\s*(plural|select|selectordinal)\\s*,/\n\n/** Check if message contains ICU plural/select syntax */\nfunction hasIcuPluralOrSelect(message: string): boolean {\n return ICU_PLURAL_SELECT_REGEX.test(message)\n}\n\n/**\n * Compile an ICU AST node array into a JS expression string.\n * Used for generating static code (not runtime evaluation).\n */\nfunction astToJsExpression(nodes: ASTNode[], locale: string): string {\n if (nodes.length === 0) return \"''\"\n\n const parts = nodes.map((node) => astNodeToJs(node, locale))\n\n if (parts.length === 1) return parts[0]!\n return parts.join(' + ')\n}\n\nfunction astNodeToJs(node: ASTNode, locale: string): string {\n switch (node.type) {\n case 'text':\n return `'${escapeStringLiteral(node.value)}'`\n\n case 'variable':\n if (node.name === '#') return 'String(__c)'\n return `String(v.${node.name} ?? '{${node.name}}')`\n\n case 'plural':\n return pluralToJs(node as PluralNode, locale)\n\n case 'select':\n return selectToJs(node as SelectNode, locale)\n\n case 'function':\n return `String(v.${node.variable} ?? '')`\n }\n}\n\nfunction pluralToJs(node: PluralNode, locale: string): string {\n const offset = node.offset ?? 0\n const countExpr = offset ? `(v.${node.variable} - ${offset})` : `v.${node.variable}`\n\n const lines: string[] = []\n lines.push(`((c) => { const __c = c; `)\n\n // Exact matches first\n const exactKeys = Object.keys(node.options).filter((k) => k.startsWith('='))\n if (exactKeys.length > 0) {\n for (const key of exactKeys) {\n const num = key.slice(1)\n const body = astToJsExpression(node.options[key]!, locale)\n lines.push(`if (c === ${num}) return ${body}; `)\n }\n }\n\n // CLDR categories via Intl.PluralRules\n const cldrKeys = Object.keys(node.options).filter((k) => !k.startsWith('='))\n if (cldrKeys.length > 1 || (cldrKeys.length === 1 && cldrKeys[0] !== 'other')) {\n lines.push(`const __cat = new Intl.PluralRules('${locale}').select(c); `)\n for (const key of cldrKeys) {\n if (key === 'other') continue\n const body = astToJsExpression(node.options[key]!, locale)\n lines.push(`if (__cat === '${key}') return ${body}; `)\n }\n }\n\n // Fallback to 'other'\n const otherBody = node.options['other']\n ? astToJsExpression(node.options['other'], locale)\n : \"''\"\n lines.push(`return ${otherBody}; `)\n lines.push(`})(${countExpr})`)\n\n return lines.join('')\n}\n\nfunction selectToJs(node: SelectNode, locale: string): string {\n const lines: string[] = []\n lines.push(`((s) => { `)\n\n const keys = Object.keys(node.options).filter((k) => k !== 'other')\n for (const key of keys) {\n const body = astToJsExpression(node.options[key]!, locale)\n lines.push(`if (s === '${escapeStringLiteral(key)}') return ${body}; `)\n }\n\n const otherBody = node.options['other']\n ? astToJsExpression(node.options['other'], locale)\n : \"''\"\n lines.push(`return ${otherBody}; `)\n lines.push(`})(String(v.${node.variable} ?? ''))`)\n\n return lines.join('')\n}\n\n/**\n * Compile a catalog to ES module with tree-shakeable named exports.\n * Each message becomes a `/* @__PURE__ */` annotated named export.\n * A default export maps message IDs to their compiled values for runtime lookup.\n */\n/** Catalog format version. Bump when the compiled output format changes. */\nexport const CATALOG_VERSION = 1\n\nexport function compileCatalog(\n catalog: CatalogData,\n locale: string,\n allIds: string[],\n sourceLocale?: string,\n): string {\n const lines: string[] = []\n lines.push(`// @fluenti/compiled v${CATALOG_VERSION}`)\n const exportNames: Array<{ id: string; exportName: string }> = []\n\n for (const id of allIds) {\n const hash = hashMessage(id)\n const exportName = `_${hash}`\n const entry = catalog[id]\n const translated = resolveCompiledMessage(entry, id, locale, sourceLocale)\n\n if (translated === undefined) {\n lines.push(`/* @__PURE__ */ export const ${exportName} = undefined`)\n } else if (hasIcuPluralOrSelect(translated)) {\n // Parse ICU and compile to JS\n const ast = parse(translated)\n const jsExpr = astToJsExpression(ast, locale)\n lines.push(`/* @__PURE__ */ export const ${exportName} = (v) => ${jsExpr}`)\n } else if (hasVariables(translated)) {\n const templateStr = messageToTemplateString(escapeTemplateLiteral(translated))\n lines.push(`/* @__PURE__ */ export const ${exportName} = (v) => \\`${templateStr}\\``)\n } else {\n lines.push(`/* @__PURE__ */ export const ${exportName} = '${escapeStringLiteral(translated)}'`)\n }\n\n exportNames.push({ id, exportName })\n }\n\n if (exportNames.length === 0) {\n return `// @fluenti/compiled v${CATALOG_VERSION}\\n// empty catalog\\nexport default {}\\n`\n }\n\n // Default export maps message IDs → compiled values for runtime lookup\n lines.push('')\n lines.push('export default {')\n for (const { id, exportName } of exportNames) {\n lines.push(` '${escapeStringLiteral(id)}': ${exportName},`)\n }\n lines.push('}')\n lines.push('')\n\n return lines.join('\\n')\n}\n\nfunction resolveCompiledMessage(\n entry: CatalogData[string] | undefined,\n id: string,\n locale: string,\n sourceLocale: string | undefined,\n): string | undefined {\n const effectiveSourceLocale = sourceLocale ?? locale\n\n if (!entry) {\n return undefined\n }\n\n if (entry.translation !== undefined && entry.translation.length > 0) {\n return entry.translation\n }\n\n if (locale === effectiveSourceLocale) {\n return entry.message ?? id\n }\n\n return undefined\n}\n\n/**\n * Generate the index module that exports locale list and lazy loaders.\n */\nexport function compileIndex(locales: string[], _catalogDir: string): string {\n const lines: string[] = []\n lines.push(`export const locales = ${JSON.stringify(locales)}`)\n lines.push('')\n lines.push('export const loaders = {')\n for (const locale of locales) {\n lines.push(` '${escapeStringLiteral(locale)}': () => import('./${locale}.js'),`)\n }\n lines.push('}')\n lines.push('')\n return lines.join('\\n')\n}\n\n/**\n * Collect the union of all message IDs across all locale catalogs.\n * Ensures every locale file exports the same names.\n */\nexport function collectAllIds(catalogs: Record<string, CatalogData>): string[] {\n const idSet = new Set<string>()\n for (const catalog of Object.values(catalogs)) {\n for (const [id, entry] of Object.entries(catalog)) {\n if (!entry.obsolete) {\n idSet.add(id)\n }\n }\n }\n return [...idSet].sort()\n}\n"],"mappings":"mmBA+GA,IAAM,EAAmB,IAAI,IAAI,CAC/B,iBACA,eACA,iBACA,4BACD,CAAC,CAEF,SAAS,EAAmB,EAAsB,CAChD,IAAM,EAAU,EAAK,MAAM,CAC3B,GAAI,6BAA6B,KAAK,EAAQ,CAC5C,OAAO,EAET,GAAI,8BAA8B,KAAK,EAAQ,EAAI,CAAC,EAAQ,SAAS,IAAI,CAAE,CACzE,IAAM,EAAQ,EAAQ,MAAM,IAAI,CAChC,OAAO,EAAM,EAAM,OAAS,GAE9B,MAAO,GAGT,SAAS,GACP,EACA,EACQ,CACR,IAAI,EAAS,GACT,EAAkB,EAEtB,IAAK,IAAI,EAAQ,EAAG,EAAQ,EAAQ,OAAQ,IAAS,CAEnD,GADA,GAAU,EAAQ,GACd,GAAS,EAAY,OAAQ,SAEjC,IAAM,EAAO,EAAmB,EAAY,GAAQ,CACpD,GAAI,IAAS,GAAI,CACf,GAAU,IAAI,EAAgB,GAC9B,IACA,SAGF,GAAU,IAAI,EAAK,GAGrB,OAAO,EAGT,SAAS,EACP,EACA,EACA,EAC8B,CAC9B,GAAI,CAAC,EAAW,QACd,OAGF,IAAM,EAAO,EAAK,KAAK,MAAM,MAAQ,EAC/B,GAAU,EAAK,KAAK,MAAM,QAAU,GAAK,EAE/C,MAAO,CACL,GAAI,EAAW,GACf,QAAS,EAAW,QACpB,GAAI,EAAW,UAAY,IAAA,GAA8C,EAAE,CAApC,CAAE,QAAS,EAAW,QA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