@scoutello/i18n-magic 0.65.0 → 0.67.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.
Files changed (59) hide show
  1. package/README.md +16 -10
  2. package/dist/cli.js +20 -15
  3. package/dist/cli.js.map +1 -1
  4. package/dist/commands/check-missing.d.ts +11 -1
  5. package/dist/commands/check-missing.d.ts.map +1 -1
  6. package/dist/commands/check-missing.js +56 -96
  7. package/dist/commands/check-missing.js.map +1 -1
  8. package/dist/commands/replace.d.ts +6 -0
  9. package/dist/commands/replace.d.ts.map +1 -1
  10. package/dist/commands/replace.js +48 -29
  11. package/dist/commands/replace.js.map +1 -1
  12. package/dist/commands/scan.d.ts.map +1 -1
  13. package/dist/commands/scan.js +114 -80
  14. package/dist/commands/scan.js.map +1 -1
  15. package/dist/commands/sync-locales.d.ts.map +1 -1
  16. package/dist/commands/sync-locales.js +21 -28
  17. package/dist/commands/sync-locales.js.map +1 -1
  18. package/dist/index.d.ts +2 -1
  19. package/dist/index.d.ts.map +1 -1
  20. package/dist/index.js +1 -1
  21. package/dist/index.js.map +1 -1
  22. package/dist/lib/locale-storage.d.ts +7 -0
  23. package/dist/lib/locale-storage.d.ts.map +1 -0
  24. package/dist/lib/locale-storage.js +49 -0
  25. package/dist/lib/locale-storage.js.map +1 -0
  26. package/dist/lib/mcp-write-schemas.d.ts +56 -0
  27. package/dist/lib/mcp-write-schemas.d.ts.map +1 -0
  28. package/dist/lib/mcp-write-schemas.js +36 -0
  29. package/dist/lib/mcp-write-schemas.js.map +1 -0
  30. package/dist/lib/translation-response.d.ts +8 -0
  31. package/dist/lib/translation-response.d.ts.map +1 -0
  32. package/dist/lib/translation-response.js +43 -0
  33. package/dist/lib/translation-response.js.map +1 -0
  34. package/dist/lib/types.d.ts +1 -1
  35. package/dist/lib/types.d.ts.map +1 -1
  36. package/dist/lib/update-translation-key.d.ts +16 -0
  37. package/dist/lib/update-translation-key.d.ts.map +1 -0
  38. package/dist/lib/update-translation-key.js +67 -0
  39. package/dist/lib/update-translation-key.js.map +1 -0
  40. package/dist/lib/utils.d.ts +2 -0
  41. package/dist/lib/utils.d.ts.map +1 -1
  42. package/dist/lib/utils.js +69 -51
  43. package/dist/lib/utils.js.map +1 -1
  44. package/dist/mcp-server.js +30 -117
  45. package/dist/mcp-server.js.map +1 -1
  46. package/package.json +5 -9
  47. package/src/cli.ts +26 -18
  48. package/src/commands/check-missing.ts +83 -137
  49. package/src/commands/replace.ts +81 -43
  50. package/src/commands/scan.ts +130 -108
  51. package/src/commands/sync-locales.ts +41 -63
  52. package/src/index.ts +6 -1
  53. package/src/lib/locale-storage.ts +76 -0
  54. package/src/lib/mcp-write-schemas.ts +46 -0
  55. package/src/lib/translation-response.ts +59 -0
  56. package/src/lib/types.ts +1 -1
  57. package/src/lib/update-translation-key.ts +119 -0
  58. package/src/lib/utils.ts +92 -76
  59. package/src/mcp-server.ts +38 -167
package/README.md CHANGED
@@ -16,8 +16,8 @@ Stop context switching. Let AI handle your translations while you stay in your c
16
16
  ## 📋 Requirements
17
17
 
18
18
  - JSON-based i18n libraries (react-i18next, next-i18next, vue-i18n, etc.)
19
- - Node.js 16+
20
- - An OpenAI or Google Gemini API key
19
+ - Node.js 20+
20
+ - An OpenAI or Google Gemini API key for commands that generate translations
21
21
 
22
22
  ## Why This Matters
23
23
 
@@ -48,7 +48,9 @@ npx @scoutello/i18n-magic check-missing # CI/CD validation
48
48
 
49
49
  **`clean`** - Removes unused translation keys from all locales. Great for keeping files lean.
50
50
 
51
- **`check-missing`** - Dry-run check. Exits with error code if translations are missing. Perfect for CI pipelines.
51
+ **`check-missing`** - Read-only check across every configured locale and namespace. Exits with error code if translations are missing and never calls a provider or writes. Perfect for CI pipelines.
52
+
53
+ `check-missing`, `clean`, `remove-key`, and `restore-from-namespaces` work without provider credentials. Translation commands request a provider only when they actually have values to translate.
52
54
 
53
55
  ### Namespace Organization (for large apps)
54
56
 
@@ -75,16 +77,16 @@ Install the i18n-magic MCP server in Cursor, and your AI gets 6 tools:
75
77
  Fuzzy search across all translations. AI searches before adding anything.
76
78
 
77
79
  ### 2. `add_translation_key` - Add New Keys
78
- Adds a single key. If API translation is configured, it auto-translates to other locales; otherwise run `sync`.
80
+ Adds a single key. MCP writes require the value's explicit source `language`. If API translation is configured, it auto-translates to other locales; otherwise run `sync`.
79
81
 
80
82
  ### 3. `add_translation_keys` - Add Multiple Keys Fast
81
- Batch add 2+ keys in one call with better performance than multiple single-key calls.
83
+ Batch add 2+ keys in one call with better performance than multiple single-key calls. Every key requires its explicit source `language`.
82
84
 
83
85
  ### 4. `get_translation_key` - Check What Exists
84
86
  Retrieve current value for any key.
85
87
 
86
88
  ### 5. `update_translation_key` - Fix & Auto-Translate
87
- Update a key and **instantly translate to all languages**. No sync needed!
89
+ MCP writes require the value's explicit source `language`. With a configured provider, update and validate all locales before writing. Without a provider, update only the supplied language and report the remaining locales as pending.
88
90
 
89
91
  ### 6. `list_untranslated_keys` - Batch Check
90
92
  Show all missing keys across your codebase.
@@ -166,7 +168,7 @@ Done! Test by asking: *"Search for translations with 'password'"*
166
168
  **Result**: No duplicate keys, instant code.
167
169
 
168
170
  If nothing exists:
169
- - AI adds key(s): `add_translation_key` or `add_translation_keys`
171
+ - AI adds key(s) with an explicit source language: `add_translation_key` or `add_translation_keys`
170
172
  - If API translation is configured, other locales are updated automatically
171
173
  - If not configured, run: `npx @scoutello/i18n-magic sync`
172
174
 
@@ -177,9 +179,9 @@ If nothing exists:
177
179
  **AI**:
178
180
  1. Finds the key via search
179
181
  2. Calls `update_translation_key`
180
- 3. **Auto-translates to ALL languages instantly**
182
+ 3. Auto-translates to all languages when a provider is configured
181
183
 
182
- No sync needed!
184
+ Without a provider, the source locale is updated and the response instructs you to run `sync` for the pending locales.
183
185
 
184
186
  ### Pattern 3: Batch Check
185
187
 
@@ -220,7 +222,7 @@ npx @scoutello/i18n-magic sync
220
222
 
221
223
  Later: **"Change title to 'Your Profile'"**
222
224
 
223
- **AI**: Calls `update_translation_key` → instantly updated in all 4 languages. No sync needed!
225
+ **AI**: Calls `update_translation_key` → all locales update together with a provider, or only the source locale updates and the others are reported as pending.
224
226
 
225
227
  ---
226
228
 
@@ -238,6 +240,10 @@ context: 'E-commerce for outdoor gear. Friendly tone. Target: adventurers.'
238
240
 
239
241
  More context = better AI translations.
240
242
 
243
+ ### Fail-closed translation writes
244
+
245
+ Provider responses must contain exactly the requested keys with string values. A malformed response is retried once with a corrective prompt. If the retry or any later locale fails, `scan`, `sync`, `replace`, and programmatic add/update operations discard their staged changes without writing locale files. Final storage failures can still leave partial writes across files.
246
+
241
247
  ### CI/CD: Auto-translate on PR
242
248
 
243
249
  ```yaml
package/dist/cli.js CHANGED
@@ -2,7 +2,7 @@
2
2
  import { Command } from "commander";
3
3
  import dotenv from "dotenv";
4
4
  import OpenAI from "openai";
5
- import { checkMissing } from "./commands/check-missing.js";
5
+ import { checkMissing, MissingTranslationsError, } from "./commands/check-missing.js";
6
6
  import { removeUnusedKeys } from "./commands/clean.js";
7
7
  import { removeKey } from "./commands/remove-key.js";
8
8
  import { replaceTranslation } from "./commands/replace.js";
@@ -82,27 +82,32 @@ for (const command of commands) {
82
82
  const geminiKey = config.GEMINI_API_KEY;
83
83
  // Select appropriate key based on model type
84
84
  const key = isGemini ? geminiKey : openaiKey;
85
- if (!key) {
86
- const keyType = isGemini ? "GEMINI_API_KEY" : "OPENAI_API_KEY";
87
- console.error(`Please provide a${isGemini ? " Gemini" : "n OpenAI"} API key in your i18n-magic config file as ${keyType}.`);
88
- process.exit(1);
89
- }
90
- const openai = new OpenAI({
91
- apiKey: key,
92
- ...(isGemini && {
93
- baseURL: "https://generativelanguage.googleapis.com/v1beta/openai/",
94
- }),
95
- });
85
+ const openai = config.openai ||
86
+ (key
87
+ ? new OpenAI({
88
+ apiKey: key,
89
+ ...(isGemini && {
90
+ baseURL: "https://generativelanguage.googleapis.com/v1beta/openai/",
91
+ }),
92
+ })
93
+ : undefined);
96
94
  // For replace and remove-key commands, check for key in argument or option
97
95
  if (command.name === "replace" || command.name === "remove-key") {
98
96
  // If key is provided as positional argument, use that first
99
97
  const keyToUse = typeof arg === "string" ? arg : options.key;
100
- command.action({ ...config, openai }, keyToUse);
98
+ await command.action({ ...config, openai }, keyToUse);
101
99
  }
102
100
  else {
103
- command.action({ ...config, openai });
101
+ await command.action({ ...config, openai });
104
102
  }
105
103
  });
106
104
  }
107
- program.parse(process.argv);
105
+ program.parseAsync(process.argv).catch((error) => {
106
+ if (error instanceof MissingTranslationsError) {
107
+ process.exitCode = 1;
108
+ return;
109
+ }
110
+ console.error(error instanceof Error ? error.message : String(error));
111
+ process.exitCode = 1;
112
+ });
108
113
  //# sourceMappingURL=cli.js.map
package/dist/cli.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,MAAM,MAAM,QAAQ,CAAA;AAC3B,OAAO,MAAM,MAAM,QAAQ,CAAA;AAC3B,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAA;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAA;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAA;AACpD,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAA;AAC1D,OAAO,EAAE,qBAAqB,EAAE,MAAM,uCAAuC,CAAA;AAC7E,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAA;AAExD,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAE3C,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAA;AAE7B,OAAO;KACJ,IAAI,CAAC,YAAY,CAAC;KAClB,WAAW,CACV,6FAA6F,CAC9F;KACA,OAAO,CAA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D,MAAM,OAAO,CAAC,MAAM,CAAC,EAAE,GAAG,MAAM,EAAE,MAAM,EAAE,EAAE,QAAQ,CAAC,CAAA;QACvD,CAAC;aAAM,CAAC;YACN,MAAM,OAAO,CAAC,MAAM,CAAC,EAAE,GAAG,MAAM,EAAE,MAAM,EAAE,CAAC,CAAA;QAC7C,CAAC;IACH,CAAC,CAAC,CAAA;AACJ,CAAC;AAED,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,KAAc,EAAE,EAAE;IACxD,IAAI,KAAK,YAAY,wBAAwB,EAAE,CAAC;QAC9C,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAA;QACpB,OAAM;IACR,CAAC;IAED,OAAO,CAAC,KAAK,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAA;IACrE,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAA;AACtB,CAAC,CAAC,CAAA"}
@@ -1,3 +1,13 @@
1
1
  import type { Configuration } from "../lib/types.js";
2
- export declare const checkMissing: (config: Configuration) => Promise<void>;
2
+ export interface MissingTranslationsReport {
3
+ missing: Record<string, Record<string, string[]>>;
4
+ totalExpected: number;
5
+ totalMissing: number;
6
+ }
7
+ export declare class MissingTranslationsError extends Error {
8
+ report: MissingTranslationsReport;
9
+ constructor(report: MissingTranslationsReport);
10
+ }
11
+ export declare const collectMissingTranslations: (config: Configuration) => Promise<MissingTranslationsReport>;
12
+ export declare const checkMissing: (config: Configuration) => Promise<MissingTranslationsReport>;
3
13
  //# sourceMappingURL=check-missing.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"check-missing.d.ts","sourceRoot":"","sources":["../../src/commands/check-missing.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AASpD,eAAO,MAAM,YAAY,GAAU,QAAQ,aAAa,kBAwJvD,CAAA"}
1
+ {"version":3,"file":"check-missing.d.ts","sourceRoot":"","sources":["../../src/commands/check-missing.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAOpD,MAAM,WAAW,yBAAyB;IACxC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC,CAAA;IACjD,aAAa,EAAE,MAAM,CAAA;IACrB,YAAY,EAAE,MAAM,CAAA;CACrB;AAED,qBAAa,wBAAyB,SAAQ,KAAK;IAC9B,MAAM,EAAE,yBAAyB;gBAAjC,MAAM,EAAE,yBAAyB;CAIrD;AAED,eAAO,MAAM,0BAA0B,GACrC,QAAQ,aAAa,KACpB,OAAO,CAAC,yBAAyB,CA4DnC,CAAA;AAgBD,eAAO,MAAM,YAAY,GAAU,QAAQ,aAAa,uCASvD,CAAA"}
@@ -1,106 +1,66 @@
1
- import { getMissingKeys, findExistingTranslations, loadLocalesFile, writeLocalesFile, translateKey, } from "../lib/utils.js";
2
- export const checkMissing = async (config) => {
3
- const { loadPath, savePath, defaultLocale, namespaces, locales, context, openai, model, disableTranslationDuringScan, } = config;
4
- const newKeys = await getMissingKeys(config);
5
- if (newKeys.length === 0) {
6
- console.log("✅ No missing translations found.");
7
- return;
1
+ import { getKeysWithNamespaces, getPureKey, loadLocalesFile, } from "../lib/utils.js";
2
+ export class MissingTranslationsError extends Error {
3
+ constructor(report) {
4
+ super(`Found ${report.totalMissing} missing translation(s).`);
5
+ this.report = report;
6
+ this.name = "MissingTranslationsError";
8
7
  }
9
- console.log(`\n🔍 Found ${newKeys.length} missing key(s) in default locale (${defaultLocale}):`);
10
- // Group keys by namespace for clearer output
11
- const keysByNamespace = {};
12
- for (const key of newKeys) {
13
- for (const ns of key.namespaces) {
14
- if (!keysByNamespace[ns]) {
15
- keysByNamespace[ns] = [];
16
- }
17
- keysByNamespace[ns].push(key.key);
8
+ }
9
+ export const collectMissingTranslations = async (config) => {
10
+ const keysWithNamespaces = await getKeysWithNamespaces({
11
+ globPatterns: config.globPatterns,
12
+ defaultNamespace: config.defaultNamespace,
13
+ });
14
+ const expectedByNamespace = Object.fromEntries(config.namespaces.map((namespace) => [namespace, new Set()]));
15
+ for (const { key, namespaces } of keysWithNamespaces) {
16
+ for (const namespace of namespaces) {
17
+ if (!expectedByNamespace[namespace])
18
+ continue;
19
+ const pureKey = getPureKey(key, namespace, namespace === config.defaultNamespace);
20
+ const expectedKey = pureKey || (!key.includes(":") ? key : null);
21
+ if (expectedKey !== null)
22
+ expectedByNamespace[namespace].add(expectedKey);
18
23
  }
19
24
  }
20
- for (const [namespace, keys] of Object.entries(keysByNamespace)) {
21
- console.log(`\n 📦 ${namespace}: ${keys.length} missing key(s)`);
22
- for (const key of keys) {
23
- console.log(` - ${key}`);
24
- }
25
+ const loadedFiles = await Promise.all(config.locales.flatMap((locale) => config.namespaces.map(async (namespace) => ({
26
+ locale,
27
+ namespace,
28
+ translations: await loadLocalesFile(config.loadPath, locale, namespace, { silent: true }),
29
+ }))));
30
+ const missing = {};
31
+ let totalMissing = 0;
32
+ for (const { locale, namespace, translations } of loadedFiles) {
33
+ const missingKeys = Array.from(expectedByNamespace[namespace]).filter((key) => !Object.hasOwn(translations, key));
34
+ if (missingKeys.length === 0)
35
+ continue;
36
+ missing[locale] ?? (missing[locale] = {});
37
+ missing[locale][namespace] = missingKeys.sort();
38
+ totalMissing += missingKeys.length;
25
39
  }
26
- // Try to auto-fill from other namespaces (like scan does)
27
- const keysList = newKeys.map((k) => k.key);
28
- const existingTranslationResults = await findExistingTranslations(keysList, namespaces, defaultLocale, loadPath);
29
- const keysWithValues = [];
30
- const reusedKeys = [];
31
- const stillMissingKeys = [];
32
- for (const newKey of newKeys) {
33
- const existingValue = existingTranslationResults[newKey.key];
34
- if (existingValue !== null) {
35
- reusedKeys.push(newKey.key);
36
- keysWithValues.push({
37
- key: newKey.key,
38
- namespaces: newKey.namespaces,
39
- value: existingValue,
40
- });
41
- }
42
- else {
43
- stillMissingKeys.push(newKey.key);
44
- keysWithValues.push({
45
- key: newKey.key,
46
- namespaces: newKey.namespaces,
47
- value: null,
48
- });
49
- }
40
+ return {
41
+ missing,
42
+ totalExpected: Object.values(expectedByNamespace).reduce((total, keys) => total + keys.size, 0),
43
+ totalMissing,
44
+ };
45
+ };
46
+ const printMissingTranslationsReport = (report) => {
47
+ if (report.totalMissing === 0) {
48
+ console.log("✅ No missing translations found.");
49
+ return;
50
50
  }
51
- // If we can auto-fill some keys, do it
52
- if (reusedKeys.length > 0) {
53
- console.log(`\n🔄 Auto-reusing ${reusedKeys.length} existing value(s) from other namespaces...`);
54
- const keysToWrite = keysWithValues.filter((k) => k.value !== null);
55
- const newKeysObject = keysToWrite.reduce((prev, next) => {
56
- prev[next.key] = next.value;
57
- return prev;
58
- }, {});
59
- const allLocales = disableTranslationDuringScan ? [defaultLocale] : locales;
60
- // Batch translate for all non-default locales in parallel
61
- const translationCache = {
62
- [defaultLocale]: newKeysObject,
63
- };
64
- const nonDefaultLocales = allLocales.filter((l) => l !== defaultLocale);
65
- if (nonDefaultLocales.length > 0 && !disableTranslationDuringScan) {
66
- console.log(` 📝 Translating to ${nonDefaultLocales.length} other locale(s)...`);
67
- await Promise.all(nonDefaultLocales.map(async (locale) => {
68
- const translatedValues = await translateKey({
69
- inputLanguage: defaultLocale,
70
- outputLanguage: locale,
71
- context,
72
- object: newKeysObject,
73
- openai,
74
- model,
75
- });
76
- translationCache[locale] = translatedValues;
77
- }));
51
+ console.error(`❌ Found ${report.totalMissing} missing translation(s):`);
52
+ for (const [locale, namespaces] of Object.entries(report.missing)) {
53
+ for (const [namespace, keys] of Object.entries(namespaces)) {
54
+ console.error(` ${locale}/${namespace}: ${keys.join(", ")}`);
78
55
  }
79
- // Process all locale/namespace combinations in parallel
80
- await Promise.all(allLocales.flatMap((locale) => namespaces.map(async (namespace) => {
81
- const existingKeys = await loadLocalesFile(loadPath, locale, namespace);
82
- const relevantKeys = keysToWrite.filter((key) => key.namespaces?.includes(namespace));
83
- if (relevantKeys.length === 0) {
84
- return;
85
- }
86
- const translatedValues = translationCache[locale];
87
- for (const key of relevantKeys) {
88
- existingKeys[key.key] = translatedValues[key.key];
89
- }
90
- await writeLocalesFile(savePath, locale, namespace, existingKeys);
91
- console.log(` ✅ Updated ${locale}/${namespace}.json with ${relevantKeys.length} key(s)`);
92
- })));
93
- console.log(`\n✅ Successfully auto-filled ${reusedKeys.length} key(s) from existing translations.`);
94
56
  }
95
- // Now check if there are still missing keys that couldn't be auto-filled
96
- if (stillMissingKeys.length > 0) {
97
- console.error(`\n❌ Error: ${stillMissingKeys.length} translation(s) could not be auto-filled:`);
98
- for (const key of stillMissingKeys) {
99
- console.error(` - ${key}`);
100
- }
101
- console.error(`\nPlease run 'i18n-magic scan' to provide values for these keys.`);
102
- process.exit(1);
57
+ };
58
+ export const checkMissing = async (config) => {
59
+ const report = await collectMissingTranslations(config);
60
+ printMissingTranslationsReport(report);
61
+ if (report.totalMissing > 0) {
62
+ throw new MissingTranslationsError(report);
103
63
  }
104
- console.log("\n✅ All translations are complete.");
64
+ return report;
105
65
  };
106
66
  //# sourceMappingURL=check-missing.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"check-missing.js","sourceRoot":"","sources":["../../src/commands/check-missing.ts"],"names":[],"mappings":"AACA,OAAO,EACL,cAAc,EACd,wBAAwB,EACxB,eAAe,EACf,gBAAgB,EAChB,YAAY,GACb,MAAM,iBAAiB,CAAA;AAExB,MAAM,CAAC,MAAM,YAAY,GAAG,KAAK,EAAE,MAAqB,EAAE,EAAE;IAC1D,MAAM,EACJ,QAAQ,EACR,QAAQ,EACR,aAAa,EACb,UAAU,EACV,OAAO,EACP,OAAO,EACP,MAAM,EACN,KAAK,EACL,4BAA4B,GAC7B,GAAG,MAAM,CAAA;IAEV,MAAM,OAAO,GAAG,MAAM,cAAc,CAAC,MAAM,CAAC,CAAA;IA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ACvE,KAAK,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC;QAClE,KAAK,MAAM,CAAC,SAAS,EAAE,IAAI,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC;YAC3D,OAAO,CAAC,KAAK,CAAC,MAAM,MAAM,IAAI,SAAS,KAAK,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;QAChE,CAAC;IACH,CAAC;AACH,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,YAAY,GAAG,KAAK,EAAE,MAAqB,EAAE,EAAE;IAC1D,MAAM,MAAM,GAAG,MAAM,0BAA0B,CAAC,MAAM,CAAC,CAAA;IACvD,8BAA8B,CAAC,MAAM,CAAC,CAAA;IAEtC,IAAI,MAAM,CAAC,YAAY,GAAG,CAAC,EAAE,CAAC;QAC5B,MAAM,IAAI,wBAAwB,CAAC,MAAM,CAAC,CAAA;IAC5C,CAAC;IAED,OAAO,MAAM,CAAA;AACf,CAAC,CAAA"}
@@ -1,3 +1,9 @@
1
1
  import type { Configuration } from "../lib/types.js";
2
+ export declare const replaceTranslationValue: ({ config, key, value, targetNamespaces, }: {
3
+ config: Configuration;
4
+ key: string;
5
+ value: string;
6
+ targetNamespaces: string[];
7
+ }) => Promise<void>;
2
8
  export declare const replaceTranslation: (config: Configuration, key?: string) => Promise<void>;
3
9
  //# sourceMappingURL=replace.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"replace.d.ts","sourceRoot":"","sources":["../../src/commands/replace.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AA6BpD,eAAO,MAAM,kBAAkB,GAC7B,QAAQ,aAAa,EACrB,MAAM,MAAM,kBA0Ib,CAAA"}
1
+ {"version":3,"file":"replace.d.ts","sourceRoot":"","sources":["../../src/commands/replace.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AA6BpD,eAAO,MAAM,uBAAuB,GAAU,2CAK3C;IACD,MAAM,EAAE,aAAa,CAAA;IACrB,GAAG,EAAE,MAAM,CAAA;IACX,KAAK,EAAE,MAAM,CAAA;IACb,gBAAgB,EAAE,MAAM,EAAE,CAAA;CAC3B,kBA2DA,CAAA;AAED,eAAO,MAAM,kBAAkB,GAC7B,QAAQ,aAAa,EACrB,MAAM,MAAM,kBAyGb,CAAA"}
@@ -9,8 +9,48 @@ const getKeyToReplace = async (allAvailableKeys) => {
9
9
  console.log(`The key "${keyToReplace}" exists in namespaces: ${namespaces.join(", ")}.`);
10
10
  return { key: keyToReplace, namespaces };
11
11
  };
12
+ export const replaceTranslationValue = async ({ config, key, value, targetNamespaces, }) => {
13
+ const { loadPath, savePath, defaultLocale, locales, context, openai } = config;
14
+ const stagedFiles = new Map();
15
+ await Promise.all(targetNamespaces.flatMap((namespace) => locales.map(async (locale) => {
16
+ const existingKeys = await loadLocalesFile(loadPath, locale, namespace);
17
+ stagedFiles.set(JSON.stringify([locale, namespace]), {
18
+ ...existingKeys,
19
+ });
20
+ })));
21
+ const translationCache = {
22
+ [defaultLocale]: value,
23
+ };
24
+ await Promise.all(locales
25
+ .filter((locale) => locale !== defaultLocale)
26
+ .map(async (locale) => {
27
+ const translation = await translateKey({
28
+ context,
29
+ inputLanguage: defaultLocale,
30
+ outputLanguage: locale,
31
+ object: { [key]: value },
32
+ openai,
33
+ model: config.model,
34
+ });
35
+ translationCache[locale] = translation[key];
36
+ }));
37
+ for (const namespace of targetNamespaces) {
38
+ for (const locale of locales) {
39
+ const staged = stagedFiles.get(JSON.stringify([locale, namespace]));
40
+ if (!staged) {
41
+ throw new Error(`Internal error: no staged snapshot for ${locale}/${namespace}.`);
42
+ }
43
+ staged[key] = translationCache[locale];
44
+ }
45
+ }
46
+ for (const namespace of targetNamespaces) {
47
+ for (const locale of locales) {
48
+ await writeLocalesFile(savePath, locale, namespace, stagedFiles.get(JSON.stringify([locale, namespace])));
49
+ }
50
+ }
51
+ };
12
52
  export const replaceTranslation = async (config, key) => {
13
- const { loadPath, savePath, defaultLocale, defaultNamespace, namespaces, locales, globPatterns, context, openai, } = config;
53
+ const { loadPath, defaultLocale, defaultNamespace, namespaces, locales, globPatterns, } = config;
14
54
  // Find all keys with their namespaces from the codebase
15
55
  const keysWithNamespaces = await getKeysWithNamespaces({
16
56
  globPatterns,
@@ -77,33 +117,12 @@ export const replaceTranslation = async (config, key) => {
77
117
  }
78
118
  }
79
119
  const newTranslation = await getTextInput("Enter the new translation: ");
80
- // Batch translate for all non-default locales first
81
- const translationCache = {
82
- [defaultLocale]: newTranslation,
83
- };
84
- const nonDefaultLocales = locales.filter((l) => l !== defaultLocale);
85
- if (nonDefaultLocales.length > 0) {
86
- await Promise.all(nonDefaultLocales.map(async (locale) => {
87
- const translation = await translateKey({
88
- context,
89
- inputLanguage: defaultLocale,
90
- outputLanguage: locale,
91
- object: {
92
- [keyToReplace]: newTranslation,
93
- },
94
- openai,
95
- model: config.model,
96
- });
97
- translationCache[locale] = translation[keyToReplace];
98
- }));
99
- }
100
- // Update the key in all relevant namespaces and locales in parallel
101
- await Promise.all(targetNamespaces.flatMap((namespace) => locales.map(async (locale) => {
102
- const newValue = translationCache[locale];
103
- const existingKeys = await loadLocalesFile(loadPath, locale, namespace);
104
- existingKeys[keyToReplace] = newValue;
105
- await writeLocalesFile(savePath, locale, namespace, existingKeys);
106
- console.log(`Updated "${keyToReplace}" in ${locale} (${namespace}): "${newValue}"`);
107
- })));
120
+ await replaceTranslationValue({
121
+ config,
122
+ key: keyToReplace,
123
+ value: newTranslation,
124
+ targetNamespaces,
125
+ });
126
+ console.log(`Updated "${keyToReplace}" in ${targetNamespaces.length} namespace(s) and ${locales.length} locale(s).`);
108
127
  };
109
128
  //# sourceMappingURL=replace.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"replace.js","sourceR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AAA;IAEF,OAAO,CAAC,GAAG,CACT,YAAY,YAAY,QAAQ,gBAAgB,CAAC,MAAM,qBAAqB,OAAO,CAAC,MAAM,aAAa,CACxG,CAAA;AACH,CAAC,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"scan.d.ts","sourceRoot":"","sources":["../../src/commands/scan.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAYpD,eAAO,MAAM,gBAAgB,GAAU,QAAQ,aAAa,kBAkJ3D,CAAA"}
1
+ {"version":3,"file":"scan.d.ts","sourceRoot":"","sources":["../../src/commands/scan.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAcpD,eAAO,MAAM,gBAAgB,GAAU,QAAQ,aAAa,kBAsK3D,CAAA"}