@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.
- package/dist/server/index.js +99 -31
- package/dist/server/index.mjs +99 -31
- package/dist/server/src/config/constants.d.ts +1 -1
- package/package.json +1 -1
package/dist/server/index.js
CHANGED
|
@@ -6,7 +6,70 @@ const destroy = ({ strapi: strapi2 }) => {
|
|
|
6
6
|
};
|
|
7
7
|
const register = ({ strapi: strapi2 }) => {
|
|
8
8
|
};
|
|
9
|
-
const DEFAULT_SYSTEM_PROMPT =
|
|
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 `
|
|
1283
|
-
|
|
1284
|
-
Target Language:
|
|
1345
|
+
return `
|
|
1346
|
+
TARGET LANGUAGE (STRICTLY ENFORCED):
|
|
1285
1347
|
${targetLanguage}
|
|
1286
1348
|
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
Do NOT
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
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
|
-
|
|
1368
|
+
LANGUAGE VALIDATION CHECK (MANDATORY):
|
|
1298
1369
|
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
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
|
-
|
|
1313
|
-
|
|
1314
|
-
-
|
|
1315
|
-
-
|
|
1316
|
-
-
|
|
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
|
|
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({
|
package/dist/server/index.mjs
CHANGED
|
@@ -5,7 +5,70 @@ const destroy = ({ strapi: strapi2 }) => {
|
|
|
5
5
|
};
|
|
6
6
|
const register = ({ strapi: strapi2 }) => {
|
|
7
7
|
};
|
|
8
|
-
const DEFAULT_SYSTEM_PROMPT =
|
|
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 `
|
|
1282
|
-
|
|
1283
|
-
Target Language:
|
|
1344
|
+
return `
|
|
1345
|
+
TARGET LANGUAGE (STRICTLY ENFORCED):
|
|
1284
1346
|
${targetLanguage}
|
|
1285
1347
|
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
Do NOT
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
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
|
-
|
|
1367
|
+
LANGUAGE VALIDATION CHECK (MANDATORY):
|
|
1297
1368
|
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
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
|
-
|
|
1312
|
-
|
|
1313
|
-
-
|
|
1314
|
-
-
|
|
1315
|
-
-
|
|
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
|
|
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
|
|
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