@goenhance/strapi-plugins-translate 1.1.1 → 1.1.3

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.
@@ -6,7 +6,70 @@ const destroy = ({ strapi: strapi2 }) => {
6
6
  };
7
7
  const register = ({ strapi: strapi2 }) => {
8
8
  };
9
- const DEFAULT_SYSTEM_PROMPT = "You are a professional translator. Your task is to translate the provided content accurately while preserving the original meaning and tone.";
9
+ const DEFAULT_SYSTEM_PROMPT = `You are a professional localization engineer specializing in SEO-driven multilingual websites.
10
+
11
+ Your task is to translate structured content into ONE strictly defined target language provided in the user instructions.
12
+
13
+ You must strictly follow the language specified by the user.
14
+
15
+ ────────────────────────
16
+ GLOBAL LANGUAGE RULES
17
+ ────────────────────────
18
+
19
+ - Output must contain only ONE language.
20
+ - Do not mix languages.
21
+ - Do not auto-switch to a similar language.
22
+ - All visible text must be fully localized.
23
+
24
+ ────────────────────────
25
+ ALLOWED ENGLISH CONTENT
26
+ ────────────────────────
27
+
28
+ English is allowed ONLY for:
29
+
30
+ 1) Official brand names
31
+ 2) Product model names
32
+ 3) Version numbers
33
+ 4) Standard technical acronyms (AI, API, UI, UX, JSON, HTML, CSS, FPS, 4K, etc.)
34
+ 5) URLs
35
+ 6) Code variables or placeholders
36
+
37
+ All other English words must be translated.
38
+
39
+ ────────────────────────
40
+ SEO LOCALIZATION
41
+ ────────────────────────
42
+
43
+ - Use natural terminology used by native speakers.
44
+ - Avoid literal translation.
45
+ - Maintain marketing fluency where appropriate.
46
+ - Preserve technical accuracy where required.
47
+
48
+ ────────────────────────
49
+ STRUCTURE REQUIREMENTS
50
+ ────────────────────────
51
+
52
+ - Preserve JSON structure exactly.
53
+ - Do not modify keys.
54
+ - Do not add or remove fields.
55
+ - Only translate string values.
56
+ - Preserve placeholders, variables, HTML, Markdown, and URLs exactly.
57
+ - Maintain valid JSON formatting.
58
+
59
+ ────────────────────────
60
+ MANDATORY VALIDATION
61
+ ────────────────────────
62
+
63
+ Before output:
64
+ 1. Verify that only one language is used.
65
+ 2. Ensure no unintended foreign words remain.
66
+ 3. Ensure allowed English is limited to approved categories.
67
+ 4. Confirm valid JSON format.
68
+
69
+ Return ONLY the localized JSON.
70
+ No explanations.
71
+ No comments.
72
+ No extra formatting.`;
10
73
  const SYSTEM_PROMPT_APPENDIX = `The user asks you to translate the text to a specific language, the language is provided via short code like "en", "fr", "de", etc.`;
11
74
  const DEFAULT_LLM_TEMPERATURE = 0.3;
12
75
  const DEFAULT_LLM_MODEL = "gpt-4o";
@@ -1279,44 +1342,49 @@ const llmService = ({ strapi: strapi2 }) => ({
1279
1342
  }
1280
1343
  });
1281
1344
  const buildPrompt = (fields, targetLanguage) => {
1282
- return `You are translating CMS content into a specified target language.
1283
-
1284
- Target Language:
1345
+ return `
1346
+ TARGET LANGUAGE (STRICTLY ENFORCED):
1285
1347
  ${targetLanguage}
1286
1348
 
1287
- IMPORTANT:
1288
- You MUST translate strictly into the specified target language.
1289
- Do NOT auto-detect language.
1290
- Do NOT change the target language.
1291
- If the target language is Italian, output must be Italian.
1292
- If it is French, output must be French.
1293
- Follow exactly the language provided.
1349
+ CRITICAL LANGUAGE LOCK:
1350
+
1351
+ - ALL translated string values MUST be written strictly in ${targetLanguage}.
1352
+ - Do NOT output any other language.
1353
+ - Do NOT mix similar languages (e.g., Italian/French/Spanish/Portuguese).
1354
+ - Partial translation is forbidden.
1355
+ - Every visible word must be in ${targetLanguage}, except approved English terms.
1356
+
1357
+ APPROVED ENGLISH TERMS (ONLY THESE CATEGORIES):
1358
+
1359
+ - Brand names
1360
+ - Product model names
1361
+ - Version numbers
1362
+ - Standard technical acronyms (AI, API, UI, UX, JSON, HTML, CSS, FPS, 4K)
1363
+ - URLs
1364
+ - Code variables or placeholders
1294
1365
 
1295
- ---
1366
+ All other English words must be translated.
1296
1367
 
1297
- TRANSLATION RULES:
1368
+ LANGUAGE VALIDATION CHECK (MANDATORY):
1298
1369
 
1299
- 1. Preserve the entire JSON structure and keys exactly as provided.
1300
- 2. Only translate string values.
1301
- 3. Do NOT modify keys, arrays, object structure, or data types.
1302
- 4. Preserve all markdown formatting inside text.
1303
- 5. Keep all HTML tags intact.
1304
- 6. Preserve placeholders like:
1305
- {{variable}}, {variable}, %s, %d
1306
- 7. Preserve URLs, code blocks, technical tokens, and system identifiers.
1307
- 8. Return ONLY valid JSON.
1308
- 9. Do NOT add explanations, comments, or extra text.
1370
+ Before output:
1371
+ 1. Scan every string value.
1372
+ 2. Confirm it is strictly in ${targetLanguage}.
1373
+ 3. Remove foreign-language fragments.
1374
+ 4. Replace unintended English words.
1375
+ 5. Ensure valid JSON.
1309
1376
 
1310
- ---
1377
+ STRUCTURE RULES:
1311
1378
 
1312
- Validation Step (Critical):
1313
- Before outputting, verify:
1314
- - All string values are written in ${targetLanguage}
1315
- - No mixed languages remain
1316
- - JSON structure is valid
1379
+ - Preserve JSON structure exactly.
1380
+ - Only translate string values.
1381
+ - Do not modify keys.
1382
+ - Do not add or remove fields.
1383
+ - Preserve placeholders, HTML, Markdown, URLs.
1317
1384
 
1318
- SOURCE JSON:
1319
- ${JSON.stringify(fields, null, 2)}`;
1385
+ SOURCE:
1386
+ ${JSON.stringify(fields, null, 2)}
1387
+ `;
1320
1388
  };
1321
1389
  const getUserConfig = async () => {
1322
1390
  const pluginStore = strapi.store({
@@ -5,7 +5,70 @@ const destroy = ({ strapi: strapi2 }) => {
5
5
  };
6
6
  const register = ({ strapi: strapi2 }) => {
7
7
  };
8
- const DEFAULT_SYSTEM_PROMPT = "You are a professional translator. Your task is to translate the provided content accurately while preserving the original meaning and tone.";
8
+ const DEFAULT_SYSTEM_PROMPT = `You are a professional localization engineer specializing in SEO-driven multilingual websites.
9
+
10
+ Your task is to translate structured content into ONE strictly defined target language provided in the user instructions.
11
+
12
+ You must strictly follow the language specified by the user.
13
+
14
+ ────────────────────────
15
+ GLOBAL LANGUAGE RULES
16
+ ────────────────────────
17
+
18
+ - Output must contain only ONE language.
19
+ - Do not mix languages.
20
+ - Do not auto-switch to a similar language.
21
+ - All visible text must be fully localized.
22
+
23
+ ────────────────────────
24
+ ALLOWED ENGLISH CONTENT
25
+ ────────────────────────
26
+
27
+ English is allowed ONLY for:
28
+
29
+ 1) Official brand names
30
+ 2) Product model names
31
+ 3) Version numbers
32
+ 4) Standard technical acronyms (AI, API, UI, UX, JSON, HTML, CSS, FPS, 4K, etc.)
33
+ 5) URLs
34
+ 6) Code variables or placeholders
35
+
36
+ All other English words must be translated.
37
+
38
+ ────────────────────────
39
+ SEO LOCALIZATION
40
+ ────────────────────────
41
+
42
+ - Use natural terminology used by native speakers.
43
+ - Avoid literal translation.
44
+ - Maintain marketing fluency where appropriate.
45
+ - Preserve technical accuracy where required.
46
+
47
+ ────────────────────────
48
+ STRUCTURE REQUIREMENTS
49
+ ────────────────────────
50
+
51
+ - Preserve JSON structure exactly.
52
+ - Do not modify keys.
53
+ - Do not add or remove fields.
54
+ - Only translate string values.
55
+ - Preserve placeholders, variables, HTML, Markdown, and URLs exactly.
56
+ - Maintain valid JSON formatting.
57
+
58
+ ────────────────────────
59
+ MANDATORY VALIDATION
60
+ ────────────────────────
61
+
62
+ Before output:
63
+ 1. Verify that only one language is used.
64
+ 2. Ensure no unintended foreign words remain.
65
+ 3. Ensure allowed English is limited to approved categories.
66
+ 4. Confirm valid JSON format.
67
+
68
+ Return ONLY the localized JSON.
69
+ No explanations.
70
+ No comments.
71
+ No extra formatting.`;
9
72
  const SYSTEM_PROMPT_APPENDIX = `The user asks you to translate the text to a specific language, the language is provided via short code like "en", "fr", "de", etc.`;
10
73
  const DEFAULT_LLM_TEMPERATURE = 0.3;
11
74
  const DEFAULT_LLM_MODEL = "gpt-4o";
@@ -1278,44 +1341,49 @@ const llmService = ({ strapi: strapi2 }) => ({
1278
1341
  }
1279
1342
  });
1280
1343
  const buildPrompt = (fields, targetLanguage) => {
1281
- return `You are translating CMS content into a specified target language.
1282
-
1283
- Target Language:
1344
+ return `
1345
+ TARGET LANGUAGE (STRICTLY ENFORCED):
1284
1346
  ${targetLanguage}
1285
1347
 
1286
- IMPORTANT:
1287
- You MUST translate strictly into the specified target language.
1288
- Do NOT auto-detect language.
1289
- Do NOT change the target language.
1290
- If the target language is Italian, output must be Italian.
1291
- If it is French, output must be French.
1292
- Follow exactly the language provided.
1348
+ CRITICAL LANGUAGE LOCK:
1349
+
1350
+ - ALL translated string values MUST be written strictly in ${targetLanguage}.
1351
+ - Do NOT output any other language.
1352
+ - Do NOT mix similar languages (e.g., Italian/French/Spanish/Portuguese).
1353
+ - Partial translation is forbidden.
1354
+ - Every visible word must be in ${targetLanguage}, except approved English terms.
1355
+
1356
+ APPROVED ENGLISH TERMS (ONLY THESE CATEGORIES):
1357
+
1358
+ - Brand names
1359
+ - Product model names
1360
+ - Version numbers
1361
+ - Standard technical acronyms (AI, API, UI, UX, JSON, HTML, CSS, FPS, 4K)
1362
+ - URLs
1363
+ - Code variables or placeholders
1293
1364
 
1294
- ---
1365
+ All other English words must be translated.
1295
1366
 
1296
- TRANSLATION RULES:
1367
+ LANGUAGE VALIDATION CHECK (MANDATORY):
1297
1368
 
1298
- 1. Preserve the entire JSON structure and keys exactly as provided.
1299
- 2. Only translate string values.
1300
- 3. Do NOT modify keys, arrays, object structure, or data types.
1301
- 4. Preserve all markdown formatting inside text.
1302
- 5. Keep all HTML tags intact.
1303
- 6. Preserve placeholders like:
1304
- {{variable}}, {variable}, %s, %d
1305
- 7. Preserve URLs, code blocks, technical tokens, and system identifiers.
1306
- 8. Return ONLY valid JSON.
1307
- 9. Do NOT add explanations, comments, or extra text.
1369
+ Before output:
1370
+ 1. Scan every string value.
1371
+ 2. Confirm it is strictly in ${targetLanguage}.
1372
+ 3. Remove foreign-language fragments.
1373
+ 4. Replace unintended English words.
1374
+ 5. Ensure valid JSON.
1308
1375
 
1309
- ---
1376
+ STRUCTURE RULES:
1310
1377
 
1311
- Validation Step (Critical):
1312
- Before outputting, verify:
1313
- - All string values are written in ${targetLanguage}
1314
- - No mixed languages remain
1315
- - JSON structure is valid
1378
+ - Preserve JSON structure exactly.
1379
+ - Only translate string values.
1380
+ - Do not modify keys.
1381
+ - Do not add or remove fields.
1382
+ - Preserve placeholders, HTML, Markdown, URLs.
1316
1383
 
1317
- SOURCE JSON:
1318
- ${JSON.stringify(fields, null, 2)}`;
1384
+ SOURCE:
1385
+ ${JSON.stringify(fields, null, 2)}
1386
+ `;
1319
1387
  };
1320
1388
  const getUserConfig = async () => {
1321
1389
  const pluginStore = strapi.store({
@@ -1,4 +1,4 @@
1
- export declare const DEFAULT_SYSTEM_PROMPT = "You are a professional translator. Your task is to translate the provided content accurately while preserving the original meaning and tone.";
1
+ export declare const DEFAULT_SYSTEM_PROMPT = "You are a professional localization engineer specializing in SEO-driven multilingual websites.\n\nYour task is to translate structured content into ONE strictly defined target language provided in the user instructions.\n\nYou must strictly follow the language specified by the user.\n\n\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\nGLOBAL LANGUAGE RULES\n\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\n- Output must contain only ONE language.\n- Do not mix languages.\n- Do not auto-switch to a similar language.\n- All visible text must be fully localized.\n\n\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\nALLOWED ENGLISH CONTENT\n\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nEnglish is allowed ONLY for:\n\n1) Official brand names\n2) Product model names\n3) Version numbers\n4) Standard technical acronyms (AI, API, UI, UX, JSON, HTML, CSS, FPS, 4K, etc.)\n5) URLs\n6) Code variables or placeholders\n\nAll other English words must be translated.\n\n\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\nSEO LOCALIZATION\n\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\n- Use natural terminology used by native speakers.\n- Avoid literal translation.\n- Maintain marketing fluency where appropriate.\n- Preserve technical accuracy where required.\n\n\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\nSTRUCTURE REQUIREMENTS\n\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\n- Preserve JSON structure exactly.\n- Do not modify keys.\n- Do not add or remove fields.\n- Only translate string values.\n- Preserve placeholders, variables, HTML, Markdown, and URLs exactly.\n- Maintain valid JSON formatting.\n\n\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\nMANDATORY VALIDATION\n\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nBefore output:\n1. Verify that only one language is used.\n2. Ensure no unintended foreign words remain.\n3. Ensure allowed English is limited to approved categories.\n4. Confirm valid JSON format.\n\nReturn ONLY the localized JSON.\nNo explanations.\nNo comments.\nNo extra formatting.";
2
2
  export declare const SYSTEM_PROMPT_APPENDIX = "The user asks you to translate the text to a specific language, the language is provided via short code like \"en\", \"fr\", \"de\", etc.";
3
3
  export declare const DEFAULT_LLM_TEMPERATURE = 0.3;
4
4
  export declare const DEFAULT_LLM_MODEL = "gpt-4o";
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.1.1",
2
+ "version": "1.1.3",
3
3
  "keywords": [
4
4
  "strapi",
5
5
  "plugin",