@pigment/auto-translate 1.3.2 → 1.3.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.
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
export const getTranslationExclusionsCollection = (slug = 'translation-exclusions')=>({
|
|
2
2
|
slug,
|
|
3
3
|
access: {
|
|
4
|
-
create: ()=>
|
|
5
|
-
delete: ()=>
|
|
6
|
-
read: ()=>
|
|
7
|
-
update: ()=>
|
|
4
|
+
create: ({ req: { user } })=>Boolean(user),
|
|
5
|
+
delete: ({ req: { user } })=>Boolean(user),
|
|
6
|
+
read: ({ req: { user } })=>Boolean(user),
|
|
7
|
+
update: ({ req: { user } })=>Boolean(user)
|
|
8
8
|
},
|
|
9
9
|
admin: {
|
|
10
10
|
defaultColumns: [
|
|
@@ -14,7 +14,7 @@ export const getTranslationExclusionsCollection = (slug = 'translation-exclusion
|
|
|
14
14
|
'excludedPaths'
|
|
15
15
|
],
|
|
16
16
|
description: 'Stores field-level translation exclusions per document and locale. Each locale can have its own set of excluded fields. There should only be ONE record per (collectionSlug, documentId, locale) combination.',
|
|
17
|
-
group: 'Settings',
|
|
17
|
+
group: 'Auto-Translate Settings',
|
|
18
18
|
useAsTitle: 'collectionSlug'
|
|
19
19
|
},
|
|
20
20
|
fields: [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/collections/translationExclusions.ts"],"sourcesContent":["import type { CollectionConfig } from 'payload'\n\nexport const getTranslationExclusionsCollection = (\n slug: string = 'translation-exclusions',\n): CollectionConfig => ({\n slug,\n access: {\n create: () =>
|
|
1
|
+
{"version":3,"sources":["../../src/collections/translationExclusions.ts"],"sourcesContent":["import type { CollectionConfig } from 'payload'\n\nexport const getTranslationExclusionsCollection = (\n slug: string = 'translation-exclusions',\n): CollectionConfig => ({\n slug,\n access: {\n create: ({ req: { user } }) => Boolean(user),\n delete: ({ req: { user } }) => Boolean(user),\n read: ({ req: { user } }) => Boolean(user),\n update: ({ req: { user } }) => Boolean(user),\n },\n admin: {\n defaultColumns: ['collectionSlug', 'documentId', 'locale', 'excludedPaths'],\n description:\n 'Stores field-level translation exclusions per document and locale. Each locale can have its own set of excluded fields. There should only be ONE record per (collectionSlug, documentId, locale) combination.',\n group: 'Auto-Translate Settings',\n useAsTitle: 'collectionSlug',\n },\n fields: [\n {\n name: 'collectionSlug',\n type: 'text',\n admin: {\n description: 'The collection this exclusion belongs to',\n position: 'sidebar',\n readOnly: true,\n },\n index: true,\n required: true,\n },\n {\n name: 'documentId',\n type: 'text',\n admin: {\n description: 'The ID of the document',\n position: 'sidebar',\n readOnly: true,\n },\n index: true,\n required: true,\n },\n {\n name: 'locale',\n type: 'text',\n admin: {\n description: 'The locale these exclusions apply to (e.g., \"en\", \"de\", \"fr\")',\n position: 'sidebar',\n readOnly: true,\n },\n index: true,\n label: 'Locale',\n required: true,\n },\n {\n name: 'excludedPaths',\n type: 'array',\n admin: {\n description:\n 'Fields that should NOT be auto-translated in this specific locale. Each locale has its own independent set of exclusions.',\n },\n fields: [\n {\n name: 'path',\n type: 'text',\n admin: {\n description: 'Field path (e.g., \"title\", \"content.0.description\")',\n },\n label: 'Field Path',\n required: true,\n },\n ],\n label: `Excluded Fields for this Locale`,\n required: true,\n },\n ],\n})\n"],"names":["getTranslationExclusionsCollection","slug","access","create","req","user","Boolean","delete","read","update","admin","defaultColumns","description","group","useAsTitle","fields","name","type","position","readOnly","index","required","label"],"mappings":"AAEA,OAAO,MAAMA,qCAAqC,CAChDC,OAAe,wBAAwB,GACjB,CAAA;QACtBA;QACAC,QAAQ;YACNC,QAAQ,CAAC,EAAEC,KAAK,EAAEC,IAAI,EAAE,EAAE,GAAKC,QAAQD;YACvCE,QAAQ,CAAC,EAAEH,KAAK,EAAEC,IAAI,EAAE,EAAE,GAAKC,QAAQD;YACvCG,MAAM,CAAC,EAAEJ,KAAK,EAAEC,IAAI,EAAE,EAAE,GAAKC,QAAQD;YACrCI,QAAQ,CAAC,EAAEL,KAAK,EAAEC,IAAI,EAAE,EAAE,GAAKC,QAAQD;QACzC;QACAK,OAAO;YACLC,gBAAgB;gBAAC;gBAAkB;gBAAc;gBAAU;aAAgB;YAC3EC,aACE;YACFC,OAAO;YACPC,YAAY;QACd;QACAC,QAAQ;YACN;gBACEC,MAAM;gBACNC,MAAM;gBACNP,OAAO;oBACLE,aAAa;oBACbM,UAAU;oBACVC,UAAU;gBACZ;gBACAC,OAAO;gBACPC,UAAU;YACZ;YACA;gBACEL,MAAM;gBACNC,MAAM;gBACNP,OAAO;oBACLE,aAAa;oBACbM,UAAU;oBACVC,UAAU;gBACZ;gBACAC,OAAO;gBACPC,UAAU;YACZ;YACA;gBACEL,MAAM;gBACNC,MAAM;gBACNP,OAAO;oBACLE,aAAa;oBACbM,UAAU;oBACVC,UAAU;gBACZ;gBACAC,OAAO;gBACPE,OAAO;gBACPD,UAAU;YACZ;YACA;gBACEL,MAAM;gBACNC,MAAM;gBACNP,OAAO;oBACLE,aACE;gBACJ;gBACAG,QAAQ;oBACN;wBACEC,MAAM;wBACNC,MAAM;wBACNP,OAAO;4BACLE,aAAa;wBACf;wBACAU,OAAO;wBACPD,UAAU;oBACZ;iBACD;gBACDC,OAAO,CAAC,+BAA+B,CAAC;gBACxCD,UAAU;YACZ;SACD;IACH,CAAA,EAAE"}
|
|
@@ -1,14 +1,8 @@
|
|
|
1
1
|
export const getTranslationSettingsGlobal = (slug = 'translation-settings')=>({
|
|
2
2
|
slug,
|
|
3
|
-
access: {
|
|
4
|
-
read: ()=>true,
|
|
5
|
-
update: ()=>{
|
|
6
|
-
// Only admins can update translation settings
|
|
7
|
-
return true;
|
|
8
|
-
}
|
|
9
|
-
},
|
|
10
3
|
admin: {
|
|
11
|
-
description: 'Configure translation settings including the system prompt and model parameters'
|
|
4
|
+
description: 'Configure translation settings including the system prompt and model parameters',
|
|
5
|
+
group: 'Auto-Translate Settings'
|
|
12
6
|
},
|
|
13
7
|
fields: [
|
|
14
8
|
{
|
|
@@ -19,8 +13,7 @@ export const getTranslationSettingsGlobal = (slug = 'translation-settings')=>({
|
|
|
19
13
|
Field: '@pigment/auto-translate/client#LockTranslation'
|
|
20
14
|
},
|
|
21
15
|
position: 'sidebar'
|
|
22
|
-
}
|
|
23
|
-
custom: {}
|
|
16
|
+
}
|
|
24
17
|
},
|
|
25
18
|
{
|
|
26
19
|
name: 'lockTranslationSettings',
|
|
@@ -61,12 +54,12 @@ export const getTranslationSettingsGlobal = (slug = 'translation-settings')=>({
|
|
|
61
54
|
rows: 8
|
|
62
55
|
},
|
|
63
56
|
defaultValue: `Rules:
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
57
|
+
- Only translate the values, never the keys
|
|
58
|
+
- Preserve the exact JSON structure
|
|
59
|
+
- Do not translate field names like 'id', 'createdAt', 'updatedAt', etc.
|
|
60
|
+
- Maintain formatting, HTML tags, and special characters
|
|
61
|
+
- Return only valid JSON without any markdown formatting or code blocks
|
|
62
|
+
- If a value is already in the target language or is a proper noun, keep it as is`,
|
|
70
63
|
label: 'Translation Rules',
|
|
71
64
|
required: true
|
|
72
65
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/globals/translationSettings.ts"],"sourcesContent":["import type { GlobalConfig } from 'payload'\n\nexport const getTranslationSettingsGlobal = (\n slug: string = 'translation-settings',\n): GlobalConfig => ({\n slug,\n
|
|
1
|
+
{"version":3,"sources":["../../src/globals/translationSettings.ts"],"sourcesContent":["import type { GlobalConfig } from 'payload'\n\nexport const getTranslationSettingsGlobal = (\n slug: string = 'translation-settings',\n): GlobalConfig => ({\n slug,\n admin: {\n description: 'Configure translation settings including the system prompt and model parameters',\n group: 'Auto-Translate Settings',\n },\n fields: [\n {\n name: 'settingsLock',\n type: 'ui',\n admin: {\n components: {\n Field: '@pigment/auto-translate/client#LockTranslation',\n },\n position: 'sidebar',\n },\n },\n {\n name: 'lockTranslationSettings',\n type: 'checkbox',\n admin: {\n hidden: true,\n },\n defaultValue: true,\n },\n {\n name: 'systemPrompt',\n type: 'textarea',\n access: {\n read: () => true,\n update: ({ data }) => {\n return !data?.lockTranslationSettings\n },\n },\n admin: {\n description:\n 'The main instruction for the AI translator. Use {fromLocale} and {toLocale} as placeholders.',\n rows: 3,\n },\n defaultValue: `You are a professional translator. Translate the JSON object values from {fromLocale} to {toLocale}.`,\n label: 'System Prompt',\n required: true,\n },\n {\n name: 'translationRules',\n type: 'textarea',\n access: {\n read: () => true,\n update: ({ data }) => {\n return !data?.lockTranslationSettings\n },\n },\n admin: {\n description:\n \"⚠️ Do not edit if you don't know what you are doing. These rules ensure proper JSON translation behavior.\",\n rows: 8,\n },\n defaultValue: `Rules:\n- Only translate the values, never the keys\n- Preserve the exact JSON structure\n- Do not translate field names like 'id', 'createdAt', 'updatedAt', etc.\n- Maintain formatting, HTML tags, and special characters\n- Return only valid JSON without any markdown formatting or code blocks\n- If a value is already in the target language or is a proper noun, keep it as is`,\n label: 'Translation Rules',\n required: true,\n },\n {\n name: 'model',\n type: 'text',\n access: {\n read: () => true,\n update: ({ data }) => {\n return !data?.lockTranslationSettings\n },\n },\n admin: {\n description: 'The OpenAI model to use for translations (e.g., gpt-4o, gpt-4o-mini)',\n },\n defaultValue: 'gpt-4o',\n label: 'Model',\n required: true,\n },\n {\n name: 'temperature',\n type: 'number',\n access: {\n read: () => true,\n update: ({ data }) => {\n return !data?.lockTranslationSettings\n },\n },\n admin: {\n description:\n 'Controls randomness in translation (0.0-2.0). Lower values are more deterministic.',\n step: 0.1,\n },\n defaultValue: 0.3,\n label: 'Temperature',\n max: 2,\n min: 0,\n required: true,\n },\n {\n name: 'maxTokens',\n type: 'number',\n access: {\n read: () => true,\n update: ({ data }) => {\n return !data?.lockTranslationSettings\n },\n },\n admin: {\n description: 'Maximum tokens for the response. Leave empty for automatic.',\n },\n label: 'Max Tokens',\n min: 1,\n },\n ],\n hooks: {\n afterChange: [\n async ({ data, req }) => {\n if (!data?.lockTranslationSettings) {\n const result = await req.payload.updateGlobal({\n slug: 'translation-settings',\n data: { lockTranslationSettings: true },\n req,\n })\n\n return result\n }\n },\n ],\n },\n label: 'Translation Settings',\n})\n"],"names":["getTranslationSettingsGlobal","slug","admin","description","group","fields","name","type","components","Field","position","hidden","defaultValue","access","read","update","data","lockTranslationSettings","rows","label","required","step","max","min","hooks","afterChange","req","result","payload","updateGlobal"],"mappings":"AAEA,OAAO,MAAMA,+BAA+B,CAC1CC,OAAe,sBAAsB,GACnB,CAAA;QAClBA;QACAC,OAAO;YACLC,aAAa;YACbC,OAAO;QACT;QACAC,QAAQ;YACN;gBACEC,MAAM;gBACNC,MAAM;gBACNL,OAAO;oBACLM,YAAY;wBACVC,OAAO;oBACT;oBACAC,UAAU;gBACZ;YACF;YACA;gBACEJ,MAAM;gBACNC,MAAM;gBACNL,OAAO;oBACLS,QAAQ;gBACV;gBACAC,cAAc;YAChB;YACA;gBACEN,MAAM;gBACNC,MAAM;gBACNM,QAAQ;oBACNC,MAAM,IAAM;oBACZC,QAAQ,CAAC,EAAEC,IAAI,EAAE;wBACf,OAAO,CAACA,MAAMC;oBAChB;gBACF;gBACAf,OAAO;oBACLC,aACE;oBACFe,MAAM;gBACR;gBACAN,cAAc,CAAC,oGAAoG,CAAC;gBACpHO,OAAO;gBACPC,UAAU;YACZ;YACA;gBACEd,MAAM;gBACNC,MAAM;gBACNM,QAAQ;oBACNC,MAAM,IAAM;oBACZC,QAAQ,CAAC,EAAEC,IAAI,EAAE;wBACf,OAAO,CAACA,MAAMC;oBAChB;gBACF;gBACAf,OAAO;oBACLC,aACE;oBACFe,MAAM;gBACR;gBACAN,cAAc,CAAC;;;;;;iFAM4D,CAAC;gBAC5EO,OAAO;gBACPC,UAAU;YACZ;YACA;gBACEd,MAAM;gBACNC,MAAM;gBACNM,QAAQ;oBACNC,MAAM,IAAM;oBACZC,QAAQ,CAAC,EAAEC,IAAI,EAAE;wBACf,OAAO,CAACA,MAAMC;oBAChB;gBACF;gBACAf,OAAO;oBACLC,aAAa;gBACf;gBACAS,cAAc;gBACdO,OAAO;gBACPC,UAAU;YACZ;YACA;gBACEd,MAAM;gBACNC,MAAM;gBACNM,QAAQ;oBACNC,MAAM,IAAM;oBACZC,QAAQ,CAAC,EAAEC,IAAI,EAAE;wBACf,OAAO,CAACA,MAAMC;oBAChB;gBACF;gBACAf,OAAO;oBACLC,aACE;oBACFkB,MAAM;gBACR;gBACAT,cAAc;gBACdO,OAAO;gBACPG,KAAK;gBACLC,KAAK;gBACLH,UAAU;YACZ;YACA;gBACEd,MAAM;gBACNC,MAAM;gBACNM,QAAQ;oBACNC,MAAM,IAAM;oBACZC,QAAQ,CAAC,EAAEC,IAAI,EAAE;wBACf,OAAO,CAACA,MAAMC;oBAChB;gBACF;gBACAf,OAAO;oBACLC,aAAa;gBACf;gBACAgB,OAAO;gBACPI,KAAK;YACP;SACD;QACDC,OAAO;YACLC,aAAa;gBACX,OAAO,EAAET,IAAI,EAAEU,GAAG,EAAE;oBAClB,IAAI,CAACV,MAAMC,yBAAyB;wBAClC,MAAMU,SAAS,MAAMD,IAAIE,OAAO,CAACC,YAAY,CAAC;4BAC5C5B,MAAM;4BACNe,MAAM;gCAAEC,yBAAyB;4BAAK;4BACtCS;wBACF;wBAEA,OAAOC;oBACT;gBACF;aACD;QACH;QACAR,OAAO;IACT,CAAA,EAAE"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pigment/auto-translate",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.4",
|
|
4
4
|
"description": "Automatic translation plugin for Payload CMS with field-level exclusion controls and performance optimizations",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"payload",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"homepage": "https://pigment.se",
|
|
22
22
|
"repository": {
|
|
23
23
|
"type": "git",
|
|
24
|
-
"url": "https://github.com/
|
|
24
|
+
"url": "https://github.com/pigmentab/auto-translate"
|
|
25
25
|
},
|
|
26
26
|
"license": "MIT",
|
|
27
27
|
"type": "module",
|