cc-translate 1.3.0 → 1.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +128 -10
- package/index.d.ts +5 -4
- package/index.js +417 -119
- package/lib/cache/index.d.ts +9 -3
- package/lib/cache/index.d.ts.map +1 -1
- package/lib/cache/index.js +87 -4
- package/lib/log/index.d.ts +1 -1
- package/lib/log/index.d.ts.map +1 -1
- package/lib/support.d.ts +1 -1
- package/lib/support.d.ts.map +1 -1
- package/lib/translation-format.d.ts +5 -0
- package/lib/translation-format.d.ts.map +1 -0
- package/lib/translation-format.js +31 -0
- package/lib/translation-metadata.d.ts +12 -0
- package/lib/translation-metadata.d.ts.map +1 -0
- package/lib/translation-metadata.js +94 -0
- package/lib/translation-reference.d.ts +4 -2
- package/lib/translation-reference.d.ts.map +1 -1
- package/lib/translation-reference.js +52 -35
- package/lib/translation-response.d.ts +9 -0
- package/lib/translation-response.d.ts.map +1 -0
- package/lib/translation-response.js +169 -0
- package/lib/utils.d.ts +1 -1
- package/lib/utils.d.ts.map +1 -1
- package/package.json +3 -2
- package/types/index.d.ts +46 -10
- package/types/index.d.ts.map +1 -1
- package/CHANGELOG.md +0 -41
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import { detectAll } from "tinyld";
|
|
2
|
+
import { splitTranslationText } from "./translation-format.js";
|
|
3
|
+
const codeFence = /^\x60{3}(?:json|text|plaintext)?[ \t]*\r?\n([\s\S]*?)\r?\n\x60{3}$/i;
|
|
4
|
+
const structuredPrefix = /^\{\s*["'}]|^\[\s*["{\[\]]/;
|
|
5
|
+
const responseLabel = /(?:^|\r?\n)\s*(?:\*{1,2})?(?:source|target|translation|translated text)(?:\*{1,2})?\s*:/i;
|
|
6
|
+
const responsePreamble = /(?:^|\r?\n)\s*(?:\*{1,2})?(?:(?:here (?:is|are)|here['’]s)\b[^:\r\n]*\b(?:translation|translated text)(?:\s+(?:in|to|of)\s+[^:\r\n]+)?|the(?: [a-z-]+){0,4} translation is(?: as follows)?)(?:\*{1,2})?\s*:/i;
|
|
7
|
+
const inlineEnvelope = /(?:\{|,)\s*"(?:source|target|translation)"\s*:/i;
|
|
8
|
+
export function readTranslationResponse(content, source) {
|
|
9
|
+
let text = content === null || content === void 0 ? void 0 : content.trim();
|
|
10
|
+
if (!text)
|
|
11
|
+
throw new Error("No translation returned");
|
|
12
|
+
const fenced = codeFence.exec(text);
|
|
13
|
+
if (fenced)
|
|
14
|
+
text = fenced[1].trim();
|
|
15
|
+
if (/^[{[\"]/.test(text)) {
|
|
16
|
+
let parsed;
|
|
17
|
+
try {
|
|
18
|
+
parsed = JSON.parse(text);
|
|
19
|
+
}
|
|
20
|
+
catch (_a) {
|
|
21
|
+
if (structuredPrefix.test(text)) {
|
|
22
|
+
throw new Error("Malformed structured translation response");
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
if (typeof parsed === "string") {
|
|
26
|
+
text = parsed.trim();
|
|
27
|
+
}
|
|
28
|
+
else if (parsed && typeof parsed === "object") {
|
|
29
|
+
const { target, translation } = parsed;
|
|
30
|
+
const value = target !== null && target !== void 0 ? target : translation;
|
|
31
|
+
if (typeof value !== "string" ||
|
|
32
|
+
(target != null && translation != null && target !== translation)) {
|
|
33
|
+
throw new Error("Structured response must contain one unambiguous translation");
|
|
34
|
+
}
|
|
35
|
+
text = value.trim();
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
// 识别响应包装时,保留原文中本来就有的内嵌 JSON 示例和文案标签。
|
|
39
|
+
if (!text ||
|
|
40
|
+
text.startsWith("\x60\x60\x60") ||
|
|
41
|
+
text.endsWith("\x60\x60\x60") ||
|
|
42
|
+
structuredPrefix.test(text) ||
|
|
43
|
+
(inlineEnvelope.test(text) && !inlineEnvelope.test(source)) ||
|
|
44
|
+
(responseLabel.test(text) && !responseLabel.test(source)) ||
|
|
45
|
+
(responsePreamble.test(text) && !responsePreamble.test(source))) {
|
|
46
|
+
throw new Error("Expected only the translated text");
|
|
47
|
+
}
|
|
48
|
+
return text;
|
|
49
|
+
}
|
|
50
|
+
const latin = /\p{Script_Extensions=Latin}/u;
|
|
51
|
+
const arabic = /\p{Script_Extensions=Arabic}/u;
|
|
52
|
+
const han = /\p{Script_Extensions=Han}/u;
|
|
53
|
+
const cyrillic = /\p{Script_Extensions=Cyrillic}/u;
|
|
54
|
+
const devanagari = /\p{Script_Extensions=Devanagari}/u;
|
|
55
|
+
const languageScripts = {
|
|
56
|
+
ar: arabic,
|
|
57
|
+
fa: arabic,
|
|
58
|
+
"ur-PK": arabic,
|
|
59
|
+
"zh-CN": han,
|
|
60
|
+
"zh-TW": han,
|
|
61
|
+
ja: /[\p{Script_Extensions=Han}\p{Script_Extensions=Hiragana}\p{Script_Extensions=Katakana}]/u,
|
|
62
|
+
ko: /[\p{Script_Extensions=Hangul}\p{Script_Extensions=Han}]/u,
|
|
63
|
+
ru: cyrillic,
|
|
64
|
+
uk: cyrillic,
|
|
65
|
+
hi: devanagari,
|
|
66
|
+
"ne-NP": devanagari,
|
|
67
|
+
bn: /\p{Script_Extensions=Bengali}/u,
|
|
68
|
+
my: /\p{Script_Extensions=Myanmar}/u,
|
|
69
|
+
"th-TH": /\p{Script_Extensions=Thai}/u,
|
|
70
|
+
};
|
|
71
|
+
const notation = /(?<!\p{L})(?:[ΔδπΩΣσλθ]|[µμ](?:m|s|g|A|F|L|V|W|mol))(?!\p{L})/gu;
|
|
72
|
+
const sentences = /[^.!?。!?\r\n]+/gu;
|
|
73
|
+
const stripNotation = (text) => text.replace(notation, (value) => " ".repeat(value.length));
|
|
74
|
+
const visibleText = (text) => splitTranslationText(text)
|
|
75
|
+
.map((segment) => segment.placeholder ? " ".repeat(segment.text.length) : segment.text)
|
|
76
|
+
.join("");
|
|
77
|
+
const comparableText = (text) => visibleText(text).normalize("NFKC").toLowerCase().replace(/[\p{P}\p{S}\s]/gu, "");
|
|
78
|
+
const detectConfidentLanguage = (text) => {
|
|
79
|
+
var _a, _b;
|
|
80
|
+
const words = (_a = text.match(/\p{L}+/gu)) !== null && _a !== void 0 ? _a : [];
|
|
81
|
+
// 短词和品牌名可能跨语言共用,只在文案足够长且识别结果明显时拦截。
|
|
82
|
+
if (words.length < 3 || words.join("").length < 16)
|
|
83
|
+
return;
|
|
84
|
+
const [first, second] = detectAll(text);
|
|
85
|
+
if (!first)
|
|
86
|
+
return;
|
|
87
|
+
const runnerUp = (_b = second === null || second === void 0 ? void 0 : second.accuracy) !== null && _b !== void 0 ? _b : 0;
|
|
88
|
+
if (first.accuracy >= 0.65 && first.accuracy - runnerUp >= 0.25)
|
|
89
|
+
return first.lang;
|
|
90
|
+
// 对完整长句,再参考候选语言之间的相对差距,避免漏放低原始分但明显领先的文案。
|
|
91
|
+
if (words.length >= 6 && first.accuracy >= 0.04 && first.accuracy >= 2 * runnerUp)
|
|
92
|
+
return first.lang;
|
|
93
|
+
};
|
|
94
|
+
const foreignRanges = (text) => {
|
|
95
|
+
var _a;
|
|
96
|
+
const ranges = [];
|
|
97
|
+
const plain = stripNotation(text);
|
|
98
|
+
for (const match of plain.matchAll(sentences)) {
|
|
99
|
+
const sentence = match[0];
|
|
100
|
+
const letters = (_a = sentence.match(/\p{L}/gu)) !== null && _a !== void 0 ? _a : [];
|
|
101
|
+
if (letters.some((letter) => !latin.test(letter))) {
|
|
102
|
+
for (const letter of sentence.matchAll(/\p{L}\p{M}*/gu)) {
|
|
103
|
+
if (latin.test(letter[0]))
|
|
104
|
+
continue;
|
|
105
|
+
const start = match.index + letter.index;
|
|
106
|
+
const end = start + letter[0].length;
|
|
107
|
+
const previous = ranges[ranges.length - 1];
|
|
108
|
+
if (previous && /^\s*$/u.test(plain.slice(previous.end, start)))
|
|
109
|
+
previous.end = end;
|
|
110
|
+
else
|
|
111
|
+
ranges.push({ start, end });
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
const detected = detectConfidentLanguage(sentence);
|
|
116
|
+
if (detected && detected !== "en") {
|
|
117
|
+
ranges.push({
|
|
118
|
+
start: match.index + sentence.length - sentence.trimStart().length,
|
|
119
|
+
end: match.index + sentence.trimEnd().length,
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
return ranges;
|
|
125
|
+
};
|
|
126
|
+
export const englishSourceLiterals = (text) => [
|
|
127
|
+
...foreignRanges(text),
|
|
128
|
+
...Array.from(text.matchAll(notation), (match) => ({
|
|
129
|
+
start: match.index, end: match.index + match[0].length,
|
|
130
|
+
})),
|
|
131
|
+
];
|
|
132
|
+
export function isNonEnglishSource(source) {
|
|
133
|
+
const text = stripNotation(visibleText(source));
|
|
134
|
+
const ranges = foreignRanges(text);
|
|
135
|
+
if (!ranges.length)
|
|
136
|
+
return false;
|
|
137
|
+
const remainder = text.split("");
|
|
138
|
+
for (const { start, end } of ranges)
|
|
139
|
+
remainder.fill(" ", start, end);
|
|
140
|
+
return !/\p{L}/u.test(remainder.join(""));
|
|
141
|
+
}
|
|
142
|
+
export function hasUnexpectedTranslationLanguage(translation, source, targetLanguage, references) {
|
|
143
|
+
var _a, _b, _c;
|
|
144
|
+
const visible = stripNotation(visibleText(translation));
|
|
145
|
+
const letters = (_a = visible.match(/\p{L}/gu)) !== null && _a !== void 0 ? _a : [];
|
|
146
|
+
if (!letters.length)
|
|
147
|
+
return false;
|
|
148
|
+
const normalized = comparableText(translation);
|
|
149
|
+
if (normalized === comparableText(source.value))
|
|
150
|
+
return false;
|
|
151
|
+
const acceptedLanguages = [source.language.split("-")[0], targetLanguage.split("-")[0]];
|
|
152
|
+
// 不同语言可能共用同一种文字。除了检查文字,还要拦截原样返回的其他语言参考。
|
|
153
|
+
if (references.some(({ language, value }) => !acceptedLanguages.includes(language.split("-")[0]) && comparableText(value) === normalized))
|
|
154
|
+
return true;
|
|
155
|
+
const sourceScript = (_b = languageScripts[source.language]) !== null && _b !== void 0 ? _b : latin;
|
|
156
|
+
const targetScript = (_c = languageScripts[targetLanguage]) !== null && _c !== void 0 ? _c : latin;
|
|
157
|
+
if (letters.some((letter) => !sourceScript.test(letter) && !targetScript.test(letter)))
|
|
158
|
+
return true;
|
|
159
|
+
for (const [sentence] of visible.matchAll(sentences)) {
|
|
160
|
+
const detected = detectConfidentLanguage(sentence);
|
|
161
|
+
if (!detected || acceptedLanguages.includes(detected))
|
|
162
|
+
continue;
|
|
163
|
+
// 这些语种容易被识别器混淆。文字系统相容时,不能仅凭此结果拒绝合法译文。
|
|
164
|
+
const confusable = [["ms", "id"], ["ne", "hi"]].some((group) => group.includes(detected) && acceptedLanguages.some((language) => group.includes(language)));
|
|
165
|
+
if (!confusable)
|
|
166
|
+
return true;
|
|
167
|
+
}
|
|
168
|
+
return false;
|
|
169
|
+
}
|
package/lib/utils.d.ts
CHANGED
package/lib/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/lib/utils.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,qBAAqB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/lib/utils.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAE/D;;;GAGG;AACH,eAAO,MAAM,qBAAqB,SAAU,MAAM,SAGjD,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,SAAgB,MAAM,iBAUlD,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,cAAc,WAAY,qBAAqB,SAS3D,CAAC;AAEF,eAAO,MAAM,eAAe,QAAS,MAAM,OAAO,MAAM,WAEvD,CAAC;AAEF,eAAO,MAAM,KAAK,OAAQ,MAAM,kBACyB,CAAC;AAE1D,eAAO,MAAM,eAAe,SAAU,MAAM,YAG3C,CAAC;AAEF,eAAO,MAAM,iBAAiB,YAAa,MAAM,aAKhD,CAAC;AAEF,wBAAgB,UAAU,CAAC,CAAC,SAAS,MAAM,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,SAAS,EAAE,MAAM,SASzE;AAED,wBAAgB,YAAY,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,GAAG,CAAC,EAAE,CAczD;AAGD,MAAM,MAAM,UAAU,CAAC,CAAC,IACpB;IAAE,MAAM,EAAE,WAAW,CAAC;IAAC,KAAK,EAAE,CAAC,CAAA;CAAE,GACjC;IAAE,MAAM,EAAE,UAAU,CAAC;IAAC,MAAM,EAAE,GAAG,CAAA;CAAE,CAAC;AAExC;;;;GAIG;AACH,wBAAsB,uBAAuB,CAAC,CAAC;AAC7C,sCAAsC;AACtC,KAAK,EAAE,CAAC,MAAM,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE;AAC3B,gBAAgB;AAChB,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC,CA2B1B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cc-translate",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.3",
|
|
4
4
|
"description": "A language translation tool based on OpenAI",
|
|
5
5
|
"author": "maybe",
|
|
6
6
|
"license": "ISC",
|
|
@@ -50,7 +50,8 @@
|
|
|
50
50
|
"dependencies": {
|
|
51
51
|
"ansi-colors": "^4.1.3",
|
|
52
52
|
"cli-progress": "^3.12.0",
|
|
53
|
-
"openai": "^4.68.1"
|
|
53
|
+
"openai": "^4.68.1",
|
|
54
|
+
"tinyld": "^1.3.4"
|
|
54
55
|
},
|
|
55
56
|
"devDependencies": {
|
|
56
57
|
"@types/cli-progress": "^3.11.6",
|
package/types/index.d.ts
CHANGED
|
@@ -28,18 +28,52 @@ export interface IOutputLanguageFile {
|
|
|
28
28
|
fileName: string;
|
|
29
29
|
jsonMap: IJson;
|
|
30
30
|
blockedKeys?: ReadonlySet<string>;
|
|
31
|
+
rejectedReferences?: IJson;
|
|
32
|
+
usedReferenceId?: string;
|
|
31
33
|
}
|
|
32
34
|
export interface IRegisterLanguageCacheFile {
|
|
33
35
|
folderName: string;
|
|
34
36
|
fileName: string;
|
|
35
37
|
language: SupportLanguageType;
|
|
36
38
|
jsonMap: IJson;
|
|
39
|
+
rejectedReferences?: IJson;
|
|
40
|
+
usedReferenceId?: string;
|
|
37
41
|
/** await translate file path */
|
|
38
42
|
sourceFilePath: string;
|
|
39
43
|
}
|
|
40
44
|
export interface IJson {
|
|
41
45
|
[key: string]: string;
|
|
42
46
|
}
|
|
47
|
+
export type ReferenceSnapshot = Record<string, string>;
|
|
48
|
+
export type MissingReferenceIds = Record<string, string[]>;
|
|
49
|
+
export type SourceCache = Record<string, string | {
|
|
50
|
+
rejectedReferences?: IJson;
|
|
51
|
+
missingReferenceIds?: MissingReferenceIds;
|
|
52
|
+
}>;
|
|
53
|
+
export interface ReferenceCacheState {
|
|
54
|
+
filePath: string;
|
|
55
|
+
rejectedReferences: IJson;
|
|
56
|
+
observed: Map<string, ReferenceSnapshot>;
|
|
57
|
+
current: ReadonlyMap<string, ReferenceSnapshot>;
|
|
58
|
+
changed: Map<string, {
|
|
59
|
+
identity: string;
|
|
60
|
+
value: string;
|
|
61
|
+
}>;
|
|
62
|
+
}
|
|
63
|
+
export interface FileTranslationMetadata {
|
|
64
|
+
context?: string;
|
|
65
|
+
noTranslate?: readonly string[];
|
|
66
|
+
}
|
|
67
|
+
export interface TranslationReference {
|
|
68
|
+
language: SupportLanguageType;
|
|
69
|
+
value: string;
|
|
70
|
+
}
|
|
71
|
+
interface FileTranslationReference {
|
|
72
|
+
language: SupportLanguageType;
|
|
73
|
+
matches: ReadonlyMap<string, {
|
|
74
|
+
translation: string;
|
|
75
|
+
}>;
|
|
76
|
+
}
|
|
43
77
|
export interface ISingleTranslate {
|
|
44
78
|
language: SupportLanguageType;
|
|
45
79
|
fileName: string;
|
|
@@ -47,13 +81,11 @@ export interface ISingleTranslate {
|
|
|
47
81
|
multiBar?: MultiBar;
|
|
48
82
|
progressBar?: SingleBar;
|
|
49
83
|
callback?: () => void;
|
|
50
|
-
reference?:
|
|
51
|
-
language: SupportLanguageType;
|
|
52
|
-
matches: ReadonlyMap<string, {
|
|
53
|
-
translation: string;
|
|
54
|
-
}>;
|
|
55
|
-
};
|
|
84
|
+
reference?: FileTranslationReference;
|
|
56
85
|
blockedKeys?: ReadonlySet<string>;
|
|
86
|
+
conflictingKeys?: ReadonlySet<string>;
|
|
87
|
+
metadata?: FileTranslationMetadata;
|
|
88
|
+
referenceCache?: ReferenceCacheState;
|
|
57
89
|
}
|
|
58
90
|
export interface ITranslateChat {
|
|
59
91
|
key: string;
|
|
@@ -61,15 +93,16 @@ export interface ITranslateChat {
|
|
|
61
93
|
language: SupportLanguageType;
|
|
62
94
|
index: number;
|
|
63
95
|
fileName: string;
|
|
64
|
-
reference?:
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
96
|
+
reference?: TranslationReference;
|
|
97
|
+
metadata?: FileTranslationMetadata;
|
|
98
|
+
changedReference?: string;
|
|
99
|
+
sourceOnly?: boolean;
|
|
68
100
|
}
|
|
69
101
|
export interface ITranslateChatResponse {
|
|
70
102
|
key: string;
|
|
71
103
|
value: string;
|
|
72
104
|
index: number;
|
|
105
|
+
usedSourceFallback?: boolean;
|
|
73
106
|
error?: Error;
|
|
74
107
|
}
|
|
75
108
|
export interface II18nTranslateAgentParams {
|
|
@@ -92,6 +125,8 @@ export interface II18nTranslateAgentParams {
|
|
|
92
125
|
concurrency?: number;
|
|
93
126
|
/** 微调模型 */
|
|
94
127
|
fineTune?: string[];
|
|
128
|
+
/** 全局保护词语 */
|
|
129
|
+
noTranslate?: readonly string[];
|
|
95
130
|
/** 翻译任务最大重试次数 */
|
|
96
131
|
maxTaskRetries?: number;
|
|
97
132
|
/** 翻译任务重试间隔时间(毫秒) */
|
|
@@ -117,4 +152,5 @@ export interface ICacheFile {
|
|
|
117
152
|
filePath: string;
|
|
118
153
|
data: Record<string, string>;
|
|
119
154
|
}
|
|
155
|
+
export {};
|
|
120
156
|
//# sourceMappingURL=index.d.ts.map
|
package/types/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACnD,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,WAAW,SAAS;IACxB,KAAK,EAAE,KAAK,CAAC;CACd;AAED,MAAM,WAAW,kBAAmB,SAAQ,SAAS;IACnD,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,mBAAmB,CAAC;IAC9B,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,qBAAqB;IACpC,QAAQ,EAAE,mBAAmB,CAAC;IAC9B,QAA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AC1B;AAED,MAAM,WAAW,wBAAwB;IACvC,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,eAAe,EAAE,MAAM,CAAC;IACxB,aAAa,EAAE,MAAM,CAAC;IACtB,eAAe;IACf,SAAS,CAAC,EAAE,mBAAmB,EAAE,CAAC;CACnC;AAED,MAAM,WAAW,UAAU;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC9B"}
|
package/CHANGELOG.md
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
# Changelog
|
|
2
|
-
|
|
3
|
-
All notable changes to this project will be documented in this file.
|
|
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
|
-
|
|
23
|
-
## [1.0.0] - 2026-03-04
|
|
24
|
-
|
|
25
|
-
### Changed
|
|
26
|
-
- Refactored translator core from `CwalletTranslate` to `I18nTranslateAgent`.
|
|
27
|
-
- Reworked OpenAI configuration to use `openaiClientConfig` and `chatCompletionCreateParams`.
|
|
28
|
-
- Updated translation logs to clearer English output and added task-level summary counters.
|
|
29
|
-
- Optimized `No content to translate` logging: switched from per-item spam to one aggregated summary line.
|
|
30
|
-
- Standardized package metadata in `package.json` (`main` / `module` / `types` / `exports` / `files` / `engines` / `sideEffects` / `bugs` / `homepage`).
|
|
31
|
-
- Updated publish scripts to `compile`, `prepublishOnly`, and `release`.
|
|
32
|
-
|
|
33
|
-
### Added
|
|
34
|
-
- Added retry support in concurrency queue with incremental backoff (`runWithConcurrencyLimit`).
|
|
35
|
-
- Added settled-style task results (`fulfilled` / `rejected`) for better post-run reporting.
|
|
36
|
-
- Added `test.js` entry for test flow.
|
|
37
|
-
|
|
38
|
-
### Fixed
|
|
39
|
-
- Fixed npm `bugs` URL to repository issue tracker.
|
|
40
|
-
- Fixed package export/type consistency with built output (`index.js` + `index.d.ts`).
|
|
41
|
-
- Moved `ts-node` to `devDependencies` to avoid unnecessary runtime dependency.
|