gptrans 1.5.6 → 1.5.8
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/index.js +3 -6
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -65,7 +65,7 @@ class GPTrans {
|
|
|
65
65
|
temperature: 0
|
|
66
66
|
}
|
|
67
67
|
};
|
|
68
|
-
this.
|
|
68
|
+
this.divider = '------';
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
setContext(context = '') {
|
|
@@ -137,7 +137,6 @@ class GPTrans {
|
|
|
137
137
|
}
|
|
138
138
|
|
|
139
139
|
async _processBatch(context) {
|
|
140
|
-
this.processing = true;
|
|
141
140
|
|
|
142
141
|
const batch = Array.from(this.pendingTranslations.entries());
|
|
143
142
|
|
|
@@ -150,10 +149,10 @@ class GPTrans {
|
|
|
150
149
|
|
|
151
150
|
this.pendingCharCount = 0;
|
|
152
151
|
|
|
153
|
-
const textsToTranslate = batch.map(([_, text]) => text).join(
|
|
152
|
+
const textsToTranslate = batch.map(([_, text]) => text).join(`\n${this.divider}\n`);
|
|
154
153
|
try {
|
|
155
154
|
const translations = await this._translate(textsToTranslate);
|
|
156
|
-
const translatedTexts = translations.split(
|
|
155
|
+
const translatedTexts = translations.split(`\n${this.divider}\n`);
|
|
157
156
|
|
|
158
157
|
const contextHash = this._hash(context);
|
|
159
158
|
batch.forEach(([key], index) => {
|
|
@@ -171,8 +170,6 @@ class GPTrans {
|
|
|
171
170
|
} catch (e) {
|
|
172
171
|
console.error(e);
|
|
173
172
|
}
|
|
174
|
-
|
|
175
|
-
this.processing = false;
|
|
176
173
|
}
|
|
177
174
|
|
|
178
175
|
async _translate(text) {
|