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.
Files changed (2) hide show
  1. package/index.js +3 -6
  2. 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.processing = false;
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('\n---\n');
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('\n---\n');
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) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "gptrans",
3
3
  "type": "module",
4
- "version": "1.5.6",
4
+ "version": "1.5.8",
5
5
  "description": "🚆 GPTrans - The smarter AI-powered way to translate.",
6
6
  "keywords": [
7
7
  "translate",