scancscode 1.0.43 → 1.0.47
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/dist/src/CmdExecutor.js +2 -2
- package/dist/src/CsvAutoTranslator.js +117 -50
- package/dist/test/CsvAutoTranslator.test.js +15 -5
- package/package.json +1 -1
- package/src/CmdExecutor.ts +3 -3
- package/src/CsvAutoTranslator.ts +127 -55
- package/test/Auto.csv +3 -12484
- package/test/CsvAutoTranslator.test.ts +19 -8
|
@@ -30,7 +30,7 @@ describe("CsvAutoTranslator", () => {
|
|
|
30
30
|
return;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
const translator = new CsvAutoTranslator(
|
|
33
|
+
const translator = new CsvAutoTranslator(appId, apiKey);
|
|
34
34
|
const rows = JSON.parse(JSON.stringify(testRows));
|
|
35
35
|
const translatedCount = await translator.translateCsvRows(rows, "zh_cn");
|
|
36
36
|
|
|
@@ -53,7 +53,7 @@ describe("CsvAutoTranslator", () => {
|
|
|
53
53
|
return;
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
const translator = new CsvAutoTranslator(
|
|
56
|
+
const translator = new CsvAutoTranslator(appId, apiKey);
|
|
57
57
|
const rows = JSON.parse(JSON.stringify(testRows));
|
|
58
58
|
rows[1][2] = "已有译文";
|
|
59
59
|
const translatedCount = await translator.translateCsvRows(rows, "zh_cn");
|
|
@@ -63,13 +63,13 @@ describe("CsvAutoTranslator", () => {
|
|
|
63
63
|
}, 120000);
|
|
64
64
|
|
|
65
65
|
test("translateCsvRows - 空CSV测试", async () => {
|
|
66
|
-
const translator = new CsvAutoTranslator(
|
|
66
|
+
const translator = new CsvAutoTranslator(NIUTRANS_APP_ID, NIUTRANS_API_KEY);
|
|
67
67
|
const translatedCount = await translator.translateCsvRows([], "zh_cn");
|
|
68
68
|
expect(translatedCount).toBe(0);
|
|
69
69
|
});
|
|
70
70
|
|
|
71
71
|
test("translateCsvRows - 没有需要翻译的内容", async () => {
|
|
72
|
-
const translator = new CsvAutoTranslator(
|
|
72
|
+
const translator = new CsvAutoTranslator(NIUTRANS_APP_ID, NIUTRANS_API_KEY);
|
|
73
73
|
const rows = [
|
|
74
74
|
["key", "en_us", "zh_hk"],
|
|
75
75
|
["Hello", "", "已有译文1"],
|
|
@@ -80,7 +80,7 @@ describe("CsvAutoTranslator", () => {
|
|
|
80
80
|
});
|
|
81
81
|
|
|
82
82
|
describe("smartBatch - 边界回归测试", () => {
|
|
83
|
-
const translator = new CsvAutoTranslator(
|
|
83
|
+
const translator = new CsvAutoTranslator(NIUTRANS_APP_ID, NIUTRANS_API_KEY);
|
|
84
84
|
|
|
85
85
|
test("空文本数组", () => {
|
|
86
86
|
const batches = translator.smartBatch([]);
|
|
@@ -169,12 +169,12 @@ describe("CsvAutoTranslator", () => {
|
|
|
169
169
|
|
|
170
170
|
test("翻译 Auto.csv 并验证输出", async () => {
|
|
171
171
|
await translator.translateCsv(inputFile, outputFile, "zh_cn");
|
|
172
|
-
|
|
172
|
+
|
|
173
173
|
const csvUtils = new CSVUtils(outputFile);
|
|
174
174
|
const rows = await csvUtils.parseCsv();
|
|
175
|
-
|
|
175
|
+
|
|
176
176
|
expect(rows.length).toBeGreaterThan(1);
|
|
177
|
-
|
|
177
|
+
|
|
178
178
|
for (let i = 1; i < rows.length; i++) {
|
|
179
179
|
const row = rows[i];
|
|
180
180
|
expect(row[0]).toBeTruthy();
|
|
@@ -183,4 +183,15 @@ describe("CsvAutoTranslator", () => {
|
|
|
183
183
|
}
|
|
184
184
|
}, 300000);
|
|
185
185
|
});
|
|
186
|
+
|
|
187
|
+
describe("translateCSV", () => {
|
|
188
|
+
test("翻译 Auto.csv 并验证输出", async () => {
|
|
189
|
+
const incsv = "test/Auto.csv";
|
|
190
|
+
const outcsv = "temp/Auto-Out.csv";
|
|
191
|
+
const fromLang = "zh_cn";
|
|
192
|
+
let result = await CsvAutoTranslator.translateCsvWithLangs("kDr1772519780125", "4cfb5525d3be1e45003910059cd7ea9b", incsv, outcsv, fromLang);
|
|
193
|
+
expect(result.isOk).toBe(true);
|
|
194
|
+
expect(result.translateCount).toBeGreaterThan(0);
|
|
195
|
+
});
|
|
196
|
+
});
|
|
186
197
|
});
|