@adminforth/i18n 1.0.18-next.7 → 1.0.18-next.9
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/index.js +3 -4
- package/index.ts +3 -6
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -286,8 +286,8 @@ export default class I18N extends AdminForthPlugin {
|
|
|
286
286
|
translatedCount = yield this.bulkTranslate({ selectedIds });
|
|
287
287
|
}
|
|
288
288
|
catch (e) {
|
|
289
|
+
process.env.HEAVY_DEBUG && console.error('🪲⛔ bulkTranslate error', e);
|
|
289
290
|
if (e instanceof AiTranslateError) {
|
|
290
|
-
process.env.HEAVY_DEBUG && console.error('🪲⛔ bulkTranslate error', e);
|
|
291
291
|
return { ok: false, error: e.message };
|
|
292
292
|
}
|
|
293
293
|
}
|
|
@@ -375,8 +375,8 @@ ${JSON.stringify(strings.reduce((acc, s) => {
|
|
|
375
375
|
res = resp.content.split("```json")[1].split("```")[0];
|
|
376
376
|
}
|
|
377
377
|
catch (e) {
|
|
378
|
-
console.error(
|
|
379
|
-
|
|
378
|
+
console.error(`Error in parsing OpenAI: ${resp}\n Prompt was: ${prompt}\n Resp was: ${JSON.stringify(resp)}`);
|
|
379
|
+
return [];
|
|
380
380
|
}
|
|
381
381
|
res = JSON.parse(res);
|
|
382
382
|
for (const [enStr, translatedStr] of Object.entries(res)) {
|
|
@@ -421,7 +421,6 @@ ${JSON.stringify(strings.reduce((acc, s) => {
|
|
|
421
421
|
}
|
|
422
422
|
}
|
|
423
423
|
}
|
|
424
|
-
const maxKeysInOneReq = 10;
|
|
425
424
|
const updateStrings = {};
|
|
426
425
|
const langsInvolved = new Set(Object.keys(needToTranslateByLang));
|
|
427
426
|
let totalTranslated = [];
|
package/index.ts
CHANGED
|
@@ -329,8 +329,8 @@ export default class I18N extends AdminForthPlugin {
|
|
|
329
329
|
try {
|
|
330
330
|
translatedCount = await this.bulkTranslate({ selectedIds });
|
|
331
331
|
} catch (e) {
|
|
332
|
+
process.env.HEAVY_DEBUG && console.error('🪲⛔ bulkTranslate error', e);
|
|
332
333
|
if (e instanceof AiTranslateError) {
|
|
333
|
-
process.env.HEAVY_DEBUG && console.error('🪲⛔ bulkTranslate error', e);
|
|
334
334
|
return { ok: false, error: e.message };
|
|
335
335
|
}
|
|
336
336
|
}
|
|
@@ -437,12 +437,11 @@ JSON.stringify(strings.reduce((acc: object, s: { en_string: string }): object =>
|
|
|
437
437
|
try {
|
|
438
438
|
res = resp.content.split("```json")[1].split("```")[0];
|
|
439
439
|
} catch (e) {
|
|
440
|
-
console.error(
|
|
441
|
-
|
|
440
|
+
console.error(`Error in parsing OpenAI: ${resp}\n Prompt was: ${prompt}\n Resp was: ${JSON.stringify(resp)}`, );
|
|
441
|
+
return [];
|
|
442
442
|
}
|
|
443
443
|
res = JSON.parse(res);
|
|
444
444
|
|
|
445
|
-
|
|
446
445
|
for (const [enStr, translatedStr] of Object.entries(res) as [string, string][]) {
|
|
447
446
|
const translationsTargeted = translations.filter(t => t[this.enFieldName] === enStr);
|
|
448
447
|
// might be several with same en_string
|
|
@@ -500,8 +499,6 @@ JSON.stringify(strings.reduce((acc: object, s: { en_string: string }): object =>
|
|
|
500
499
|
}
|
|
501
500
|
}
|
|
502
501
|
|
|
503
|
-
const maxKeysInOneReq = 10;
|
|
504
|
-
|
|
505
502
|
const updateStrings: Record<string, {
|
|
506
503
|
updates: any,
|
|
507
504
|
category: string,
|