@scoutello/i18n-magic 0.14.0 → 0.15.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.
@@ -1 +1 @@
1
- {"version":3,"file":"i18n-magic.cjs.production.min.js","sources":["../src/lib/languges.ts","../src/lib/utils.ts","../src/commands/check-missing.ts","../src/commands/replace.ts","../src/commands/scan.ts","../src/commands/sync-locales.ts","../src/index.ts"],"sourcesContent":["export const languages = [\n {\n label: \"Deutsch\",\n name: \"German\",\n value: \"de\",\n },\n {\n label: \"English\",\n name: \"English\",\n value: \"en\",\n },\n {\n label: \"Español\",\n name: \"Spanish\",\n value: \"es\",\n },\n {\n label: \"Français\",\n name: \"French\",\n value: \"fr\",\n },\n {\n label: \"Dansk\",\n name: \"Danish\",\n value: \"dk\",\n },\n {\n label: \"中文\",\n name: \"Chinese\",\n value: \"cn\",\n },\n {\n label: \"Русский\",\n name: \"Russian\",\n value: \"ru\",\n },\n {\n label: \"Italiano\",\n name: \"Italian\",\n value: \"it\",\n },\n {\n label: \"Nederlands\",\n name: \"Dutch\",\n value: \"nl\",\n },\n {\n label: \"Português\",\n name: \"Portuguese\",\n value: \"pt\",\n },\n {\n label: \"Türkçe\",\n name: \"Turkish\",\n value: \"tr\",\n },\n {\n label: \"Polski\",\n name: \"Polish\",\n value: \"pl\",\n },\n {\n label: \"Українська\",\n name: \"Ukrainian\",\n value: \"ua\",\n },\n {\n label: \"Suomi\",\n name: \"Finnish\",\n value: \"fi\",\n },\n {\n label: \"Norsk\",\n name: \"Norwegian\",\n value: \"no\",\n },\n {\n label: \"Svenska\",\n name: \"Swedish\",\n value: \"sv\",\n },\n {\n label: \"Čeština\",\n name: \"Czech\",\n value: \"cz\",\n },\n {\n label: \"Ελληνικά\",\n name: \"Greek\",\n value: \"gr\",\n },\n {\n label: \"日本語\",\n name: \"Japanese\",\n value: \"jp\",\n },\n {\n label: \"한국어\",\n name: \"Korean\",\n value: \"kr\",\n },\n {\n label: \"Română\",\n name: \"Romanian\",\n value: \"ro\",\n },\n {\n label: \"Hrvatski\",\n name: \"Croatian\",\n value: \"hr\",\n },\n {\n label: \"Magyar\",\n name: \"Hungarian\",\n value: \"hu\",\n },\n {\n label: \"Slovensky\",\n name: \"Slovak\",\n value: \"sk\",\n },\n {\n label: \"हिन्दी\",\n name: \"Hindi\",\n value: \"hi\",\n },\n {\n label: \"தமிழ்\",\n name: \"Tamil\",\n value: \"ta\",\n },\n {\n label: \"Bahasa Indonesia\",\n name: \"Indonesian\",\n value: \"id\",\n },\n {\n label: \"Tiếng Việt\",\n name: \"Vietnamese\",\n value: \"vn\",\n },\n]\n","import glob from \"fast-glob\"\nimport { Parser } from \"i18next-scanner\"\nimport fs from \"node:fs\"\nimport path from \"node:path\"\nimport type OpenAI from \"openai\"\nimport prompts from \"prompts\"\nimport { languages } from \"./languges\"\nimport type { Configuration } from \"./types\"\n\nexport const loadConfig = ({\n configPath = \"i18n-magic.js\",\n}: { configPath: string }) => {\n const filePath = path.join(process.cwd(), configPath)\n\n if (!fs.existsSync(filePath)) {\n console.error(\"Config file does not exist:\", filePath)\n process.exit(1)\n }\n\n try {\n const config = require(filePath)\n // Validate config if needed\n return config\n } catch (error) {\n console.error(\"Error while loading config:\", error)\n process.exit(1)\n }\n}\n\nexport function removeDuplicatesFromArray<T>(arr: T[]): T[] {\n return arr.filter((item, index) => arr.indexOf(item) === index)\n}\n\nexport const translateKey = async ({\n inputLanguage,\n context,\n object,\n openai,\n outputLanguage,\n model,\n}: {\n object: Record<string, string>\n context: string\n inputLanguage: string\n outputLanguage: string\n model: string\n openai: OpenAI\n}) => {\n // Split object into chunks of 100 keys\n const entries = Object.entries(object)\n const chunks: Array<[string, string][]> = []\n\n for (let i = 0; i < entries.length; i += 100) {\n chunks.push(entries.slice(i, i + 100))\n }\n\n let result: Record<string, string> = {}\n\n const existingInput = languages.find((l) => l.value === inputLanguage)\n const existingOutput = languages.find((l) => l.value === outputLanguage)\n\n const input = existingInput?.label || inputLanguage\n const output = existingOutput?.label || outputLanguage\n\n // Translate each chunk\n for (const chunk of chunks) {\n const chunkObject = Object.fromEntries(chunk)\n const completion = await openai.beta.chat.completions.parse({\n model,\n messages: [\n {\n content: `You are a bot that translates the values of a locales JSON. ${\n context\n ? `The user provided some additional context or guidelines about what to fill in the blanks: \\\"${context}\\\". `\n : \"\"\n }The user provides you a JSON with a field named \"inputLanguage\", which defines the language the values of the JSON are defined in. It also has a field named \"outputLanguage\", which defines the language you should translate the values to. The last field is named \"data\", which includes the object with the values to translate. The keys of the values should never be changed. You output only a JSON, which has the same keys as the input, but with translated values. I give you an example input: {\"inputLanguage\": \"English\", outputLanguage: \"German\", \"keys\": {\"hello\": \"Hello\", \"world\": \"World\"}}. The output should be {\"hello\": \"Hallo\", \"world\": \"Welt\"}.`,\n role: \"system\",\n },\n {\n content: JSON.stringify({\n inputLanguage: input,\n outputLanguage: output,\n data: chunkObject,\n }),\n role: \"user\",\n },\n ],\n response_format: {\n type: \"json_object\",\n },\n })\n\n const translatedChunk = JSON.parse(\n completion.choices[0].message.content,\n ) as Record<string, string>\n\n // Merge translated chunk with result\n result = { ...result, ...translatedChunk }\n\n // Optional: Add a small delay between chunks to avoid rate limiting\n await new Promise((resolve) => setTimeout(resolve, 100))\n }\n\n return result\n}\n\nexport const loadLocalesFile = async (\n loadPath:\n | string\n | ((locale: string, namespace: string) => Promise<Record<string, string>>),\n locale: string,\n namespace: string,\n) => {\n if (typeof loadPath === \"string\") {\n const resolvedPath = loadPath\n .replace(\"{{lng}}\", locale)\n .replace(\"{{ns}}\", namespace)\n\n const content = fs.readFileSync(resolvedPath, \"utf-8\")\n const json = JSON.parse(content)\n\n return json as Record<string, string>\n }\n\n return loadPath(locale, namespace)\n}\n\nexport const writeLocalesFile = async (\n savePath:\n | string\n | ((\n locale: string,\n namespace: string,\n data: Record<string, string>,\n ) => Promise<void>),\n locale: string,\n namespace: string,\n data: Record<string, string>,\n) => {\n if (typeof savePath === \"string\") {\n const resolvedSavePath = savePath\n .replace(\"{{lng}}\", locale)\n .replace(\"{{ns}}\", namespace)\n\n fs.writeFileSync(resolvedSavePath, JSON.stringify(data, null, 2))\n\n return\n }\n\n await savePath(locale, namespace, data)\n}\n\nexport const getPureKey = (\n key: string,\n namespace?: string,\n isDefault?: boolean,\n) => {\n const splitted = key.split(\":\")\n\n if (splitted.length === 1) {\n if (isDefault) {\n return key\n }\n\n return null\n }\n\n if (splitted[0] === namespace) {\n return splitted[1]\n }\n\n return null\n}\n\nexport const getMissingKeys = async ({\n globPatterns,\n namespaces,\n defaultNamespace,\n defaultLocale,\n loadPath,\n}: Configuration) => {\n const parser = new Parser({\n nsSeparator: false,\n keySeparator: false,\n })\n\n const files = await glob([...globPatterns, \"!**/node_modules/**\"])\n\n const keys = []\n\n for (const file of files) {\n const content = fs.readFileSync(file, \"utf-8\")\n parser.parseFuncFromString(content, { list: [\"t\"] }, (key: string) => {\n keys.push(key)\n })\n }\n\n const uniqueKeys = removeDuplicatesFromArray(keys)\n\n const newKeys = []\n\n for (const namespace of namespaces) {\n const existingKeys = await loadLocalesFile(\n loadPath,\n defaultLocale,\n namespace,\n )\n\n console.log(Object.keys(existingKeys).length, \"existing keys\")\n\n for (const key of uniqueKeys) {\n const pureKey = getPureKey(key, namespace, namespace === defaultNamespace)\n\n if (!pureKey) {\n continue\n }\n\n if (!existingKeys[pureKey]) {\n newKeys.push({ key: pureKey, namespace })\n }\n }\n }\n\n return newKeys\n}\n\nexport const getTextInput = async (prompt: string) => {\n const input = await prompts({\n name: \"value\",\n type: \"text\",\n message: prompt,\n onState: (state) => {\n if (state.aborted) {\n process.nextTick(() => {\n process.exit(0)\n })\n }\n },\n })\n\n return input.value as string\n}\n\nexport const checkAllKeysExist = async ({\n namespaces,\n defaultLocale,\n loadPath,\n locales,\n context,\n openai,\n savePath,\n disableTranslation,\n model,\n}: Configuration) => {\n if (disableTranslation) {\n return\n }\n\n for (const namespace of namespaces) {\n const defaultLocaleKeys = await loadLocalesFile(\n loadPath,\n defaultLocale,\n namespace,\n )\n\n for (const locale of locales) {\n if (locale === defaultLocale) continue\n\n const localeKeys = await loadLocalesFile(loadPath, locale, namespace)\n const missingKeys: Record<string, string> = {}\n\n // Check which keys from default locale are missing in current locale\n for (const [key, value] of Object.entries(defaultLocaleKeys)) {\n if (!localeKeys[key]) {\n missingKeys[key] = value\n }\n }\n\n // If there are missing keys, translate them\n if (Object.keys(missingKeys).length > 0) {\n console.log(\n `Found ${Object.keys(missingKeys).length} missing keys in ${locale} (namespace: ${namespace})`,\n )\n\n const translatedValues = await translateKey({\n inputLanguage: defaultLocale,\n outputLanguage: locale,\n context,\n object: missingKeys,\n openai,\n model,\n })\n\n // Merge translated values with existing ones\n const updatedLocaleKeys = {\n ...localeKeys,\n ...translatedValues,\n }\n\n // Save the updated translations\n writeLocalesFile(savePath, locale, namespace, updatedLocaleKeys)\n console.log(\n `✓ Translated and saved missing keys for ${locale} (namespace: ${namespace})`,\n )\n }\n }\n }\n}\n\nexport class TranslationError extends Error {\n constructor(\n message: string,\n public locale?: string,\n public namespace?: string,\n public cause?: Error,\n ) {\n super(message)\n this.name = \"TranslationError\"\n }\n}\n","import type { Configuration } from \"../lib/types\"\nimport { getMissingKeys } from \"../lib/utils\"\n\nexport const checkMissing = async (config: Configuration) => {\n const newKeys = await getMissingKeys(config)\n\n if (newKeys.length > 0) {\n console.error(\"Error: Missing translations found!\")\n process.exit(1)\n }\n}\n","import type { Configuration } from \"../lib/types\"\nimport {\n getTextInput,\n loadLocalesFile,\n translateKey,\n writeLocalesFile,\n} from \"../lib/utils\"\n\nconst getKeyToReplace = async (keys: Record<string, string>) => {\n const keyToReplace = await getTextInput(\n \"Enter the key to replace the translation for: \",\n )\n\n if (!keys[keyToReplace]) {\n console.log(`The key \"${keyToReplace}\" does not exist.`)\n return await getKeyToReplace(keys)\n }\n\n console.log(`The key \"${keyToReplace}\" exists.`)\n return keyToReplace\n}\n\nexport const replaceTranslation = async (config: Configuration) => {\n const {\n loadPath,\n savePath,\n defaultLocale,\n defaultNamespace,\n namespaces,\n locales,\n globPatterns,\n context,\n openai,\n } = config\n\n const keys = await loadLocalesFile(\n config.loadPath,\n config.defaultLocale,\n config.defaultNamespace,\n )\n\n const keyToReplace = await getKeyToReplace(keys)\n\n console.log(\n `The current translation in ${defaultLocale} for \"${keyToReplace}\" is \"${keys[keyToReplace]}\".`,\n )\n\n const newTranslation = await getTextInput(\"Enter the new translation: \")\n\n for (const locale of locales) {\n let newValue = \"\"\n if (locale === defaultLocale) {\n newValue = newTranslation\n } else {\n const translation = await translateKey({\n context,\n inputLanguage: defaultLocale,\n outputLanguage: locale,\n object: {\n [keyToReplace]: newTranslation,\n },\n openai,\n model: config.model,\n })\n\n newValue = translation[keyToReplace]\n }\n\n const existingKeys = await loadLocalesFile(\n loadPath,\n locale,\n defaultNamespace,\n )\n\n existingKeys[keyToReplace] = newValue\n\n writeLocalesFile(savePath, locale, defaultNamespace, existingKeys)\n\n console.log(\n `The new translation for \"${keyToReplace}\" in ${locale} is \"${newValue}\".`,\n )\n }\n}\n","import type { Configuration } from \"../lib/types\"\nimport {\n checkAllKeysExist,\n getMissingKeys,\n getTextInput,\n loadLocalesFile,\n translateKey,\n writeLocalesFile,\n} from \"../lib/utils\"\n\nexport const translateMissing = async (config: Configuration) => {\n const {\n loadPath,\n savePath,\n defaultLocale,\n namespaces,\n locales,\n context,\n openai,\n disableTranslation,\n } = config\n\n const newKeys = await getMissingKeys(config)\n\n if (newKeys.length === 0) {\n console.log(\"No new keys found.\")\n\n await checkAllKeysExist(config)\n\n return\n }\n\n console.log(\n `${newKeys.length} keys are missing. Please provide the values for the following keys in ${defaultLocale}:`,\n )\n\n const newKeysWithDefaultLocale = []\n\n for (const newKey of newKeys) {\n const answer = await getTextInput(newKey.key)\n\n newKeysWithDefaultLocale.push({\n key: newKey.key,\n namespace: newKey.namespace,\n value: answer,\n })\n }\n\n const newKeysObject = newKeysWithDefaultLocale.reduce((prev, next) => {\n prev[next.key] = next.value\n\n return prev\n }, {})\n\n const allLocales = disableTranslation ? [defaultLocale] : locales\n\n for (const locale of allLocales) {\n let translatedValues = {}\n\n if (locale === defaultLocale) {\n translatedValues = newKeysObject\n } else {\n translatedValues = await translateKey({\n inputLanguage: defaultLocale,\n outputLanguage: locale,\n context,\n object: newKeysObject,\n openai,\n model: config.model,\n })\n }\n\n for (const namespace of namespaces) {\n const existingKeys = await loadLocalesFile(loadPath, locale, namespace)\n\n const relevantKeys = newKeysWithDefaultLocale.filter(\n (key) => key.namespace === namespace,\n )\n\n if (relevantKeys.length === 0) {\n continue\n }\n\n for (const key of relevantKeys) {\n existingKeys[key.key] = translatedValues[key.key]\n }\n\n writeLocalesFile(savePath, locale, namespace, existingKeys)\n }\n }\n\n await checkAllKeysExist(config)\n\n console.log(`Successfully translated ${newKeys.length} keys.`)\n}\n","import type { Configuration } from \"../lib/types\"\nimport {\n TranslationError,\n loadLocalesFile,\n translateKey,\n writeLocalesFile,\n} from \"../lib/utils\"\n\nexport const syncLocales = async (config: Configuration) => {\n const {\n loadPath,\n savePath,\n defaultLocale,\n namespaces,\n locales,\n context,\n openai,\n } = config\n\n try {\n for (const namespace of namespaces) {\n let defaultLocaleKeys: Record<string, string>\n\n try {\n defaultLocaleKeys = await loadLocalesFile(\n loadPath,\n defaultLocale,\n namespace,\n )\n } catch (error) {\n throw new TranslationError(\n `Failed to load default locale file for namespace \"${namespace}\"`,\n defaultLocale,\n namespace,\n error instanceof Error ? error : undefined,\n )\n }\n\n for (const locale of locales) {\n if (locale === defaultLocale) continue\n\n let localeKeys: Record<string, string>\n try {\n localeKeys = await loadLocalesFile(loadPath, locale, namespace)\n } catch (error) {\n console.warn(\n `Warning: Could not load locale file for ${locale} (namespace: ${namespace}). Creating new file.`,\n )\n localeKeys = {}\n }\n\n const missingKeys: Record<string, string> = {}\n\n // Check which keys from default locale are missing in current locale\n for (const [key, value] of Object.entries(defaultLocaleKeys)) {\n if (!localeKeys[key]) {\n missingKeys[key] = value\n }\n }\n\n // If there are missing keys, translate them\n if (Object.keys(missingKeys).length > 0) {\n console.log(\n `Found ${Object.keys(missingKeys).length} missing keys in ${locale} (namespace: ${namespace})`,\n )\n\n let translatedValues: Record<string, string>\n try {\n translatedValues = await translateKey({\n inputLanguage: defaultLocale,\n outputLanguage: locale,\n context,\n object: missingKeys,\n openai,\n model: config.model,\n })\n } catch (error) {\n throw new TranslationError(\n `Failed to translate keys for locale \"${locale}\" (namespace: ${namespace})`,\n locale,\n namespace,\n error instanceof Error ? error : undefined,\n )\n }\n\n // Merge translated values with existing ones\n const updatedLocaleKeys = {\n ...localeKeys,\n ...translatedValues,\n }\n\n try {\n await writeLocalesFile(\n savePath,\n locale,\n namespace,\n updatedLocaleKeys,\n )\n } catch (error) {\n throw new TranslationError(\n `Failed to save translations for locale \"${locale}\" (namespace: ${namespace})`,\n locale,\n namespace,\n error instanceof Error ? error : undefined,\n )\n }\n\n console.log(\n `Successfully translated and saved ${Object.keys(missingKeys).length} keys for ${locale} (namespace: ${namespace})`,\n )\n } else {\n console.log(\n `No missing keys found for ${locale} (namespace: ${namespace})`,\n )\n }\n }\n }\n } catch (error) {\n if (error instanceof TranslationError) {\n throw error\n }\n throw new TranslationError(\n \"An unexpected error occurred during translation\",\n undefined,\n undefined,\n error instanceof Error ? error : undefined,\n )\n }\n}\n","import { Command } from \"commander\"\nimport dotenv from \"dotenv\"\nimport OpenAI from \"openai\"\nimport { checkMissing } from \"./commands/check-missing\"\nimport { replaceTranslation } from \"./commands/replace\"\nimport { translateMissing } from \"./commands/scan\"\nimport { syncLocales } from \"./commands/sync-locales\"\nimport type { CommandType, Configuration } from \"./lib/types\"\nimport { loadConfig } from \"./lib/utils\"\n\n// Only run CLI initialization when this file is executed directly\n\nconst program = new Command()\n\nprogram\n .name(\"i18n-magic\")\n .description(\n \"CLI to help you manage your locales JSON with translations, replacements, etc. with OpenAI.\",\n )\n .version(\"0.2.0\")\n .option(\"-c, --config <path>\", \"path to config file\")\n .option(\"-e, --env <path>\", \"path to .env file\")\n\nconst commands: CommandType[] = [\n {\n name: \"scan\",\n description:\n \"Scan for missing translations, get prompted for each, translate it to the other locales and save it to the JSON file.\",\n action: translateMissing,\n },\n {\n name: \"replace\",\n description:\n \"Replace a translation based on the key, and translate it to the other locales and save it to the JSON file.\",\n action: replaceTranslation,\n },\n {\n name: \"check-missing\",\n description:\n \"Check if there are any missing translations. Useful for a CI/CD pipeline or husky hook.\",\n action: checkMissing,\n },\n {\n name: \"sync\",\n description:\n \"Sync the translations from the default locale to the other locales. Useful for a CI/CD pipeline or husky hook.\",\n action: syncLocales,\n },\n]\n\nfor (const command of commands) {\n program\n .command(command.name)\n .description(command.description)\n .action(async () => {\n const res = dotenv.config({\n path: program.opts().env || \".env\",\n })\n\n const config: Configuration = await loadConfig({\n configPath: program.opts().config,\n })\n\n const isGemini = (config.model as string)?.includes(\"gemini\")\n\n // Get API key from environment or config\n const openaiKey = res.parsed.OPENAI_API_KEY || config.OPENAI_API_KEY\n const geminiKey = res.parsed.GEMINI_API_KEY || config.GEMINI_API_KEY\n\n // Select appropriate key based on model type\n const key = isGemini ? geminiKey : openaiKey\n\n if (!key) {\n const keyType = isGemini ? \"GEMINI_API_KEY\" : \"OPENAI_API_KEY\"\n console.error(\n `Please provide a${isGemini ? \" Gemini\" : \"n OpenAI\"} API key in your .env file or config, called ${keyType}.`,\n )\n process.exit(1)\n }\n\n const openai = new OpenAI({\n apiKey: key,\n ...(isGemini && {\n baseURL: \"https://generativelanguage.googleapis.com/v1beta/openai/\",\n }),\n })\n\n command.action({ ...config, openai })\n })\n}\n\nprogram.parse(process.argv)\n"],"names":["languages","label","name","value","loadConfig","_ref","_ref$configPath","configPath","filePath","path","join","process","cwd","fs","existsSync","console","error","exit","require","removeDuplicatesFromArray","arr","filter","item","index","indexOf","translateKey","_ref3","_asyncToGenerator","_regeneratorRuntime","mark","_callee","_ref2","inputLanguage","context","openai","outputLanguage","model","entries","chunks","i","result","existingInput","existingOutput","input","output","_i","_chunks","chunkObject","translatedChunk","wrap","_context","prev","next","Object","object","length","push","slice","find","l","fromEntries","beta","chat","completions","parse","messages","content","role","JSON","stringify","data","response_format","type","sent","choices","message","_extends","Promise","resolve","setTimeout","abrupt","stop","_x","apply","this","arguments","loadLocalesFile","_ref4","_callee2","loadPath","locale","namespace","resolvedPath","json","_context2","replace","readFileSync","_x2","_x3","_x4","writeLocalesFile","_ref5","_callee3","savePath","resolvedSavePath","_context3","writeFileSync","_x5","_x6","_x7","_x8","getPureKey","key","isDefault","splitted","split","getMissingKeys","_ref7","_callee4","_ref6","globPatterns","namespaces","defaultNamespace","defaultLocale","parser","keys","_iterator","_step","uniqueKeys","newKeys","_iterator2","_step2","existingKeys","_iterator3","_step3","pureKey","_context4","Parser","nsSeparator","keySeparator","glob","concat","_createForOfIteratorHelperLoose","done","parseFuncFromString","list","log","_x9","getTextInput","_ref8","_callee5","prompt","_context5","prompts","onState","state","aborted","nextTick","_x10","checkAllKeysExist","_ref10","_callee6","_ref9","locales","_iterator4","_step4","defaultLocaleKeys","_iterator5","_step5","localeKeys","missingKeys","_i2","_Object$entries","_Object$entries$_i","updatedLocaleKeys","_context6","disableTranslation","_x11","TranslationError","_Error","cause","_this","call","_wrapNativeSuper","Error","checkMissing","config","getKeyToReplace","keyToReplace","replaceTranslation","newTranslation","newValue","_object","translateMissing","newKeysWithDefaultLocale","newKey","newKeysObject","translatedValues","_loop","reduce","relevantKeys","delegateYield","t0","syncLocales","undefined","t1","warn","t2","t3","t4","program","Command","description","version","option","command","_commands","action","_config$model","res","isGemini","openaiKey","geminiKey","dotenv","opts","env","includes","parsed","OPENAI_API_KEY","GEMINI_API_KEY","OpenAI","apiKey","baseURL","argv"],"mappings":"y9RAAO,IAAMA,EAAY,CACvB,CACEC,MAAO,UACPC,KAAM,SACNC,MAAO,MAET,CACEF,MAAO,UACPC,KAAM,UACNC,MAAO,MAET,CACEF,MAAO,UACPC,KAAM,UACNC,MAAO,MAET,CACEF,MAAO,WACPC,KAAM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K,IAGTiB,EAAS,IAAIoM,EAAM1J,EAAA,CACvB2J,OAAQvH,GACJ4G,GAAY,CACdY,QAAS,8DAIbjB,EAAQE,OAAM7I,KAAM8G,EAAM,CAAExJ,OAAAA,KAAS,KAAA,GAAA,IAAA,MAAA,OAAAgB,EAAA+B,OAAA,GAAAnD,EACtC,KACL,EAvCAe,EAAA,EAAA2K,EA3BgC,CAC9B,CACEtN,KAAM,OACNkN,YACE,wHACFK,OAAQxB,GAEV,CACE/L,KAAM,UACNkN,YACE,8GACFK,OAAQ5B,GAEV,CACE3L,KAAM,gBACNkN,YACE,0FACFK,OAAQhC,GAEV,CACEvL,KAAM,OACNkN,YACE,iHACFK,OAAQd,IAIkB9J,EAAA2K,EAAAjK,OAAAV,IAAAyJ,IAyC9BY,EAAQlJ,MAAMrD,QAAQ8N"}
1
+ {"version":3,"file":"i18n-magic.cjs.production.min.js","sources":["../src/lib/languges.ts","../src/lib/utils.ts","../src/commands/check-missing.ts","../src/commands/replace.ts","../src/commands/scan.ts","../src/commands/sync-locales.ts","../src/index.ts"],"sourcesContent":["export const languages = [\n {\n label: \"Deutsch\",\n name: \"German\",\n value: \"de\",\n },\n {\n label: \"English\",\n name: \"English\",\n value: \"en\",\n },\n {\n label: \"Español\",\n name: \"Spanish\",\n value: \"es\",\n },\n {\n label: \"Français\",\n name: \"French\",\n value: \"fr\",\n },\n {\n label: \"Dansk\",\n name: \"Danish\",\n value: \"dk\",\n },\n {\n label: \"中文\",\n name: \"Chinese\",\n value: \"cn\",\n },\n {\n label: \"Русский\",\n name: \"Russian\",\n value: \"ru\",\n },\n {\n label: \"Italiano\",\n name: \"Italian\",\n value: \"it\",\n },\n {\n label: \"Nederlands\",\n name: \"Dutch\",\n value: \"nl\",\n },\n {\n label: \"Português\",\n name: \"Portuguese\",\n value: \"pt\",\n },\n {\n label: \"Türkçe\",\n name: \"Turkish\",\n value: \"tr\",\n },\n {\n label: \"Polski\",\n name: \"Polish\",\n value: \"pl\",\n },\n {\n label: \"Українська\",\n name: \"Ukrainian\",\n value: \"ua\",\n },\n {\n label: \"Suomi\",\n name: \"Finnish\",\n value: \"fi\",\n },\n {\n label: \"Norsk\",\n name: \"Norwegian\",\n value: \"no\",\n },\n {\n label: \"Svenska\",\n name: \"Swedish\",\n value: \"sv\",\n },\n {\n label: \"Čeština\",\n name: \"Czech\",\n value: \"cz\",\n },\n {\n label: \"Ελληνικά\",\n name: \"Greek\",\n value: \"gr\",\n },\n {\n label: \"日本語\",\n name: \"Japanese\",\n value: \"jp\",\n },\n {\n label: \"한국어\",\n name: \"Korean\",\n value: \"kr\",\n },\n {\n label: \"Română\",\n name: \"Romanian\",\n value: \"ro\",\n },\n {\n label: \"Hrvatski\",\n name: \"Croatian\",\n value: \"hr\",\n },\n {\n label: \"Magyar\",\n name: \"Hungarian\",\n value: \"hu\",\n },\n {\n label: \"Slovensky\",\n name: \"Slovak\",\n value: \"sk\",\n },\n {\n label: \"हिन्दी\",\n name: \"Hindi\",\n value: \"hi\",\n },\n {\n label: \"தமிழ்\",\n name: \"Tamil\",\n value: \"ta\",\n },\n {\n label: \"Bahasa Indonesia\",\n name: \"Indonesian\",\n value: \"id\",\n },\n {\n label: \"Tiếng Việt\",\n name: \"Vietnamese\",\n value: \"vn\",\n },\n]\n","import glob from \"fast-glob\"\nimport { Parser } from \"i18next-scanner\"\nimport fs from \"node:fs\"\nimport path from \"node:path\"\nimport type OpenAI from \"openai\"\nimport prompts from \"prompts\"\nimport { languages } from \"./languges\"\nimport type { Configuration } from \"./types\"\n\nexport const loadConfig = ({\n configPath = \"i18n-magic.js\",\n}: { configPath: string }) => {\n const filePath = path.join(process.cwd(), configPath)\n\n if (!fs.existsSync(filePath)) {\n console.error(\"Config file does not exist:\", filePath)\n process.exit(1)\n }\n\n try {\n const config = require(filePath)\n // Validate config if needed\n return config\n } catch (error) {\n console.error(\"Error while loading config:\", error)\n process.exit(1)\n }\n}\n\nexport function removeDuplicatesFromArray<T>(arr: T[]): T[] {\n return arr.filter((item, index) => arr.indexOf(item) === index)\n}\n\nexport const translateKey = async ({\n inputLanguage,\n context,\n object,\n openai,\n outputLanguage,\n model,\n}: {\n object: Record<string, string>\n context: string\n inputLanguage: string\n outputLanguage: string\n model: string\n openai: OpenAI\n}) => {\n // Split object into chunks of 100 keys\n const entries = Object.entries(object)\n const chunks: Array<[string, string][]> = []\n\n for (let i = 0; i < entries.length; i += 100) {\n chunks.push(entries.slice(i, i + 100))\n }\n\n let result: Record<string, string> = {}\n\n const existingInput = languages.find((l) => l.value === inputLanguage)\n const existingOutput = languages.find((l) => l.value === outputLanguage)\n\n const input = existingInput?.label || inputLanguage\n const output = existingOutput?.label || outputLanguage\n\n // Translate each chunk\n for (const chunk of chunks) {\n const chunkObject = Object.fromEntries(chunk)\n const completion = await openai.beta.chat.completions.parse({\n model,\n messages: [\n {\n content: `You are a bot that translates the values of a locales JSON. ${\n context\n ? `The user provided some additional context or guidelines about what to fill in the blanks: \\\"${context}\\\". `\n : \"\"\n }The user provides you a JSON with a field named \"inputLanguage\", which defines the language the values of the JSON are defined in. It also has a field named \"outputLanguage\", which defines the language you should translate the values to. The last field is named \"data\", which includes the object with the values to translate. The keys of the values should never be changed. You output only a JSON, which has the same keys as the input, but with translated values. I give you an example input: {\"inputLanguage\": \"English\", outputLanguage: \"German\", \"keys\": {\"hello\": \"Hello\", \"world\": \"World\"}}. The output should be {\"hello\": \"Hallo\", \"world\": \"Welt\"}.`,\n role: \"system\",\n },\n {\n content: JSON.stringify({\n inputLanguage: input,\n outputLanguage: output,\n data: chunkObject,\n }),\n role: \"user\",\n },\n ],\n response_format: {\n type: \"json_object\",\n },\n })\n\n const translatedChunk = JSON.parse(\n completion.choices[0].message.content,\n ) as Record<string, string>\n\n // Merge translated chunk with result\n result = { ...result, ...translatedChunk }\n\n // Optional: Add a small delay between chunks to avoid rate limiting\n await new Promise((resolve) => setTimeout(resolve, 100))\n }\n\n return result\n}\n\nexport const loadLocalesFile = async (\n loadPath:\n | string\n | ((locale: string, namespace: string) => Promise<Record<string, string>>),\n locale: string,\n namespace: string,\n) => {\n if (typeof loadPath === \"string\") {\n const resolvedPath = loadPath\n .replace(\"{{lng}}\", locale)\n .replace(\"{{ns}}\", namespace)\n\n const content = fs.readFileSync(resolvedPath, \"utf-8\")\n const json = JSON.parse(content)\n\n return json as Record<string, string>\n }\n\n return loadPath(locale, namespace)\n}\n\nexport const writeLocalesFile = async (\n savePath:\n | string\n | ((\n locale: string,\n namespace: string,\n data: Record<string, string>,\n ) => Promise<void>),\n locale: string,\n namespace: string,\n data: Record<string, string>,\n) => {\n if (typeof savePath === \"string\") {\n const resolvedSavePath = savePath\n .replace(\"{{lng}}\", locale)\n .replace(\"{{ns}}\", namespace)\n\n fs.writeFileSync(resolvedSavePath, JSON.stringify(data, null, 2))\n\n return\n }\n\n await savePath(locale, namespace, data)\n}\n\nexport const getPureKey = (\n key: string,\n namespace?: string,\n isDefault?: boolean,\n) => {\n const splitted = key.split(\":\")\n\n if (splitted.length === 1) {\n if (isDefault) {\n return key\n }\n\n return null\n }\n\n if (splitted[0] === namespace) {\n return splitted[1]\n }\n\n return null\n}\n\nexport const getMissingKeys = async ({\n globPatterns,\n namespaces,\n defaultNamespace,\n defaultLocale,\n loadPath,\n}: Configuration) => {\n const parser = new Parser({\n nsSeparator: false,\n keySeparator: false,\n })\n\n const files = await glob([...globPatterns, \"!**/node_modules/**\"])\n\n const keys = []\n\n for (const file of files) {\n const content = fs.readFileSync(file, \"utf-8\")\n parser.parseFuncFromString(content, { list: [\"t\"] }, (key: string) => {\n keys.push(key)\n })\n }\n\n const uniqueKeys = removeDuplicatesFromArray(keys)\n\n const newKeys = []\n\n for (const namespace of namespaces) {\n const existingKeys = await loadLocalesFile(\n loadPath,\n defaultLocale,\n namespace,\n )\n\n console.log(Object.keys(existingKeys).length, \"existing keys\")\n\n for (const key of uniqueKeys) {\n const pureKey = getPureKey(key, namespace, namespace === defaultNamespace)\n\n if (!pureKey) {\n continue\n }\n\n if (!existingKeys[pureKey]) {\n newKeys.push({ key: pureKey, namespace })\n }\n }\n }\n\n return newKeys\n}\n\nexport const getTextInput = async (prompt: string) => {\n const input = await prompts({\n name: \"value\",\n type: \"text\",\n message: prompt,\n onState: (state) => {\n if (state.aborted) {\n process.nextTick(() => {\n process.exit(0)\n })\n }\n },\n })\n\n return input.value as string\n}\n\nexport const checkAllKeysExist = async ({\n namespaces,\n defaultLocale,\n loadPath,\n locales,\n context,\n openai,\n savePath,\n disableTranslation,\n model,\n}: Configuration) => {\n if (disableTranslation) {\n return\n }\n\n for (const namespace of namespaces) {\n const defaultLocaleKeys = await loadLocalesFile(\n loadPath,\n defaultLocale,\n namespace,\n )\n\n for (const locale of locales) {\n if (locale === defaultLocale) continue\n\n const localeKeys = await loadLocalesFile(loadPath, locale, namespace)\n const missingKeys: Record<string, string> = {}\n\n // Check which keys from default locale are missing in current locale\n for (const [key, value] of Object.entries(defaultLocaleKeys)) {\n if (!localeKeys[key]) {\n missingKeys[key] = value\n }\n }\n\n // If there are missing keys, translate them\n if (Object.keys(missingKeys).length > 0) {\n console.log(\n `Found ${Object.keys(missingKeys).length} missing keys in ${locale} (namespace: ${namespace})`,\n )\n\n const translatedValues = await translateKey({\n inputLanguage: defaultLocale,\n outputLanguage: locale,\n context,\n object: missingKeys,\n openai,\n model,\n })\n\n // Merge translated values with existing ones\n const updatedLocaleKeys = {\n ...localeKeys,\n ...translatedValues,\n }\n\n // Save the updated translations\n writeLocalesFile(savePath, locale, namespace, updatedLocaleKeys)\n console.log(\n `✓ Translated and saved missing keys for ${locale} (namespace: ${namespace})`,\n )\n }\n }\n }\n}\n\nexport class TranslationError extends Error {\n constructor(\n message: string,\n public locale?: string,\n public namespace?: string,\n public cause?: Error,\n ) {\n super(message)\n this.name = \"TranslationError\"\n }\n}\n","import type { Configuration } from \"../lib/types\"\nimport { getMissingKeys } from \"../lib/utils\"\n\nexport const checkMissing = async (config: Configuration) => {\n const newKeys = await getMissingKeys(config)\n\n if (newKeys.length > 0) {\n console.error(\"Error: Missing translations found!\")\n process.exit(1)\n }\n}\n","import type { Configuration } from \"../lib/types\"\nimport {\n getTextInput,\n loadLocalesFile,\n translateKey,\n writeLocalesFile,\n} from \"../lib/utils\"\n\nconst getKeyToReplace = async (keys: Record<string, string>) => {\n const keyToReplace = await getTextInput(\n \"Enter the key to replace the translation for: \",\n )\n\n if (!keys[keyToReplace]) {\n console.log(`The key \"${keyToReplace}\" does not exist.`)\n return await getKeyToReplace(keys)\n }\n\n console.log(`The key \"${keyToReplace}\" exists.`)\n return keyToReplace\n}\n\nexport const replaceTranslation = async (\n config: Configuration,\n key?: string,\n) => {\n const {\n loadPath,\n savePath,\n defaultLocale,\n defaultNamespace,\n namespaces,\n locales,\n globPatterns,\n context,\n openai,\n } = config\n\n const keys = await loadLocalesFile(\n config.loadPath,\n config.defaultLocale,\n config.defaultNamespace,\n )\n\n let keyToReplace: string\n\n if (key) {\n if (keys[key]) {\n keyToReplace = key\n console.log(`The key \"${keyToReplace}\" exists.`)\n } else {\n console.log(`The key \"${key}\" does not exist.`)\n keyToReplace = await getKeyToReplace(keys)\n }\n } else {\n keyToReplace = await getKeyToReplace(keys)\n }\n\n console.log(\n `The current translation in ${defaultLocale} for \"${keyToReplace}\" is \"${keys[keyToReplace]}\".`,\n )\n\n const newTranslation = await getTextInput(\"Enter the new translation: \")\n\n for (const locale of locales) {\n let newValue = \"\"\n if (locale === defaultLocale) {\n newValue = newTranslation\n } else {\n const translation = await translateKey({\n context,\n inputLanguage: defaultLocale,\n outputLanguage: locale,\n object: {\n [keyToReplace]: newTranslation,\n },\n openai,\n model: config.model,\n })\n\n newValue = translation[keyToReplace]\n }\n\n const existingKeys = await loadLocalesFile(\n loadPath,\n locale,\n defaultNamespace,\n )\n\n existingKeys[keyToReplace] = newValue\n\n writeLocalesFile(savePath, locale, defaultNamespace, existingKeys)\n\n console.log(\n `The new translation for \"${keyToReplace}\" in ${locale} is \"${newValue}\".`,\n )\n }\n}\n","import type { Configuration } from \"../lib/types\"\nimport {\n checkAllKeysExist,\n getMissingKeys,\n getTextInput,\n loadLocalesFile,\n translateKey,\n writeLocalesFile,\n} from \"../lib/utils\"\n\nexport const translateMissing = async (config: Configuration) => {\n const {\n loadPath,\n savePath,\n defaultLocale,\n namespaces,\n locales,\n context,\n openai,\n disableTranslation,\n } = config\n\n const newKeys = await getMissingKeys(config)\n\n if (newKeys.length === 0) {\n console.log(\"No new keys found.\")\n\n await checkAllKeysExist(config)\n\n return\n }\n\n console.log(\n `${newKeys.length} keys are missing. Please provide the values for the following keys in ${defaultLocale}:`,\n )\n\n const newKeysWithDefaultLocale = []\n\n for (const newKey of newKeys) {\n const answer = await getTextInput(newKey.key)\n\n newKeysWithDefaultLocale.push({\n key: newKey.key,\n namespace: newKey.namespace,\n value: answer,\n })\n }\n\n const newKeysObject = newKeysWithDefaultLocale.reduce((prev, next) => {\n prev[next.key] = next.value\n\n return prev\n }, {})\n\n const allLocales = disableTranslation ? [defaultLocale] : locales\n\n for (const locale of allLocales) {\n let translatedValues = {}\n\n if (locale === defaultLocale) {\n translatedValues = newKeysObject\n } else {\n translatedValues = await translateKey({\n inputLanguage: defaultLocale,\n outputLanguage: locale,\n context,\n object: newKeysObject,\n openai,\n model: config.model,\n })\n }\n\n for (const namespace of namespaces) {\n const existingKeys = await loadLocalesFile(loadPath, locale, namespace)\n\n const relevantKeys = newKeysWithDefaultLocale.filter(\n (key) => key.namespace === namespace,\n )\n\n if (relevantKeys.length === 0) {\n continue\n }\n\n for (const key of relevantKeys) {\n existingKeys[key.key] = translatedValues[key.key]\n }\n\n writeLocalesFile(savePath, locale, namespace, existingKeys)\n }\n }\n\n await checkAllKeysExist(config)\n\n console.log(`Successfully translated ${newKeys.length} keys.`)\n}\n","import type { Configuration } from \"../lib/types\"\nimport {\n TranslationError,\n loadLocalesFile,\n translateKey,\n writeLocalesFile,\n} from \"../lib/utils\"\n\nexport const syncLocales = async (config: Configuration) => {\n const {\n loadPath,\n savePath,\n defaultLocale,\n namespaces,\n locales,\n context,\n openai,\n } = config\n\n try {\n for (const namespace of namespaces) {\n let defaultLocaleKeys: Record<string, string>\n\n try {\n defaultLocaleKeys = await loadLocalesFile(\n loadPath,\n defaultLocale,\n namespace,\n )\n } catch (error) {\n throw new TranslationError(\n `Failed to load default locale file for namespace \"${namespace}\"`,\n defaultLocale,\n namespace,\n error instanceof Error ? error : undefined,\n )\n }\n\n for (const locale of locales) {\n if (locale === defaultLocale) continue\n\n let localeKeys: Record<string, string>\n try {\n localeKeys = await loadLocalesFile(loadPath, locale, namespace)\n } catch (error) {\n console.warn(\n `Warning: Could not load locale file for ${locale} (namespace: ${namespace}). Creating new file.`,\n )\n localeKeys = {}\n }\n\n const missingKeys: Record<string, string> = {}\n\n // Check which keys from default locale are missing in current locale\n for (const [key, value] of Object.entries(defaultLocaleKeys)) {\n if (!localeKeys[key]) {\n missingKeys[key] = value\n }\n }\n\n // If there are missing keys, translate them\n if (Object.keys(missingKeys).length > 0) {\n console.log(\n `Found ${Object.keys(missingKeys).length} missing keys in ${locale} (namespace: ${namespace})`,\n )\n\n let translatedValues: Record<string, string>\n try {\n translatedValues = await translateKey({\n inputLanguage: defaultLocale,\n outputLanguage: locale,\n context,\n object: missingKeys,\n openai,\n model: config.model,\n })\n } catch (error) {\n throw new TranslationError(\n `Failed to translate keys for locale \"${locale}\" (namespace: ${namespace})`,\n locale,\n namespace,\n error instanceof Error ? error : undefined,\n )\n }\n\n // Merge translated values with existing ones\n const updatedLocaleKeys = {\n ...localeKeys,\n ...translatedValues,\n }\n\n try {\n await writeLocalesFile(\n savePath,\n locale,\n namespace,\n updatedLocaleKeys,\n )\n } catch (error) {\n throw new TranslationError(\n `Failed to save translations for locale \"${locale}\" (namespace: ${namespace})`,\n locale,\n namespace,\n error instanceof Error ? error : undefined,\n )\n }\n\n console.log(\n `Successfully translated and saved ${Object.keys(missingKeys).length} keys for ${locale} (namespace: ${namespace})`,\n )\n } else {\n console.log(\n `No missing keys found for ${locale} (namespace: ${namespace})`,\n )\n }\n }\n }\n } catch (error) {\n if (error instanceof TranslationError) {\n throw error\n }\n throw new TranslationError(\n \"An unexpected error occurred during translation\",\n undefined,\n undefined,\n error instanceof Error ? error : undefined,\n )\n }\n}\n","import { Command } from \"commander\"\nimport dotenv from \"dotenv\"\nimport OpenAI from \"openai\"\nimport { checkMissing } from \"./commands/check-missing\"\nimport { replaceTranslation } from \"./commands/replace\"\nimport { translateMissing } from \"./commands/scan\"\nimport { syncLocales } from \"./commands/sync-locales\"\nimport type { CommandType, Configuration } from \"./lib/types\"\nimport { loadConfig } from \"./lib/utils\"\n\n// Only run CLI initialization when this file is executed directly\n\nconst program = new Command()\n\nprogram\n .name(\"i18n-magic\")\n .description(\n \"CLI to help you manage your locales JSON with translations, replacements, etc. with OpenAI.\",\n )\n .version(\"0.2.0\")\n .option(\"-c, --config <path>\", \"path to config file\")\n .option(\"-e, --env <path>\", \"path to .env file\")\n\nconst commands: CommandType[] = [\n {\n name: \"scan\",\n description:\n \"Scan for missing translations, get prompted for each, translate it to the other locales and save it to the JSON file.\",\n action: translateMissing,\n },\n {\n name: \"replace\",\n description:\n \"Replace a translation based on the key, and translate it to the other locales and save it to the JSON file.\",\n action: replaceTranslation,\n },\n {\n name: \"check-missing\",\n description:\n \"Check if there are any missing translations. Useful for a CI/CD pipeline or husky hook.\",\n action: checkMissing,\n },\n {\n name: \"sync\",\n description:\n \"Sync the translations from the default locale to the other locales. Useful for a CI/CD pipeline or husky hook.\",\n action: syncLocales,\n },\n]\n\nfor (const command of commands) {\n const cmd = program.command(command.name).description(command.description)\n\n // Add key option to replace command\n if (command.name === \"replace\") {\n cmd.option(\"-k, --key <key>\", \"translation key to replace\")\n }\n\n cmd.action(async (options) => {\n const res = dotenv.config({\n path: program.opts().env || \".env\",\n })\n\n const config: Configuration = await loadConfig({\n configPath: program.opts().config,\n })\n\n const isGemini = (config.model as string)?.includes(\"gemini\")\n\n // Get API key from environment or config\n const openaiKey = res.parsed.OPENAI_API_KEY || config.OPENAI_API_KEY\n const geminiKey = res.parsed.GEMINI_API_KEY || config.GEMINI_API_KEY\n\n // Select appropriate key based on model type\n const key = isGemini ? geminiKey : openaiKey\n\n if (!key) {\n const keyType = isGemini ? \"GEMINI_API_KEY\" : \"OPENAI_API_KEY\"\n console.error(\n `Please provide a${isGemini ? \" Gemini\" : \"n OpenAI\"} API key in your .env file or config, called ${keyType}.`,\n )\n process.exit(1)\n }\n\n const openai = new OpenAI({\n apiKey: key,\n ...(isGemini && {\n baseURL: \"https://generativelanguage.googleapis.com/v1beta/openai/\",\n }),\n })\n\n if (command.name === \"replace\" && options.key) {\n command.action({ ...config, openai }, options.key)\n } else {\n command.action({ ...config, openai })\n }\n })\n}\n\nprogram.parse(process.argv)\n"],"names":["languages","label","name","value","loadConfig","_ref","_ref$configPath","configPath","filePath","path","join","process","cwd","fs","existsSync","console","error","exit","require","removeDuplicatesFromArray","arr","filter","item","index","indexOf","translateKey","_ref3","_asyncToGenerator","_regeneratorRuntime","mark","_callee","_ref2","inputLanguage","context","openai","outputLanguage","model","entries","chunks","i","result","existingInput","existingOutput","input","output","_i","_chunks","chunkObject","translatedChunk","wrap","_context","prev","next","Object","object","length","push","slice","find","l","fromEntries","beta","chat","completions","parse","messages","content","role","JSON","stringify","data","response_format","type","sent","choices","message","_extends","Promise","resolve","setTimeout","abrupt","stop","_x","apply","this","arguments","loadLocalesFile","_ref4","_callee2","loadPath","locale","namespace","resolvedPath","json","_context2","replace","readFileSync","_x2","_x3","_x4","writeLocalesFile","_ref5","_callee3","savePath","resolvedSavePath","_context3","writeFileSync","_x5","_x6","_x7","_x8","getPureKey","key","isDefault","splitted","split","getMissingKeys","_ref7","_callee4","_ref6","globPatterns","namespaces","defaultNamespace","defaultLocale","parser","keys","_iterator","_step","uniqueKeys","newKeys","_iterator2","_step2","existingKeys","_iterator3","_step3","pureKey","_context4","Parser","nsSeparator","keySeparator","glob","concat","_createForOfIteratorHelperLoose","done","parseFuncFromString","list","log","_x9","getTextInput","_ref8","_callee5","prompt","_context5","prompts","onState","state","aborted","nextTick","_x10","checkAllKeysExist","_ref10","_callee6","_ref9","locales","_iterator4","_step4","defaultLocaleKeys","_iterator5","_step5","localeKeys","missingKeys","_i2","_Object$entries","_Object$entries$_i","updatedLocaleKeys","_context6","disableTranslation","_x11","TranslationError","_Error","cause","_this","call","_wrapNativeSuper","Error","checkMissing","config","getKeyToReplace","keyToReplace","replaceTranslation","newTranslation","newValue","_object","translateMissing","newKeysWithDefaultLocale","newKey","newKeysObject","translatedValues","_loop","reduce","relevantKeys","delegateYield","t0","syncLocales","undefined","t1","warn","t2","t3","t4","program","Command","description","version","option","command","_commands","cmd","action","options","_config$model","res","isGemini","openaiKey","geminiKey","dotenv","opts","env","includes","parsed","OPENAI_API_KEY","GEMINI_API_KEY","OpenAI","apiKey","baseURL","argv"],"mappings":"y9RAAO,IAAMA,EAAY,CACvB,CACEC,MAAO,UACPC,KAAM,SACNC,MAAO,MAET,CACEF,MAAO,UACPC,KAAM,UACNC,MAAO,MAET,CACEF,MAAO,UACPC,KAAM,UACNC,MAAO,MAET,CACEF,MAAO,WACPC,KAAM,SACNC,MAAO,MAET,CACEF,MAAO,QACPC,KAAM,SACNC,MAAO,MAET,CACEF,MAAO,KACPC,KAAM,UACNC,MAAO,MAET,CACEF,MAAO,UACPC,KAAM,UACNC,MAAO,MAET,CACEF,MAAO,WACPC,KAAM,UACNC,MAAO,MAET,CACEF,MAAO,aACPC,KAAM,QACNC,MAAO,MAET,CACEF,MAAO,YACPC,KAAM,aACNC,MAAO,MAET,CACEF,MAAO,SACPC,KAAM,UACNC,MAAO,MAET,CACEF,MAAO,SACPC,KAAM,SACNC,MAAO,MAET,CACEF,MAAO,aACPC,KAAM,YACNC,MAAO,MAET,CACEF,MAAO,QACPC,KAAM,UACNC,MAAO,MAET,CACEF,MAAO,QACPC,KAAM,YACNC,MAAO,MAET,CACEF,MAAO,UACPC,KAAM,UACNC,MAAO,MAET,CACEF,MAAO,UACPC,KAAM,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EAAA,CACvB6J,OAAQzH,GACJ8G,GAAY,CACdY,QAAS,8DAIQ,YAAjBnB,EAAQrN,MAAsByN,EAAQ3G,IACxCuG,EAAQG,OAAM9I,KAAM8G,EAAM,CAAExJ,OAAAA,IAAUyL,EAAQ3G,KAE9CuG,EAAQG,OAAM9I,KAAM8G,EAAM,CAAExJ,OAAAA,KAC7B,KAAA,GAAA,IAAA,MAAA,OAAAgB,EAAA+B,OAAA,GAAAnD,EACF,KAAA,OAAA,SAAAoD,GAAA,OAAA7E,EAAA8E,MAAAC,KAAAC,UAAA,CAAC,CAtCQ,GAuCZ,EA/CAxC,EAAA,EAAA2K,EA3BgC,CAC9B,CACEtN,KAAM,OACNkN,YACE,wHACFM,OAAQzB,GAEV,CACE/L,KAAM,UACNkN,YACE,8GACFM,OAAQ7B,GAEV,CACE3L,KAAM,gBACNkN,YACE,0FACFM,OAAQjC,GAEV,CACEvL,KAAM,OACNkN,YACE,iHACFM,OAAQf,IAIkB9J,EAAA2K,EAAAjK,OAAAV,IAAAyJ,IAiD9BY,EAAQlJ,MAAMrD,QAAQgO"}
@@ -993,7 +993,7 @@ var getKeyToReplace = /*#__PURE__*/function () {
993
993
  };
994
994
  }();
995
995
  var replaceTranslation = /*#__PURE__*/function () {
996
- var _ref2 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(config) {
996
+ var _ref2 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(config, key) {
997
997
  var loadPath, savePath, defaultLocale, defaultNamespace, locales, context, openai, keys, keyToReplace, newTranslation, _iterator, _step, locale, newValue, _object, translation, existingKeys;
998
998
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
999
999
  while (1) switch (_context2.prev = _context2.next) {
@@ -1003,32 +1003,55 @@ var replaceTranslation = /*#__PURE__*/function () {
1003
1003
  return loadLocalesFile(config.loadPath, config.defaultLocale, config.defaultNamespace);
1004
1004
  case 3:
1005
1005
  keys = _context2.sent;
1006
- _context2.next = 6;
1006
+ if (!key) {
1007
+ _context2.next = 16;
1008
+ break;
1009
+ }
1010
+ if (!keys[key]) {
1011
+ _context2.next = 10;
1012
+ break;
1013
+ }
1014
+ keyToReplace = key;
1015
+ console.log("The key \"" + keyToReplace + "\" exists.");
1016
+ _context2.next = 14;
1017
+ break;
1018
+ case 10:
1019
+ console.log("The key \"" + key + "\" does not exist.");
1020
+ _context2.next = 13;
1007
1021
  return getKeyToReplace(keys);
1008
- case 6:
1022
+ case 13:
1023
+ keyToReplace = _context2.sent;
1024
+ case 14:
1025
+ _context2.next = 19;
1026
+ break;
1027
+ case 16:
1028
+ _context2.next = 18;
1029
+ return getKeyToReplace(keys);
1030
+ case 18:
1009
1031
  keyToReplace = _context2.sent;
1032
+ case 19:
1010
1033
  console.log("The current translation in " + defaultLocale + " for \"" + keyToReplace + "\" is \"" + keys[keyToReplace] + "\".");
1011
- _context2.next = 10;
1034
+ _context2.next = 22;
1012
1035
  return getTextInput("Enter the new translation: ");
1013
- case 10:
1036
+ case 22:
1014
1037
  newTranslation = _context2.sent;
1015
1038
  _iterator = _createForOfIteratorHelperLoose(locales);
1016
- case 12:
1039
+ case 24:
1017
1040
  if ((_step = _iterator()).done) {
1018
- _context2.next = 31;
1041
+ _context2.next = 43;
1019
1042
  break;
1020
1043
  }
1021
1044
  locale = _step.value;
1022
1045
  newValue = "";
1023
1046
  if (!(locale === defaultLocale)) {
1024
- _context2.next = 19;
1047
+ _context2.next = 31;
1025
1048
  break;
1026
1049
  }
1027
1050
  newValue = newTranslation;
1028
- _context2.next = 23;
1051
+ _context2.next = 35;
1029
1052
  break;
1030
- case 19:
1031
- _context2.next = 21;
1053
+ case 31:
1054
+ _context2.next = 33;
1032
1055
  return translateKey({
1033
1056
  context: context,
1034
1057
  inputLanguage: defaultLocale,
@@ -1037,27 +1060,27 @@ var replaceTranslation = /*#__PURE__*/function () {
1037
1060
  openai: openai,
1038
1061
  model: config.model
1039
1062
  });
1040
- case 21:
1063
+ case 33:
1041
1064
  translation = _context2.sent;
1042
1065
  newValue = translation[keyToReplace];
1043
- case 23:
1044
- _context2.next = 25;
1066
+ case 35:
1067
+ _context2.next = 37;
1045
1068
  return loadLocalesFile(loadPath, locale, defaultNamespace);
1046
- case 25:
1069
+ case 37:
1047
1070
  existingKeys = _context2.sent;
1048
1071
  existingKeys[keyToReplace] = newValue;
1049
1072
  writeLocalesFile(savePath, locale, defaultNamespace, existingKeys);
1050
1073
  console.log("The new translation for \"" + keyToReplace + "\" in " + locale + " is \"" + newValue + "\".");
1051
- case 29:
1052
- _context2.next = 12;
1074
+ case 41:
1075
+ _context2.next = 24;
1053
1076
  break;
1054
- case 31:
1077
+ case 43:
1055
1078
  case "end":
1056
1079
  return _context2.stop();
1057
1080
  }
1058
1081
  }, _callee2);
1059
1082
  }));
1060
- return function replaceTranslation(_x2) {
1083
+ return function replaceTranslation(_x2, _x3) {
1061
1084
  return _ref2.apply(this, arguments);
1062
1085
  };
1063
1086
  }();
@@ -1361,44 +1384,60 @@ var commands = [{
1361
1384
  }];
1362
1385
  var _loop = function _loop() {
1363
1386
  var command = _commands[_i];
1364
- program.command(command.name).description(command.description).action( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
1365
- var _config$model;
1366
- var res, config, isGemini, openaiKey, geminiKey, key, keyType, openai;
1367
- return _regeneratorRuntime().wrap(function _callee$(_context) {
1368
- while (1) switch (_context.prev = _context.next) {
1369
- case 0:
1370
- res = dotenv.config({
1371
- path: program.opts().env || ".env"
1372
- });
1373
- _context.next = 3;
1374
- return loadConfig({
1375
- configPath: program.opts().config
1376
- });
1377
- case 3:
1378
- config = _context.sent;
1379
- isGemini = (_config$model = config.model) == null ? void 0 : _config$model.includes("gemini"); // Get API key from environment or config
1380
- openaiKey = res.parsed.OPENAI_API_KEY || config.OPENAI_API_KEY;
1381
- geminiKey = res.parsed.GEMINI_API_KEY || config.GEMINI_API_KEY; // Select appropriate key based on model type
1382
- key = isGemini ? geminiKey : openaiKey;
1383
- if (!key) {
1384
- keyType = isGemini ? "GEMINI_API_KEY" : "OPENAI_API_KEY";
1385
- console.error("Please provide a" + (isGemini ? " Gemini" : "n OpenAI") + " API key in your .env file or config, called " + keyType + ".");
1386
- process.exit(1);
1387
- }
1388
- openai = new OpenAI(_extends({
1389
- apiKey: key
1390
- }, isGemini && {
1391
- baseURL: "https://generativelanguage.googleapis.com/v1beta/openai/"
1392
- }));
1393
- command.action(_extends({}, config, {
1394
- openai: openai
1395
- }));
1396
- case 11:
1397
- case "end":
1398
- return _context.stop();
1399
- }
1400
- }, _callee);
1401
- })));
1387
+ var cmd = program.command(command.name).description(command.description);
1388
+ // Add key option to replace command
1389
+ if (command.name === "replace") {
1390
+ cmd.option("-k, --key <key>", "translation key to replace");
1391
+ }
1392
+ cmd.action( /*#__PURE__*/function () {
1393
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(options) {
1394
+ var _config$model;
1395
+ var res, config, isGemini, openaiKey, geminiKey, key, keyType, openai;
1396
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
1397
+ while (1) switch (_context.prev = _context.next) {
1398
+ case 0:
1399
+ res = dotenv.config({
1400
+ path: program.opts().env || ".env"
1401
+ });
1402
+ _context.next = 3;
1403
+ return loadConfig({
1404
+ configPath: program.opts().config
1405
+ });
1406
+ case 3:
1407
+ config = _context.sent;
1408
+ isGemini = (_config$model = config.model) == null ? void 0 : _config$model.includes("gemini"); // Get API key from environment or config
1409
+ openaiKey = res.parsed.OPENAI_API_KEY || config.OPENAI_API_KEY;
1410
+ geminiKey = res.parsed.GEMINI_API_KEY || config.GEMINI_API_KEY; // Select appropriate key based on model type
1411
+ key = isGemini ? geminiKey : openaiKey;
1412
+ if (!key) {
1413
+ keyType = isGemini ? "GEMINI_API_KEY" : "OPENAI_API_KEY";
1414
+ console.error("Please provide a" + (isGemini ? " Gemini" : "n OpenAI") + " API key in your .env file or config, called " + keyType + ".");
1415
+ process.exit(1);
1416
+ }
1417
+ openai = new OpenAI(_extends({
1418
+ apiKey: key
1419
+ }, isGemini && {
1420
+ baseURL: "https://generativelanguage.googleapis.com/v1beta/openai/"
1421
+ }));
1422
+ if (command.name === "replace" && options.key) {
1423
+ command.action(_extends({}, config, {
1424
+ openai: openai
1425
+ }), options.key);
1426
+ } else {
1427
+ command.action(_extends({}, config, {
1428
+ openai: openai
1429
+ }));
1430
+ }
1431
+ case 11:
1432
+ case "end":
1433
+ return _context.stop();
1434
+ }
1435
+ }, _callee);
1436
+ }));
1437
+ return function (_x) {
1438
+ return _ref.apply(this, arguments);
1439
+ };
1440
+ }());
1402
1441
  };
1403
1442
  for (var _i = 0, _commands = commands; _i < _commands.length; _i++) {
1404
1443
  _loop();