@adminforth/i18n 1.3.1 → 1.3.2

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/build.log CHANGED
@@ -16,5 +16,5 @@ custom/package-lock.json
16
16
  custom/package.json
17
17
  custom/tsconfig.json
18
18
 
19
- sent 31,064 bytes received 229 bytes 62,586.00 bytes/sec
20
- total size is 30,197 speedup is 0.96
19
+ sent 31,052 bytes received 229 bytes 62,562.00 bytes/sec
20
+ total size is 30,197 speedup is 0.97
package/dist/index.js CHANGED
@@ -440,9 +440,9 @@ export default class I18nPlugin extends AdminForthPlugin {
440
440
  const langName = iso6391.getName(lang);
441
441
  const requestSlavicPlurals = Object.keys(SLAVIC_PLURAL_EXAMPLES).includes(lang) && plurals;
442
442
  const prompt = `
443
- I need to translate strings in JSON to ${lang} (${langName}) language from English for my web app.
443
+ I need to translate strings in JSON to ${langName} language (ISO 639-1 code ${lang}) from English for my web app.
444
444
  ${requestSlavicPlurals ? `You should provide 4 slavic forms (in format "zero count | singular count | 2-4 | 5+") e.g. "apple | apples" should become "${SLAVIC_PLURAL_EXAMPLES[lang]}"` : ''}
445
- Keep keys, as is, write translation into values! Here are the strings:
445
+ Keep keys, as is, write translation into values! If keys have variables (in curly brackets), then translated strings should have them as well (variables itself should not be translated). Here are the strings:
446
446
 
447
447
  \`\`\`json
448
448
  ${JSON.stringify(strings.reduce((acc, s) => {
@@ -451,6 +451,7 @@ ${JSON.stringify(strings.reduce((acc, s) => {
451
451
  }, {}), null, 2)}
452
452
  \`\`\`
453
453
  `;
454
+ process.env.HEAVY_DEBUG && console.log(`🪲🔪LLM prompt >> ${prompt.length}, <<${prompt} :\n\n`, JSON.stringify(prompt));
454
455
  // call OpenAI
455
456
  const resp = yield this.options.completeAdapter.complete(prompt, [], prompt.length * 2);
456
457
  process.env.HEAVY_DEBUG && console.log(`🪲🔪LLM resp >> ${prompt.length}, <<${resp.content.length} :\n\n`, JSON.stringify(resp));
package/index.ts CHANGED
@@ -498,9 +498,9 @@ export default class I18nPlugin extends AdminForthPlugin {
498
498
  const requestSlavicPlurals = Object.keys(SLAVIC_PLURAL_EXAMPLES).includes(lang) && plurals;
499
499
 
500
500
  const prompt = `
501
- I need to translate strings in JSON to ${lang} (${langName}) language from English for my web app.
501
+ I need to translate strings in JSON to ${langName} language (ISO 639-1 code ${lang}) from English for my web app.
502
502
  ${requestSlavicPlurals ? `You should provide 4 slavic forms (in format "zero count | singular count | 2-4 | 5+") e.g. "apple | apples" should become "${SLAVIC_PLURAL_EXAMPLES[lang]}"` : ''}
503
- Keep keys, as is, write translation into values! Here are the strings:
503
+ Keep keys, as is, write translation into values! If keys have variables (in curly brackets), then translated strings should have them as well (variables itself should not be translated). Here are the strings:
504
504
 
505
505
  \`\`\`json
506
506
  ${
@@ -512,6 +512,8 @@ JSON.stringify(strings.reduce((acc: object, s: { en_string: string }): object =>
512
512
  \`\`\`
513
513
  `;
514
514
 
515
+ process.env.HEAVY_DEBUG && console.log(`🪲🔪LLM prompt >> ${prompt.length}, <<${prompt} :\n\n`, JSON.stringify(prompt));
516
+
515
517
  // call OpenAI
516
518
  const resp = await this.options.completeAdapter.complete(
517
519
  prompt,
@@ -520,7 +522,7 @@ JSON.stringify(strings.reduce((acc: object, s: { en_string: string }): object =>
520
522
  );
521
523
 
522
524
  process.env.HEAVY_DEBUG && console.log(`🪲🔪LLM resp >> ${prompt.length}, <<${resp.content.length} :\n\n`, JSON.stringify(resp));
523
-
525
+
524
526
  if (resp.error) {
525
527
  throw new AiTranslateError(resp.error);
526
528
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adminforth/i18n",
3
- "version": "1.3.1",
3
+ "version": "1.3.2",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "type": "module",