@goenhance/strapi-plugins-translate 1.0.9 → 1.1.1

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.
@@ -436,12 +436,17 @@ async function executeBatchTranslation(strapi2, contentType, entries, sourceLoca
436
436
  delete translatedData.localizations;
437
437
  delete translatedData.createdBy;
438
438
  delete translatedData.updatedBy;
439
- await strapi2.documents(contentType).update({
439
+ const updatedDoc = await strapi2.documents(contentType).update({
440
440
  documentId: entryId,
441
441
  locale: targetLocale,
442
- data: translatedData,
443
- status: publish ? "published" : "draft"
442
+ data: translatedData
444
443
  });
444
+ if (publish && updatedDoc) {
445
+ await strapi2.documents(contentType).publish({
446
+ documentId: entryId,
447
+ locale: targetLocale
448
+ });
449
+ }
445
450
  return {
446
451
  documentId: entryId,
447
452
  locale: targetLocale,
@@ -843,12 +848,17 @@ const controllers$1 = ({ strapi: strapi2 }) => ({
843
848
  delete translatedData.localizations;
844
849
  delete translatedData.createdBy;
845
850
  delete translatedData.updatedBy;
846
- await strapi2.documents(contentType).update({
851
+ const updatedDoc = await strapi2.documents(contentType).update({
847
852
  documentId: entryId,
848
853
  locale: targetLocale,
849
- data: translatedData,
850
- status: publish ? "published" : "draft"
854
+ data: translatedData
851
855
  });
856
+ if (publish && updatedDoc) {
857
+ await strapi2.documents(contentType).publish({
858
+ documentId: entryId,
859
+ locale: targetLocale
860
+ });
861
+ }
852
862
  return {
853
863
  documentId: entryId,
854
864
  locale: targetLocale,
@@ -1269,18 +1279,41 @@ const llmService = ({ strapi: strapi2 }) => ({
1269
1279
  }
1270
1280
  });
1271
1281
  const buildPrompt = (fields, targetLanguage) => {
1272
- return `You are translating content from a CMS. Please translate the following JSON data to ${targetLanguage}.
1282
+ return `You are translating CMS content into a specified target language.
1283
+
1284
+ Target Language:
1285
+ ${targetLanguage}
1286
+
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.
1294
+
1295
+ ---
1296
+
1297
+ TRANSLATION RULES:
1298
+
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.
1309
+
1310
+ ---
1273
1311
 
1274
- IMPORTANT RULES:
1275
- 1. Preserve all JSON structure and keys exactly as provided
1276
- 2. Only translate string values
1277
- 3. Maintain any markdown formatting within the text
1278
- 4. Keep HTML tags intact if present
1279
- 5. Preserve any special characters or placeholders
1280
- 6. Return ONLY the translated JSON object
1281
- 7. Ensure the JSON is valid and well-formed. Keep arrays and nested objects intact
1282
- 8. Do not add any explanations or comments
1283
- 9. Ensure professional and culturally appropriate translations
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
1284
1317
 
1285
1318
  SOURCE JSON:
1286
1319
  ${JSON.stringify(fields, null, 2)}`;
@@ -435,12 +435,17 @@ async function executeBatchTranslation(strapi2, contentType, entries, sourceLoca
435
435
  delete translatedData.localizations;
436
436
  delete translatedData.createdBy;
437
437
  delete translatedData.updatedBy;
438
- await strapi2.documents(contentType).update({
438
+ const updatedDoc = await strapi2.documents(contentType).update({
439
439
  documentId: entryId,
440
440
  locale: targetLocale,
441
- data: translatedData,
442
- status: publish ? "published" : "draft"
441
+ data: translatedData
443
442
  });
443
+ if (publish && updatedDoc) {
444
+ await strapi2.documents(contentType).publish({
445
+ documentId: entryId,
446
+ locale: targetLocale
447
+ });
448
+ }
444
449
  return {
445
450
  documentId: entryId,
446
451
  locale: targetLocale,
@@ -842,12 +847,17 @@ const controllers$1 = ({ strapi: strapi2 }) => ({
842
847
  delete translatedData.localizations;
843
848
  delete translatedData.createdBy;
844
849
  delete translatedData.updatedBy;
845
- await strapi2.documents(contentType).update({
850
+ const updatedDoc = await strapi2.documents(contentType).update({
846
851
  documentId: entryId,
847
852
  locale: targetLocale,
848
- data: translatedData,
849
- status: publish ? "published" : "draft"
853
+ data: translatedData
850
854
  });
855
+ if (publish && updatedDoc) {
856
+ await strapi2.documents(contentType).publish({
857
+ documentId: entryId,
858
+ locale: targetLocale
859
+ });
860
+ }
851
861
  return {
852
862
  documentId: entryId,
853
863
  locale: targetLocale,
@@ -1268,18 +1278,41 @@ const llmService = ({ strapi: strapi2 }) => ({
1268
1278
  }
1269
1279
  });
1270
1280
  const buildPrompt = (fields, targetLanguage) => {
1271
- return `You are translating content from a CMS. Please translate the following JSON data to ${targetLanguage}.
1281
+ return `You are translating CMS content into a specified target language.
1282
+
1283
+ Target Language:
1284
+ ${targetLanguage}
1285
+
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.
1293
+
1294
+ ---
1295
+
1296
+ TRANSLATION RULES:
1297
+
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.
1308
+
1309
+ ---
1272
1310
 
1273
- IMPORTANT RULES:
1274
- 1. Preserve all JSON structure and keys exactly as provided
1275
- 2. Only translate string values
1276
- 3. Maintain any markdown formatting within the text
1277
- 4. Keep HTML tags intact if present
1278
- 5. Preserve any special characters or placeholders
1279
- 6. Return ONLY the translated JSON object
1280
- 7. Ensure the JSON is valid and well-formed. Keep arrays and nested objects intact
1281
- 8. Do not add any explanations or comments
1282
- 9. Ensure professional and culturally appropriate translations
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
1283
1316
 
1284
1317
  SOURCE JSON:
1285
1318
  ${JSON.stringify(fields, null, 2)}`;
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.0.9",
2
+ "version": "1.1.1",
3
3
  "keywords": [
4
4
  "strapi",
5
5
  "plugin",