@goenhance/strapi-plugins-translate 1.1.2 → 1.1.4

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,122 @@ 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 JSON 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 natural language text must be fully localized.
23
+ - Partial translation is forbidden.
24
+
25
+ ────────────────────────
26
+ ALLOWED ENGLISH CONTENT
27
+ ────────────────────────
28
+
29
+ English is allowed ONLY for:
30
+
31
+ 1) Official brand names
32
+ 2) Product model names
33
+ 3) Version numbers
34
+ 4) Standard technical acronyms (AI, API, UI, UX, JSON, HTML, CSS, FPS, 4K, etc.)
35
+ 5) URLs
36
+ 6) Code variables or placeholders
37
+
38
+ All other English words must be translated.
39
+
40
+ ────────────────────────
41
+ STRUCTURE REQUIREMENTS (STRICT)
42
+ ────────────────────────
43
+
44
+ - Preserve JSON structure exactly.
45
+ - Do NOT modify keys.
46
+ - Do NOT add fields.
47
+ - Do NOT remove fields.
48
+ - Do NOT reorder fields.
49
+ - Only translate string values that contain natural language.
50
+ - Preserve placeholders, variables, HTML, Markdown syntax, and URLs exactly.
51
+ - Maintain valid JSON formatting.
52
+
53
+ ────────────────────────
54
+ IMMUTABLE VALUE RULE (CRITICAL)
55
+ ────────────────────────
56
+
57
+ If a string value is:
58
+
59
+ - A pure URL
60
+ - A file path
61
+ - A CDN link
62
+ - An image link
63
+ - A video link
64
+ - A hash
65
+ - An ID
66
+ - A slug
67
+ - A filename
68
+ - Or contains no natural language words
69
+
70
+ You MUST return it exactly as-is.
71
+
72
+ Do NOT:
73
+ - Wrap it in Markdown
74
+ - Convert it to ![]()
75
+ - Add alt text
76
+ - Add HTML tags
77
+ - Reformat it
78
+ - Modify it in any way
79
+
80
+ The value must remain byte-identical to the source.
81
+
82
+ ────────────────────────
83
+ NO FORMAT TRANSFORMATION RULE
84
+ ────────────────────────
85
+
86
+ You are performing translation ONLY.
87
+
88
+ You are NOT:
89
+ - Improving formatting
90
+ - Converting plain URLs into Markdown
91
+ - Generating new markup
92
+ - Optimizing structure
93
+ - Rewriting fields
94
+ - Enhancing content
95
+
96
+ Do not reinterpret field meaning.
97
+ Do not transform content type.
98
+
99
+ ────────────────────────
100
+ SEO LOCALIZATION
101
+ ────────────────────────
102
+
103
+ - Use natural terminology used by native speakers.
104
+ - Avoid literal translation.
105
+ - Maintain marketing fluency where appropriate.
106
+ - Preserve technical accuracy where required.
107
+
108
+ ────────────────────────
109
+ MANDATORY VALIDATION
110
+ ────────────────────────
111
+
112
+ Before output:
113
+
114
+ 1. Verify that only ONE target language is used.
115
+ 2. Ensure no unintended foreign words remain.
116
+ 3. Ensure allowed English is limited to approved categories.
117
+ 4. Ensure all immutable values remain byte-identical.
118
+ 5. Ensure JSON structure is unchanged.
119
+ 6. Ensure valid JSON format.
120
+
121
+ Return ONLY the localized JSON.
122
+ No explanations.
123
+ No comments.
124
+ No extra formatting.`;
10
125
  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
126
  const DEFAULT_LLM_TEMPERATURE = 0.3;
12
127
  const DEFAULT_LLM_MODEL = "gpt-4o";
@@ -1280,41 +1395,47 @@ const llmService = ({ strapi: strapi2 }) => ({
1280
1395
  });
1281
1396
  const buildPrompt = (fields, targetLanguage) => {
1282
1397
  return `
1283
- You are a professional localization engine.
1284
-
1285
- TARGET LANGUAGE:
1398
+ TARGET LANGUAGE (STRICTLY ENFORCED):
1286
1399
  ${targetLanguage}
1287
1400
 
1288
- MANDATORY RULE:
1289
- ALL translated string values MUST be written strictly in ${targetLanguage}.
1401
+ CRITICAL LANGUAGE LOCK:
1290
1402
 
1291
- Mixed languages are NOT allowed.
1292
- Partial translation is NOT allowed.
1293
- Do NOT preserve source language fragments.
1403
+ - ALL translated string values MUST be written strictly in ${targetLanguage}.
1404
+ - Do NOT output any other language.
1405
+ - Do NOT mix similar languages (e.g., Italian/French/Spanish/Portuguese).
1406
+ - Partial translation is forbidden.
1407
+ - Every visible word must be in ${targetLanguage}, except approved English terms.
1294
1408
 
1295
- If any string is not fully in ${targetLanguage}, correct it before output.
1409
+ APPROVED ENGLISH TERMS (ONLY THESE CATEGORIES):
1296
1410
 
1297
- ---
1411
+ - Brand names
1412
+ - Product model names
1413
+ - Version numbers
1414
+ - Standard technical acronyms (AI, API, UI, UX, JSON, HTML, CSS, FPS, 4K)
1415
+ - URLs
1416
+ - Code variables or placeholders
1298
1417
 
1299
- STRUCTURE RULES:
1300
- - Preserve JSON structure.
1301
- - Only translate string values.
1302
- - Do not modify keys.
1303
- - Do not add or remove fields.
1304
- - Preserve placeholders, html, markdown, urls.
1305
- - Return valid JSON only.
1418
+ All other English words must be translated.
1306
1419
 
1307
- ---
1420
+ LANGUAGE VALIDATION CHECK (MANDATORY):
1308
1421
 
1309
- LANGUAGE VALIDATION CHECK:
1310
1422
  Before output:
1311
- 1. Scan all translated strings.
1312
- 2. Verify language consistency.
1423
+ 1. Scan every string value.
1424
+ 2. Confirm it is strictly in ${targetLanguage}.
1313
1425
  3. Remove foreign-language fragments.
1314
- 4. Fix any untranslated content.
1426
+ 4. Replace unintended English words.
1427
+ 5. Ensure valid JSON.
1428
+
1429
+ STRUCTURE RULES:
1430
+
1431
+ - Preserve JSON structure exactly.
1432
+ - Only translate string values.
1433
+ - Do not modify keys.
1434
+ - Do not add or remove fields.
1435
+ - Preserve placeholders, HTML, Markdown, URLs.
1315
1436
 
1316
1437
  SOURCE:
1317
- ${JSON.stringify(fields, null, 2)}
1438
+ ${fields}
1318
1439
  `;
1319
1440
  };
1320
1441
  const getUserConfig = async () => {
@@ -5,7 +5,122 @@ 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 JSON 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 natural language text must be fully localized.
22
+ - Partial translation is forbidden.
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
+ STRUCTURE REQUIREMENTS (STRICT)
41
+ ────────────────────────
42
+
43
+ - Preserve JSON structure exactly.
44
+ - Do NOT modify keys.
45
+ - Do NOT add fields.
46
+ - Do NOT remove fields.
47
+ - Do NOT reorder fields.
48
+ - Only translate string values that contain natural language.
49
+ - Preserve placeholders, variables, HTML, Markdown syntax, and URLs exactly.
50
+ - Maintain valid JSON formatting.
51
+
52
+ ────────────────────────
53
+ IMMUTABLE VALUE RULE (CRITICAL)
54
+ ────────────────────────
55
+
56
+ If a string value is:
57
+
58
+ - A pure URL
59
+ - A file path
60
+ - A CDN link
61
+ - An image link
62
+ - A video link
63
+ - A hash
64
+ - An ID
65
+ - A slug
66
+ - A filename
67
+ - Or contains no natural language words
68
+
69
+ You MUST return it exactly as-is.
70
+
71
+ Do NOT:
72
+ - Wrap it in Markdown
73
+ - Convert it to ![]()
74
+ - Add alt text
75
+ - Add HTML tags
76
+ - Reformat it
77
+ - Modify it in any way
78
+
79
+ The value must remain byte-identical to the source.
80
+
81
+ ────────────────────────
82
+ NO FORMAT TRANSFORMATION RULE
83
+ ────────────────────────
84
+
85
+ You are performing translation ONLY.
86
+
87
+ You are NOT:
88
+ - Improving formatting
89
+ - Converting plain URLs into Markdown
90
+ - Generating new markup
91
+ - Optimizing structure
92
+ - Rewriting fields
93
+ - Enhancing content
94
+
95
+ Do not reinterpret field meaning.
96
+ Do not transform content type.
97
+
98
+ ────────────────────────
99
+ SEO LOCALIZATION
100
+ ────────────────────────
101
+
102
+ - Use natural terminology used by native speakers.
103
+ - Avoid literal translation.
104
+ - Maintain marketing fluency where appropriate.
105
+ - Preserve technical accuracy where required.
106
+
107
+ ────────────────────────
108
+ MANDATORY VALIDATION
109
+ ────────────────────────
110
+
111
+ Before output:
112
+
113
+ 1. Verify that only ONE target language is used.
114
+ 2. Ensure no unintended foreign words remain.
115
+ 3. Ensure allowed English is limited to approved categories.
116
+ 4. Ensure all immutable values remain byte-identical.
117
+ 5. Ensure JSON structure is unchanged.
118
+ 6. Ensure valid JSON format.
119
+
120
+ Return ONLY the localized JSON.
121
+ No explanations.
122
+ No comments.
123
+ No extra formatting.`;
9
124
  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
125
  const DEFAULT_LLM_TEMPERATURE = 0.3;
11
126
  const DEFAULT_LLM_MODEL = "gpt-4o";
@@ -1279,41 +1394,47 @@ const llmService = ({ strapi: strapi2 }) => ({
1279
1394
  });
1280
1395
  const buildPrompt = (fields, targetLanguage) => {
1281
1396
  return `
1282
- You are a professional localization engine.
1283
-
1284
- TARGET LANGUAGE:
1397
+ TARGET LANGUAGE (STRICTLY ENFORCED):
1285
1398
  ${targetLanguage}
1286
1399
 
1287
- MANDATORY RULE:
1288
- ALL translated string values MUST be written strictly in ${targetLanguage}.
1400
+ CRITICAL LANGUAGE LOCK:
1289
1401
 
1290
- Mixed languages are NOT allowed.
1291
- Partial translation is NOT allowed.
1292
- Do NOT preserve source language fragments.
1402
+ - ALL translated string values MUST be written strictly in ${targetLanguage}.
1403
+ - Do NOT output any other language.
1404
+ - Do NOT mix similar languages (e.g., Italian/French/Spanish/Portuguese).
1405
+ - Partial translation is forbidden.
1406
+ - Every visible word must be in ${targetLanguage}, except approved English terms.
1293
1407
 
1294
- If any string is not fully in ${targetLanguage}, correct it before output.
1408
+ APPROVED ENGLISH TERMS (ONLY THESE CATEGORIES):
1295
1409
 
1296
- ---
1410
+ - Brand names
1411
+ - Product model names
1412
+ - Version numbers
1413
+ - Standard technical acronyms (AI, API, UI, UX, JSON, HTML, CSS, FPS, 4K)
1414
+ - URLs
1415
+ - Code variables or placeholders
1297
1416
 
1298
- STRUCTURE RULES:
1299
- - Preserve JSON structure.
1300
- - Only translate string values.
1301
- - Do not modify keys.
1302
- - Do not add or remove fields.
1303
- - Preserve placeholders, html, markdown, urls.
1304
- - Return valid JSON only.
1417
+ All other English words must be translated.
1305
1418
 
1306
- ---
1419
+ LANGUAGE VALIDATION CHECK (MANDATORY):
1307
1420
 
1308
- LANGUAGE VALIDATION CHECK:
1309
1421
  Before output:
1310
- 1. Scan all translated strings.
1311
- 2. Verify language consistency.
1422
+ 1. Scan every string value.
1423
+ 2. Confirm it is strictly in ${targetLanguage}.
1312
1424
  3. Remove foreign-language fragments.
1313
- 4. Fix any untranslated content.
1425
+ 4. Replace unintended English words.
1426
+ 5. Ensure valid JSON.
1427
+
1428
+ STRUCTURE RULES:
1429
+
1430
+ - Preserve JSON structure exactly.
1431
+ - Only translate string values.
1432
+ - Do not modify keys.
1433
+ - Do not add or remove fields.
1434
+ - Preserve placeholders, HTML, Markdown, URLs.
1314
1435
 
1315
1436
  SOURCE:
1316
- ${JSON.stringify(fields, null, 2)}
1437
+ ${fields}
1317
1438
  `;
1318
1439
  };
1319
1440
  const getUserConfig = async () => {
@@ -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 JSON 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 natural language text must be fully localized.\n- Partial translation is forbidden.\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\nSTRUCTURE REQUIREMENTS (STRICT)\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 fields.\n- Do NOT remove fields.\n- Do NOT reorder fields.\n- Only translate string values that contain natural language.\n- Preserve placeholders, variables, HTML, Markdown syntax, 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\nIMMUTABLE VALUE RULE (CRITICAL)\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\nIf a string value is:\n\n- A pure URL\n- A file path\n- A CDN link\n- An image link\n- A video link\n- A hash\n- An ID\n- A slug\n- A filename\n- Or contains no natural language words\n\nYou MUST return it exactly as-is.\n\nDo NOT:\n- Wrap it in Markdown\n- Convert it to ![]()\n- Add alt text\n- Add HTML tags\n- Reformat it\n- Modify it in any way\n\nThe value must remain byte-identical to the source.\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\nNO FORMAT TRANSFORMATION RULE\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\nYou are performing translation ONLY.\n\nYou are NOT:\n- Improving formatting\n- Converting plain URLs into Markdown\n- Generating new markup\n- Optimizing structure\n- Rewriting fields\n- Enhancing content\n\nDo not reinterpret field meaning.\nDo not transform content type.\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\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:\n\n1. Verify that only ONE target language is used.\n2. Ensure no unintended foreign words remain.\n3. Ensure allowed English is limited to approved categories.\n4. Ensure all immutable values remain byte-identical.\n5. Ensure JSON structure is unchanged.\n6. Ensure 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.2",
2
+ "version": "1.1.4",
3
3
  "keywords": [
4
4
  "strapi",
5
5
  "plugin",