cc-translate 1.2.2 → 1.3.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/CHANGELOG.md CHANGED
@@ -2,6 +2,24 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
+ ## [Unreleased]
6
+
7
+ ### Added
8
+
9
+ - Added the optional `TranslationReferencePlugin` for using a reviewed locale
10
+ as context for pending translations. It matches by filename and JSON key,
11
+ with translation eligibility determined by the existing cache.
12
+ - Added a reference coverage preview before translation. Missing files or
13
+ entries require terminal confirmation to continue with source-only
14
+ translation for those entries. Invalid reference directories and malformed
15
+ matching files stop the run.
16
+ - Added an opt-in conflict check shared across target languages
17
+ (`checkConflicts: true`). By default, translation uses the source and
18
+ matched reference directly. When enabled, conflicts and checks that fail
19
+ after retries are logged separately once per filename and key. Skipped entries
20
+ keep their existing translations and cache state. The reference locale is
21
+ read-only.
22
+
5
23
  ## [1.0.0] - 2026-03-04
6
24
 
7
25
  ### Changed
package/README.md CHANGED
@@ -6,6 +6,7 @@ An AI-powered i18n translation tool for JSON language files.
6
6
 
7
7
  - Translate from one source language to multiple target languages.
8
8
  - Cache-based incremental translation (only changed keys are translated).
9
+ - Use a reviewed locale as optional context for ambiguous UI copy.
9
10
  - Concurrency queue with retry support for unstable API calls.
10
11
  - Real-time progress bars and final success/failure summary.
11
12
  - Cleaner logs for skipped files (`No content to translate` is aggregated).
@@ -53,6 +54,45 @@ const agent = new I18nTranslateAgent({
53
54
  await agent.translate();
54
55
  ```
55
56
 
57
+ ## Optional Translation Reference
58
+
59
+ Use a reviewed locale as context for ambiguous UI copy. Initialize the plugin
60
+ with the reference language code and the directory containing its JSON files,
61
+ then pass it to the translation entry point.
62
+
63
+ ```ts
64
+ import { TranslationReferencePlugin } from "cc-translate";
65
+
66
+ const reference = new TranslationReferencePlugin({
67
+ language: "zh-CN",
68
+ directory: "./locales/zh-CN",
69
+ // checkConflicts: true, // Enable a separate conflict check.
70
+ });
71
+
72
+ await agent.translate(reference);
73
+ ```
74
+
75
+ The existing cache determines which entries need translation. Enabling the
76
+ plugin or editing the reference locale alone leaves cached translations intact.
77
+ Before any model calls, the plugin reports the reference language, directory,
78
+ file matches, and coverage of pending keys.
79
+
80
+ - When every pending entry has a non-empty reference, translation starts automatically.
81
+ - Missing files or entries trigger a terminal prompt. If you confirm, unmatched
82
+ entries use the source text alone. Declining or running without an interactive
83
+ terminal ends the run before translation.
84
+ - A missing or unreadable reference directory, or an invalid matching JSON
85
+ file, stops the run with an error that identifies the path.
86
+
87
+ The reference locale is read-only and its language is excluded from the output
88
+ targets. By default, the translation request includes both the source text and
89
+ its matched reference. Set `checkConflicts: true` to run a separate check before
90
+ translation. Each matched entry then gets one check shared by all targets.
91
+ Clear conflicts and checks that still fail after retries receive distinct
92
+ entries in `error.log`, once per filename and key. The affected keys are skipped
93
+ across all targets, preserving existing translations and leaving their cache
94
+ entries unchanged for the next run.
95
+
56
96
  ## Directory Layout
57
97
 
58
98
  ```text
@@ -103,4 +143,4 @@ See `CHANGELOG.md`.
103
143
 
104
144
  ## License
105
145
 
106
- ISC
146
+ ISC
package/index.d.ts CHANGED
@@ -1,7 +1,10 @@
1
1
  import { ClientOptions, OpenAI } from "openai";
2
2
  import { II18nTranslateAgentParams, IJson, IOutputLanguageFile, ISingleTranslate, ITranslateChat, ITranslateChatResponse, SupportLanguageType } from "./types";
3
+ import { TranslationReferencePlugin } from "./lib/translation-reference.js";
3
4
  import { ChatCompletionCreateParams } from "openai/resources";
4
5
  export { generateCache, deleteBatchCache } from "./lib/cache/index.js";
6
+ export { TranslationReferencePlugin };
7
+ export type { TranslationReferenceOptions } from "./lib/translation-reference.js";
5
8
  export declare class I18nTranslateAgent {
6
9
  /** 缓存文件根路径 */
7
10
  CACHE_ROOT_PATH: string;
@@ -39,7 +42,8 @@ export declare class I18nTranslateAgent {
39
42
  /**
40
43
  * 翻译入口文件的所有支持的语言文件夹和其中的文件
41
44
  */
42
- translate: () => Promise<void>;
45
+ translate: (referencePlugin?: TranslationReferencePlugin) => Promise<void>;
46
+ private reviewReferences;
43
47
  /**
44
48
  * 翻译单个文件
45
49
  * @param params
@@ -61,7 +65,7 @@ export declare class I18nTranslateAgent {
61
65
  * @param fileName
62
66
  * @returns
63
67
  */
64
- getTranslateContent: (language: SupportLanguageType, fileName: string) => Promise<IJson | undefined>;
68
+ getTranslateContent: (language: SupportLanguageType, fileName: string, deferredEmptyFiles?: IOutputLanguageFile[]) => Promise<IJson | undefined>;
65
69
  /**
66
70
  * 输出语言文件
67
71
  * @param {Object} jsonMap
package/index.js CHANGED
@@ -16,7 +16,9 @@ import { getRandomNumber, notExistsToCreateFile, readFileOfDirSync, readJsonFile
16
16
  import { getCacheFileSync, registerLanguageCacheFile, translateJSONDiffToJson, } from "./lib/cache/index.js";
17
17
  import { logErrorToFile } from "./lib/log/index.js";
18
18
  import { SUPPORT_LANGUAGE_MAP } from "./lib/support.js";
19
+ import { TranslationReferencePlugin } from "./lib/translation-reference.js";
19
20
  export { generateCache, deleteBatchCache } from "./lib/cache/index.js";
21
+ export { TranslationReferencePlugin };
20
22
  const DEFAULT_CHAT_COMPLETION_CREATE_PARAMS = {
21
23
  model: "gpt-4o",
22
24
  };
@@ -37,8 +39,10 @@ export class I18nTranslateAgent {
37
39
  /**
38
40
  * 翻译入口文件的所有支持的语言文件夹和其中的文件
39
41
  */
40
- this.translate = () => __awaiter(this, void 0, void 0, function* () {
41
- fs.writeFileSync("error.log", "", "utf8");
42
+ this.translate = (referencePlugin) => __awaiter(this, void 0, void 0, function* () {
43
+ var _a;
44
+ if (!referencePlugin)
45
+ fs.writeFileSync("error.log", "", "utf8");
42
46
  console.log("🚀 Start translation");
43
47
  console.log(`🚀 Using model: ${this.chatCompletionCreateParams.model} 🚀`);
44
48
  console.log(`🚀 Fine-tuning: ${this.fineTune.join(",")} 🚀`);
@@ -47,66 +51,105 @@ export class I18nTranslateAgent {
47
51
  // 翻译源语言问价夹下的所有json文件
48
52
  const translateFolders = yield readFileOfDirSync(translateFolderPath);
49
53
  console.log("🚀 ~ files to translate:", translateFolders, translateFolderPath);
50
- // 创建进度条
51
- const multiBar = new cliProgress.MultiBar({
52
- clearOnComplete: false,
53
- hideCursor: true,
54
- format: colors.cyan("{bar}") +
55
- "| {percentage}% || {filename} {value}/{total} ",
56
- }, cliProgress.Presets.legacy);
57
- const taskList = [];
54
+ const tasks = [];
58
55
  const skippedNoContent = [];
59
- for (const item of this.supportLanguages) {
60
- // 源语言不翻译
61
- if (item.code === this.SOURCE_LANGUAGE)
62
- continue;
56
+ const emptyFiles = [];
57
+ const targetLanguages = this.supportLanguages.filter(({ code }) => code !== this.SOURCE_LANGUAGE && code !== (referencePlugin === null || referencePlugin === void 0 ? void 0 : referencePlugin.language));
58
+ for (const item of targetLanguages) {
63
59
  for (const fileName of translateFolders) {
64
- const translateJson = yield this.getTranslateContent(item.code, fileName);
60
+ const translateJson = yield this.getTranslateContent(item.code, fileName, referencePlugin ? emptyFiles : undefined);
65
61
  if (!translateJson) {
66
62
  skippedNoContent.push(`${item.code}:${fileName}`);
67
63
  continue;
68
64
  }
69
- taskList.push(() => __awaiter(this, void 0, void 0, function* () {
70
- let attempt = 0;
71
- while (attempt <= this.maxTaskRetries) {
72
- try {
73
- yield this.singleTranslate({
74
- language: item.code,
75
- fileName,
76
- multiBar,
77
- translateJson,
78
- });
79
- attempt = this.maxTaskRetries + 1;
80
- return;
81
- }
82
- catch (error) {
83
- attempt++;
84
- if (attempt > this.maxTaskRetries) {
85
- throw error;
86
- }
87
- const waitMs = this.taskRetryBaseDelayMs * attempt;
88
- console.warn(`${colors.yellow("Task retry")} ${item.code}:${fileName} (${attempt}/${this.maxTaskRetries})`);
89
- yield sleep(waitMs);
90
- }
91
- }
92
- }));
65
+ tasks.push({ language: item.code, fileName, translateJson });
66
+ }
67
+ }
68
+ if (referencePlugin) {
69
+ const writableDirectories = targetLanguages.flatMap(({ code }) => [
70
+ path.join(this.outputPath, code),
71
+ path.join(this.CACHE_ROOT_PATH, code),
72
+ ]);
73
+ const matches = yield referencePlugin.prepare(tasks, writableDirectories);
74
+ if (!matches)
75
+ return;
76
+ fs.writeFileSync("error.log", "", "utf8");
77
+ const blockedByFile = referencePlugin.checkConflicts
78
+ ? yield this.reviewReferences(matches, referencePlugin.language)
79
+ : undefined;
80
+ for (const task of tasks) {
81
+ const fileMatches = matches.get(task.fileName);
82
+ if (fileMatches) {
83
+ task.reference = {
84
+ language: referencePlugin.language,
85
+ matches: fileMatches,
86
+ };
87
+ }
88
+ task.blockedKeys = blockedByFile === null || blockedByFile === void 0 ? void 0 : blockedByFile.get(task.fileName);
89
+ for (const key of (_a = task.blockedKeys) !== null && _a !== void 0 ? _a : []) {
90
+ delete task.translateJson[key];
91
+ }
92
+ }
93
+ for (const emptyFile of emptyFiles) {
94
+ yield this.outputLanguageFile(emptyFile);
93
95
  }
94
96
  }
95
97
  if (skippedNoContent.length > 0) {
96
98
  const summary = skippedNoContent.length <= 5
97
99
  ? skippedNoContent.join(", ")
98
100
  : `${skippedNoContent.slice(0, 3).join(", ")} ... +${skippedNoContent.length - 3} more`;
99
- console.log(`${colors.dim("Skipped (no content to translate):")} ${skippedNoContent.length} items${skippedNoContent.length <= 5 ? ` (${summary})` : ` — e.g. ${summary}`}`);
100
- }
101
- // 并发队列:同时最多 concurrency 个任务,完成一个即从队列取下一个,避免长任务拖慢整批
102
- const results = yield runWithConcurrencyLimit(taskList, this.concurrency);
103
- multiBar.stop();
104
- const errorLength = results.filter((item) => item.status === "rejected").length;
105
- if (errorLength > 0) {
106
- console.log(`${colors.red("Translation failed")}: ${errorLength} tasks`);
101
+ console.log(`Skipped (no content to translate): ${skippedNoContent.length} items${skippedNoContent.length <= 5 ? ` (${summary})` : ` — e.g. ${summary}`}`);
107
102
  }
108
- console.log(`${colors.green("Translation completed")}: ${results.length} tasks`);
109
- console.log(`${colors.green("Translation successful")}: ${results.length - errorLength} tasks`);
103
+ const readyTasks = tasks.filter(({ translateJson }) => Object.keys(translateJson).length > 0);
104
+ const multiBar = process.stderr.isTTY && !process.env.CI && readyTasks.length > 0
105
+ ? new cliProgress.MultiBar({
106
+ clearOnComplete: false,
107
+ hideCursor: true,
108
+ format: colors.cyan("{bar}") +
109
+ "| {percentage}% || {filename} {value}/{total} ",
110
+ }, cliProgress.Presets.legacy)
111
+ : undefined;
112
+ const totalBar = multiBar === null || multiBar === void 0 ? void 0 : multiBar.create(readyTasks.length, 0, {
113
+ filename: "Total tasks finished",
114
+ });
115
+ const warnTask = (message) => {
116
+ if (multiBar)
117
+ multiBar.log(`${message}\n`);
118
+ else
119
+ console.warn(message);
120
+ };
121
+ const taskList = readyTasks.map((task) => () => __awaiter(this, void 0, void 0, function* () {
122
+ const filename = `${task.language}:${task.fileName}`;
123
+ const progressBar = multiBar === null || multiBar === void 0 ? void 0 : multiBar.create(Object.keys(task.translateJson).length, 0, { filename });
124
+ try {
125
+ for (let attempt = 0;; attempt++) {
126
+ try {
127
+ yield this.singleTranslate(Object.assign(Object.assign({}, task), { progressBar }));
128
+ if (!multiBar)
129
+ console.log(`Task successful: ${filename}`);
130
+ return;
131
+ }
132
+ catch (error) {
133
+ if (attempt >= this.maxTaskRetries) {
134
+ warnTask(`Task failed: ${filename}`);
135
+ throw error;
136
+ }
137
+ const retry = attempt + 1;
138
+ warnTask(`Task retry: ${filename} (${retry}/${this.maxTaskRetries})`);
139
+ yield sleep(this.taskRetryBaseDelayMs * retry);
140
+ }
141
+ }
142
+ }
143
+ finally {
144
+ totalBar === null || totalBar === void 0 ? void 0 : totalBar.increment();
145
+ if (progressBar)
146
+ multiBar === null || multiBar === void 0 ? void 0 : multiBar.remove(progressBar);
147
+ }
148
+ }));
149
+ const results = yield runWithConcurrencyLimit(taskList, this.concurrency).finally(() => multiBar === null || multiBar === void 0 ? void 0 : multiBar.stop());
150
+ const failed = results.filter((item) => item.status === "rejected").length;
151
+ const successful = results.filter((item) => item.status === "fulfilled").length;
152
+ console.log(`Translation summary: ${successful} successful, ${failed} failed, ${skippedNoContent.length} skipped`);
110
153
  });
111
154
  /**
112
155
  * 翻译单个文件
@@ -118,28 +161,35 @@ export class I18nTranslateAgent {
118
161
  /** 待翻译的语言 */
119
162
  language,
120
163
  /** 待翻译的文件名 */
121
- fileName, translateJson, multiBar, callback, } = params;
164
+ fileName, translateJson, multiBar, progressBar: taskProgressBar, callback, reference, blockedKeys, } = params;
122
165
  try {
123
166
  // 生成chat循环代码
124
- const promiseList = Object.entries(translateJson).map(([key, value], index) => () => this.translateChat({
125
- key,
126
- value,
127
- language,
128
- index,
129
- fileName,
130
- }));
131
- const progressBar = multiBar.create(promiseList.length, 0);
167
+ const promiseList = Object.entries(translateJson).map(([key, value], index) => () => {
168
+ const match = reference === null || reference === void 0 ? void 0 : reference.matches.get(key);
169
+ return this.translateChat({
170
+ key,
171
+ value,
172
+ language,
173
+ index,
174
+ fileName,
175
+ reference: reference && match
176
+ ? { language: reference.language, value: match.translation }
177
+ : undefined,
178
+ });
179
+ });
180
+ const progressBar = taskProgressBar !== null && taskProgressBar !== void 0 ? taskProgressBar : multiBar === null || multiBar === void 0 ? void 0 : multiBar.create(promiseList.length, 0, {
181
+ filename: `${language}:${fileName}`,
182
+ });
132
183
  for (const fn of promiseList) {
133
184
  const result = yield fn();
134
185
  yield this.outputLanguageFile({
135
186
  jsonMap: { [result.key]: result.value },
136
187
  folderName: language,
137
188
  fileName,
189
+ blockedKeys,
138
190
  });
139
191
  delete translateJson[result.key];
140
- progressBar.update(result.index + 1, {
141
- filename: `${language}:${fileName}`,
142
- });
192
+ progressBar === null || progressBar === void 0 ? void 0 : progressBar.increment();
143
193
  }
144
194
  callback && callback();
145
195
  }
@@ -162,8 +212,8 @@ export class I18nTranslateAgent {
162
212
  * @returns
163
213
  */
164
214
  this.translateChat = (params) => __awaiter(this, void 0, void 0, function* () {
165
- var _a, _b, _c;
166
- const { key, value, language, index, fileName } = params;
215
+ var _a, _b, _c, _d;
216
+ const { key, value, language, index, fileName, reference } = params;
167
217
  try {
168
218
  if (!this.client)
169
219
  throw new Error("Connection failed");
@@ -183,7 +233,10 @@ export class I18nTranslateAgent {
183
233
  })),
184
234
  {
185
235
  role: "system",
186
- content: `Please translate ${originLanguage.name} to ${targetLanguage.name}`,
236
+ content: `Please translate ${originLanguage.name} to ${targetLanguage.name}` +
237
+ (reference
238
+ ? ". Use the reference translation to clarify the meaning of the source text."
239
+ : ""),
187
240
  },
188
241
  {
189
242
  role: "system",
@@ -191,12 +244,22 @@ export class I18nTranslateAgent {
191
244
  },
192
245
  {
193
246
  role: "user",
194
- content: value,
247
+ content: reference
248
+ ? JSON.stringify({
249
+ source: value,
250
+ referenceLanguage: (_c = (_b = SUPPORT_LANGUAGE_MAP[reference.language]) === null || _b === void 0 ? void 0 : _b.name) !== null && _c !== void 0 ? _c : reference.language,
251
+ reference: reference.value,
252
+ })
253
+ : value,
195
254
  },
196
255
  ] }));
256
+ const translation = (_d = chatCompletion === null || chatCompletion === void 0 ? void 0 : chatCompletion.choices[0]) === null || _d === void 0 ? void 0 : _d.message.content;
257
+ if (reference && !(translation === null || translation === void 0 ? void 0 : translation.trim())) {
258
+ throw new Error("No translation returned for referenced entry");
259
+ }
197
260
  return {
198
261
  key,
199
- value: (_c = (_b = chatCompletion === null || chatCompletion === void 0 ? void 0 : chatCompletion.choices[0]) === null || _b === void 0 ? void 0 : _b.message.content) !== null && _c !== void 0 ? _c : value,
262
+ value: translation !== null && translation !== void 0 ? translation : value,
200
263
  index,
201
264
  };
202
265
  }
@@ -216,7 +279,7 @@ export class I18nTranslateAgent {
216
279
  * @param fileName
217
280
  * @returns
218
281
  */
219
- this.getTranslateContent = (language, fileName) => __awaiter(this, void 0, void 0, function* () {
282
+ this.getTranslateContent = (language, fileName, deferredEmptyFiles) => __awaiter(this, void 0, void 0, function* () {
220
283
  const translateFilePath = path.join(this.ENTRY_ROOT_PATH, this.SOURCE_LANGUAGE, fileName);
221
284
  /** 缓存文件路径 */
222
285
  const cacheFilePath = path.join(this.CACHE_ROOT_PATH, language, fileName);
@@ -229,11 +292,15 @@ export class I18nTranslateAgent {
229
292
  const diffObject = translateJSONDiffToJson(cacheObject, translateFileObject);
230
293
  if (Object.values(diffObject).length === 0) {
231
294
  if (Object.keys(translateFileObject).length === 0) {
232
- this.outputLanguageFile({
295
+ const emptyFile = {
233
296
  jsonMap: {},
234
297
  folderName: language,
235
298
  fileName,
236
- });
299
+ };
300
+ if (deferredEmptyFiles)
301
+ deferredEmptyFiles.push(emptyFile);
302
+ else
303
+ yield this.outputLanguageFile(emptyFile);
237
304
  }
238
305
  return;
239
306
  }
@@ -244,7 +311,7 @@ export class I18nTranslateAgent {
244
311
  * @param {Object} jsonMap
245
312
  */
246
313
  this.outputLanguageFile = (params) => __awaiter(this, void 0, void 0, function* () {
247
- const { folderName, fileName, jsonMap } = params;
314
+ const { folderName, fileName, jsonMap, blockedKeys } = params;
248
315
  const outputFilePath = path.join(this.outputPath, folderName, fileName);
249
316
  //创建输出文件夹
250
317
  notExistsToCreateFile(this.outputPath);
@@ -252,13 +319,18 @@ export class I18nTranslateAgent {
252
319
  notExistsToCreateFile(`${this.outputPath}/${folderName}`);
253
320
  let oldJsonData = "";
254
321
  // 检查是否存在文件
255
- if (!fs.existsSync(outputFilePath)) {
322
+ const hasOutputFile = fs.existsSync(outputFilePath);
323
+ if (!hasOutputFile) {
256
324
  oldJsonData = yield fs.readFileSync(path.join(this.ENTRY_ROOT_PATH, this.SOURCE_LANGUAGE, fileName), "utf8");
257
325
  }
258
326
  else {
259
327
  oldJsonData = yield fs.readFileSync(outputFilePath, "utf8");
260
328
  }
261
329
  const oldJsonMap = JSON.parse(oldJsonData);
330
+ if (!hasOutputFile && blockedKeys) {
331
+ for (const key of blockedKeys)
332
+ delete oldJsonMap[key];
333
+ }
262
334
  const newJsonMap = Object.assign(oldJsonMap, jsonMap);
263
335
  yield fs.writeFileSync(path.resolve(outputFilePath), JSON.stringify(newJsonMap, null, 2), "utf8");
264
336
  // 注册缓存
@@ -311,4 +383,100 @@ export class I18nTranslateAgent {
311
383
  searchLanguage(code) {
312
384
  return this.supportLanguages.find((item) => item.code === code);
313
385
  }
386
+ reviewReferences(matches, language) {
387
+ return __awaiter(this, void 0, void 0, function* () {
388
+ var _a, _b, _c, _d, _e;
389
+ const blocked = new Map();
390
+ const sourceLanguage = (_b = (_a = SUPPORT_LANGUAGE_MAP[this.SOURCE_LANGUAGE]) === null || _a === void 0 ? void 0 : _a.name) !== null && _b !== void 0 ? _b : this.SOURCE_LANGUAGE;
391
+ const referenceLanguage = (_d = (_c = SUPPORT_LANGUAGE_MAP[language]) === null || _c === void 0 ? void 0 : _c.name) !== null && _d !== void 0 ? _d : language;
392
+ const timeout = (_e = this.openaiClientConfig.timeout) !== null && _e !== void 0 ? _e : 30000;
393
+ const checks = Array.from(matches).flatMap(([fileName, entries]) => Array.from(entries, ([key, { source, translation }]) => () => __awaiter(this, void 0, void 0, function* () {
394
+ var _a, _b, _c;
395
+ let issue;
396
+ for (let attempt = 0;; attempt++) {
397
+ const deadline = new AbortController();
398
+ const timer = setTimeout(() => deadline.abort(), timeout);
399
+ try {
400
+ if (!this.client)
401
+ throw new Error("Connection failed");
402
+ const response = yield this.client.chat.completions.create({
403
+ model: (_a = this.chatCompletionCreateParams.model) !== null && _a !== void 0 ? _a : "gpt-4o",
404
+ messages: [
405
+ {
406
+ role: "system",
407
+ content: "Compare the source UI text and its reference translation. " +
408
+ "Reply CONFLICT only when they clearly express incompatible product meanings. " +
409
+ "A reference that clarifies an ambiguous source or adds compatible detail is not a conflict. " +
410
+ "Reply COMPATIBLE in all other cases. Output exactly one label.",
411
+ },
412
+ {
413
+ role: "user",
414
+ content: JSON.stringify({
415
+ sourceLanguage,
416
+ source,
417
+ referenceLanguage,
418
+ reference: translation,
419
+ }),
420
+ },
421
+ ],
422
+ }, { signal: deadline.signal, timeout, maxRetries: 0 });
423
+ const verdict = (_c = (_b = response.choices[0]) === null || _b === void 0 ? void 0 : _b.message.content) === null || _c === void 0 ? void 0 : _c.trim();
424
+ if (verdict === "COMPATIBLE")
425
+ return;
426
+ if (verdict !== "CONFLICT")
427
+ throw new Error("Invalid reference verdict");
428
+ issue = new Error("Reference conflict");
429
+ break;
430
+ }
431
+ catch (error) {
432
+ if (attempt >= this.maxTaskRetries) {
433
+ const reason = deadline.signal.aborted
434
+ ? `request timed out after ${timeout} ms`
435
+ : error;
436
+ issue = new Error(`Reference judgment failed: ${reason}`);
437
+ break;
438
+ }
439
+ }
440
+ finally {
441
+ clearTimeout(timer);
442
+ }
443
+ yield sleep(this.taskRetryBaseDelayMs * (attempt + 1));
444
+ }
445
+ let keys = blocked.get(fileName);
446
+ if (!keys) {
447
+ keys = new Set();
448
+ blocked.set(fileName, keys);
449
+ }
450
+ keys.add(key);
451
+ yield logErrorToFile({ error: issue, fileName, key, language });
452
+ })));
453
+ if (checks.length === 0)
454
+ return blocked;
455
+ let completed = 0;
456
+ const reportProgress = () => {
457
+ console.log(`Reference checks: ${completed}/${checks.length} completed`);
458
+ };
459
+ console.log(`Checking ${checks.length} reference entries before translation...`);
460
+ const progressTimer = setInterval(reportProgress, 10000);
461
+ try {
462
+ yield runWithConcurrencyLimit(checks.map((check) => () => __awaiter(this, void 0, void 0, function* () {
463
+ try {
464
+ yield check();
465
+ }
466
+ finally {
467
+ completed++;
468
+ }
469
+ })), this.concurrency);
470
+ }
471
+ finally {
472
+ clearInterval(progressTimer);
473
+ }
474
+ reportProgress();
475
+ const skipped = Array.from(blocked.values()).reduce((count, keys) => count + keys.size, 0);
476
+ if (skipped) {
477
+ console.warn(`Skipped ${skipped} reference entries. See error.log for details.`);
478
+ }
479
+ return blocked;
480
+ });
481
+ }
314
482
  }
@@ -1,3 +1,3 @@
1
1
  import { ITranslateLogError } from "../../types";
2
- export declare function logErrorToFile(params: ITranslateLogError): void;
2
+ export declare function logErrorToFile(params: ITranslateLogError): Promise<void>;
3
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/lib/log/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAGjD,wBAAgB,cAAc,CAAC,MAAM,EAAE,kBAAkB,QASxD"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/lib/log/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAGjD,wBAAgB,cAAc,CAAC,MAAM,EAAE,kBAAkB,iBAWxD"}
package/lib/log/index.js CHANGED
@@ -6,5 +6,7 @@ export function logErrorToFile(params) {
6
6
  \nFileName: ${fileName}
7
7
  \nkey:${key}
8
8
  \nStack: ${error.stack}\n\n`;
9
- fs.appendFile("error.log", logMessage, (err) => { });
9
+ return new Promise((resolve) => {
10
+ fs.appendFile("error.log", logMessage, () => resolve());
11
+ });
10
12
  }
@@ -0,0 +1,20 @@
1
+ import type { ISingleTranslate, SupportLanguageType } from "../types";
2
+ export interface TranslationReferenceOptions {
3
+ language: SupportLanguageType;
4
+ directory: string;
5
+ checkConflicts?: boolean;
6
+ }
7
+ interface ReferenceMatch {
8
+ source: string;
9
+ translation: string;
10
+ }
11
+ export type ReferenceMatches = Map<string, Map<string, ReferenceMatch>>;
12
+ export declare class TranslationReferencePlugin {
13
+ readonly language: SupportLanguageType;
14
+ readonly directory: string;
15
+ readonly checkConflicts: boolean;
16
+ constructor({ language, directory, checkConflicts, }: TranslationReferenceOptions);
17
+ prepare(tasks: readonly Pick<ISingleTranslate, "fileName" | "translateJson">[], writableDirectories: string[]): Promise<ReferenceMatches | undefined>;
18
+ }
19
+ export {};
20
+ //# sourceMappingURL=translation-reference.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"translation-reference.d.ts","sourceRoot":"","sources":["../src/lib/translation-reference.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAEtE,MAAM,WAAW,2BAA2B;IAC1C,QAAQ,EAAE,mBAAmB,CAAC;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED,UAAU,cAAc;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,MAAM,gBAAgB,GAAG,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC,CAAC;AAExE,qBAAa,0BAA0B;IACrC,QAAQ,CAAC,QAAQ,EAAE,mBAAmB,CAAC;IACvC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,cAAc,EAAE,OAAO,CAAC;gBAErB,EACV,QAAQ,EACR,SAAS,EACT,cAAsB,GACvB,EAAE,2BAA2B;IAMxB,OAAO,CACX,KAAK,EAAE,SAAS,IAAI,CAAC,gBAAgB,EAAE,UAAU,GAAG,eAAe,CAAC,EAAE,EACtE,mBAAmB,EAAE,MAAM,EAAE;CAkGhC"}
@@ -0,0 +1,112 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import fs from "fs";
11
+ import path from "path";
12
+ import { createInterface } from "node:readline";
13
+ export class TranslationReferencePlugin {
14
+ constructor({ language, directory, checkConflicts = false, }) {
15
+ this.language = language;
16
+ this.directory = path.resolve(directory);
17
+ this.checkConflicts = checkConflicts;
18
+ }
19
+ prepare(tasks, writableDirectories) {
20
+ return __awaiter(this, void 0, void 0, function* () {
21
+ var _a;
22
+ let fileNames;
23
+ let referenceDirectory;
24
+ try {
25
+ fileNames = new Set(fs.readdirSync(this.directory));
26
+ referenceDirectory = fs.realpathSync(this.directory);
27
+ }
28
+ catch (error) {
29
+ throw new Error(`Cannot read reference directory ${this.directory}: ${error}`);
30
+ }
31
+ for (const directory of writableDirectories) {
32
+ if (fs.existsSync(directory) &&
33
+ fs.realpathSync(directory) === referenceDirectory) {
34
+ throw new Error(`Reference directory is read-only for translation: ${this.directory}`);
35
+ }
36
+ }
37
+ const pending = new Map();
38
+ for (const { fileName, translateJson } of tasks) {
39
+ let entries = pending.get(fileName);
40
+ if (!entries) {
41
+ entries = new Map();
42
+ pending.set(fileName, entries);
43
+ }
44
+ for (const [key, source] of Object.entries(translateJson)) {
45
+ entries.set(key, source);
46
+ }
47
+ }
48
+ const matches = new Map();
49
+ const report = [];
50
+ let hasUnmatched = false;
51
+ for (const [fileName, entries] of pending) {
52
+ if (!fileNames.has(fileName)) {
53
+ report.push(` ${fileName}: missing reference file (0/${entries.size} matched)`);
54
+ hasUnmatched = true;
55
+ continue;
56
+ }
57
+ const referencePath = path.join(this.directory, fileName);
58
+ let reference;
59
+ try {
60
+ const data = JSON.parse(fs.readFileSync(referencePath, "utf8"));
61
+ if (!data || typeof data !== "object" || Array.isArray(data)) {
62
+ throw new Error("Expected a JSON object");
63
+ }
64
+ reference = data;
65
+ }
66
+ catch (error) {
67
+ throw new Error(`Cannot read reference file ${referencePath}: ${error}`);
68
+ }
69
+ const fileMatches = new Map();
70
+ for (const [key, source] of entries) {
71
+ const translation = reference[key];
72
+ if (typeof translation === "string" && translation.trim()) {
73
+ fileMatches.set(key, { source, translation });
74
+ }
75
+ }
76
+ matches.set(fileName, fileMatches);
77
+ const missing = entries.size - fileMatches.size;
78
+ hasUnmatched || (hasUnmatched = missing > 0);
79
+ report.push(` ${fileName}: ${fileMatches.size}/${entries.size} matched` +
80
+ (missing ? ` (${missing} missing non-empty references)` : ""));
81
+ }
82
+ console.log(`Translation reference: ${this.language} (${this.directory})`);
83
+ console.log(report.length ? report.join("\n") : " No pending files to match.");
84
+ if (!hasUnmatched) {
85
+ if (report.length)
86
+ console.log("All pending entries have matching references.");
87
+ return matches;
88
+ }
89
+ console.log("Unmatched entries will be translated without a reference.");
90
+ if (!process.stdin.isTTY || !process.stdout.isTTY || process.env.CI) {
91
+ console.warn("Translation cancelled: confirmation requires an interactive terminal.");
92
+ return;
93
+ }
94
+ const prompt = createInterface({
95
+ input: process.stdin,
96
+ output: process.stdout,
97
+ });
98
+ try {
99
+ const answers = prompt[Symbol.asyncIterator]();
100
+ prompt.setPrompt("Start translation? [y/N] ");
101
+ prompt.prompt();
102
+ const { value } = yield answers.next();
103
+ if (/^y(?:es)?$/i.test((_a = value === null || value === void 0 ? void 0 : value.trim()) !== null && _a !== void 0 ? _a : ""))
104
+ return matches;
105
+ console.log("Translation cancelled.");
106
+ }
107
+ finally {
108
+ prompt.close();
109
+ }
110
+ });
111
+ }
112
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cc-translate",
3
- "version": "1.2.2",
3
+ "version": "1.3.0",
4
4
  "description": "A language translation tool based on OpenAI",
5
5
  "author": "maybe",
6
6
  "license": "ISC",
package/types/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { MultiBar } from "cli-progress";
1
+ import { MultiBar, SingleBar } from "cli-progress";
2
2
  import { ClientOptions } from "openai";
3
3
  import { ChatCompletionCreateParams } from "openai/resources";
4
4
  export interface ILanguage {
@@ -27,6 +27,7 @@ export interface IOutputLanguageFile {
27
27
  folderName: SupportLanguageType;
28
28
  fileName: string;
29
29
  jsonMap: IJson;
30
+ blockedKeys?: ReadonlySet<string>;
30
31
  }
31
32
  export interface IRegisterLanguageCacheFile {
32
33
  folderName: string;
@@ -43,8 +44,16 @@ export interface ISingleTranslate {
43
44
  language: SupportLanguageType;
44
45
  fileName: string;
45
46
  translateJson: IJson;
46
- multiBar: MultiBar;
47
+ multiBar?: MultiBar;
48
+ progressBar?: SingleBar;
47
49
  callback?: () => void;
50
+ reference?: {
51
+ language: SupportLanguageType;
52
+ matches: ReadonlyMap<string, {
53
+ translation: string;
54
+ }>;
55
+ };
56
+ blockedKeys?: ReadonlySet<string>;
48
57
  }
49
58
  export interface ITranslateChat {
50
59
  key: string;
@@ -52,6 +61,10 @@ export interface ITranslateChat {
52
61
  language: SupportLanguageType;
53
62
  index: number;
54
63
  fileName: string;
64
+ reference?: {
65
+ language: SupportLanguageType;
66
+ value: string;
67
+ };
55
68
  }
56
69
  export interface ITranslateChatResponse {
57
70
  key: string;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAe,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAC/C,OAAO,EAAE,0BAA0B,EAAE,MAAM,kBAAkB,CAAC;AAE9D,MAAM,WAAW,SAAS;IACxB,aAAa;IACb,IAAI,EAAE,mBAAmB,CAAC;IAC1B,UAAU;IACV,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,MAAM,mBAAmB,GAC3B,IAAI,GACJ,OAAO,GACP,OAAO,GACP,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,OAAO,GACP,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,OAAO,GACP,IAAI,GACJ,IAAI,GACJ,OAAO,GACP,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,OAAO,GACP,OAAO,CAAC;AAEZ,MAAM,MAAM,kBAAkB,GAAG,OAAO,CACtC,MAAM,CAAC,mBAAmB,EAAE,SAAS,CAAC,CACvC,CAAC;AAEF,MAAM,WAA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