@payload-enchants/translator 1.1.37 → 1.1.39
Sign up to get free protection for your applications and to get access to all the features.
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"traverseFields.d.ts","sourceRoot":"","sources":["../../src/translate/traverseFields.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,KAAK,EAAc,MAAM,eAAe,CAAC;AAIvD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAEhD,eAAO,MAAM,cAAc,iIASxB;IACD,QAAQ,EAAE,OAAO,MAAM,EAAE,OAAO,CAAC,CAAC;IAClC,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,MAAM,EAAE,KAAK,EAAE,CAAC;IAChB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,eAAe,CAAC,EAAE,OAAO,MAAM,EAAE,OAAO,CAAC,CAAC;IAC1C,qBAAqB,CAAC,EAAE,OAAO,MAAM,EAAE,OAAO,CAAC,CAAC;IAChD,cAAc,EAAE,OAAO,MAAM,EAAE,OAAO,CAAC,CAAC;IACxC,iBAAiB,EAAE,gBAAgB,EAAE,CAAC;CACvC,
|
1
|
+
{"version":3,"file":"traverseFields.d.ts","sourceRoot":"","sources":["../../src/translate/traverseFields.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,KAAK,EAAc,MAAM,eAAe,CAAC;AAIvD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAEhD,eAAO,MAAM,cAAc,iIASxB;IACD,QAAQ,EAAE,OAAO,MAAM,EAAE,OAAO,CAAC,CAAC;IAClC,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,MAAM,EAAE,KAAK,EAAE,CAAC;IAChB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,eAAe,CAAC,EAAE,OAAO,MAAM,EAAE,OAAO,CAAC,CAAC;IAC1C,qBAAqB,CAAC,EAAE,OAAO,MAAM,EAAE,OAAO,CAAC,CAAC;IAChD,cAAc,EAAE,OAAO,MAAM,EAAE,OAAO,CAAC,CAAC;IACxC,iBAAiB,EAAE,gBAAgB,EAAE,CAAC;CACvC,SAyOA,CAAC"}
|
@@ -120,9 +120,9 @@ export const traverseFields = ({ dataFrom, emptyOnly, fields, localizedParent, s
|
|
120
120
|
break;
|
121
121
|
case 'text':
|
122
122
|
case 'textarea':
|
123
|
-
if (field.custom && typeof field.custom === 'object' && field.custom.translatorSkip)
|
124
|
-
if (!field.localized
|
125
|
-
if (emptyOnly && siblingDataTranslated[field.name])
|
123
|
+
if (field.custom && typeof field.custom === 'object' && field.custom.translatorSkip) break;
|
124
|
+
if (!(field.localized || localizedParent) || isEmpty(siblingDataFrom[field.name])) break;
|
125
|
+
if (emptyOnly && siblingDataTranslated[field.name]) break;
|
126
126
|
// do not translate the block ID or admin-facing label
|
127
127
|
if (field.name === 'blockName' || field.name === 'id') {
|
128
128
|
break;
|
@@ -135,8 +135,8 @@ export const traverseFields = ({ dataFrom, emptyOnly, fields, localizedParent, s
|
|
135
135
|
});
|
136
136
|
break;
|
137
137
|
case 'richText':
|
138
|
-
if (!field.localized
|
139
|
-
if (emptyOnly && siblingDataTranslated[field.name])
|
138
|
+
if (!(field.localized || localizedParent) || isEmpty(siblingDataFrom[field.name])) break;
|
139
|
+
if (emptyOnly && siblingDataTranslated[field.name]) break;
|
140
140
|
const richTextDataFrom = siblingDataFrom[field.name];
|
141
141
|
siblingDataTranslated[field.name] = richTextDataFrom;
|
142
142
|
if (!richTextDataFrom) break;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../src/translate/traverseFields.ts"],"sourcesContent":["import ObjectID from 'bson-objectid';\nimport { type Field, tabHasName } from 'payload/types';\n\nimport { isEmpty } from '../utils/isEmpty';\nimport { traverseRichText } from './traverseRichText';\nimport type { ValueToTranslate } from './types';\n\nexport const traverseFields = ({\n dataFrom,\n emptyOnly,\n fields,\n localizedParent,\n siblingDataFrom,\n siblingDataTranslated,\n translatedData,\n valuesToTranslate,\n}: {\n dataFrom: Record<string, unknown>;\n emptyOnly?: boolean;\n fields: Field[];\n localizedParent?: boolean;\n siblingDataFrom?: Record<string, unknown>;\n siblingDataTranslated?: Record<string, unknown>;\n translatedData: Record<string, unknown>;\n valuesToTranslate: ValueToTranslate[];\n}) => {\n siblingDataFrom = siblingDataFrom ?? dataFrom;\n siblingDataTranslated = siblingDataTranslated ?? translatedData;\n\n fields.forEach((field) => {\n switch (field.type) {\n case 'tabs':\n field.tabs.forEach((tab) => {\n const hasName = tabHasName(tab);\n\n const tabDataFrom = hasName\n ? (siblingDataFrom[tab.name] as Record<string, unknown>)\n : siblingDataFrom;\n\n if (!tabDataFrom) return;\n\n const tabDataTranslated = hasName\n ? (siblingDataTranslated[tab.name] as Record<string, unknown>) ?? {}\n : siblingDataTranslated;\n\n traverseFields({\n dataFrom,\n emptyOnly,\n fields: tab.fields,\n localizedParent: tab.localized,\n siblingDataFrom: tabDataFrom,\n siblingDataTranslated: tabDataTranslated,\n translatedData,\n valuesToTranslate,\n });\n });\n\n break;\n\n case 'group':\n const groupDataFrom = siblingDataFrom[field.name] as Record<string, unknown>;\n\n if (!groupDataFrom) break;\n\n const groupDataTranslated =\n (siblingDataTranslated[field.name] as Record<string, unknown>) ?? {};\n\n traverseFields({\n dataFrom,\n emptyOnly,\n fields: field.fields,\n localizedParent: field.localized,\n siblingDataFrom: groupDataFrom,\n siblingDataTranslated: groupDataTranslated,\n translatedData,\n valuesToTranslate,\n });\n\n break;\n\n case 'array':\n const arrayDataFrom = siblingDataFrom[field.name] as {\n id: string;\n }[];\n\n if (isEmpty(arrayDataFrom)) break;\n\n let arrayDataTranslated =\n (siblingDataTranslated[field.name] as { id: string }[] | undefined) ?? [];\n\n if (field.localized || localizedParent) {\n if (arrayDataTranslated.length > 0 && emptyOnly) break;\n\n arrayDataTranslated = arrayDataFrom.map(() => ({\n id: ObjectID().toHexString(),\n }));\n }\n\n arrayDataTranslated.forEach((item, index) => {\n traverseFields({\n dataFrom,\n emptyOnly,\n fields: field.fields,\n localizedParent: localizedParent ?? field.localized,\n siblingDataFrom: arrayDataFrom[index],\n siblingDataTranslated: item,\n translatedData,\n valuesToTranslate,\n });\n });\n\n siblingDataTranslated[field.name] = arrayDataTranslated;\n\n break;\n\n case 'blocks':\n const blocksDataFrom = siblingDataFrom[field.name] as { blockType: string; id: string }[];\n\n if (isEmpty(blocksDataFrom)) break;\n\n let blocksDataTranslated =\n (siblingDataTranslated[field.name] as { blockType: string; id: string }[] | undefined) ??\n [];\n\n if (field.localized || localizedParent) {\n if (blocksDataTranslated.length > 0 && emptyOnly) break;\n\n blocksDataTranslated = blocksDataFrom.map(({ blockType }) => ({\n blockType,\n id: ObjectID().toHexString(),\n }));\n }\n\n blocksDataTranslated.forEach((item, index) => {\n const block = field.blocks.find((each) => each.slug === item.blockType);\n\n if (!block) return;\n\n traverseFields({\n dataFrom,\n emptyOnly,\n fields: block.fields,\n localizedParent: localizedParent ?? field.localized,\n siblingDataFrom: blocksDataFrom[index],\n siblingDataTranslated: item,\n translatedData,\n valuesToTranslate,\n });\n });\n\n siblingDataTranslated[field.name] = blocksDataTranslated;\n\n break;\n\n case 'collapsible':\n case 'row':\n traverseFields({\n dataFrom,\n emptyOnly,\n fields: field.fields,\n localizedParent,\n siblingDataFrom,\n siblingDataTranslated,\n translatedData,\n valuesToTranslate,\n });\n break;\n\n // long ass cases here we have\n case 'date':\n case 'checkbox':\n case 'json':\n case 'code':\n case 'email':\n case 'number':\n case 'point':\n case 'radio':\n case 'relationship':\n case 'select':\n case 'upload':\n siblingDataTranslated[field.name] = siblingDataFrom[field.name];\n\n break;\n\n case 'text':\n case 'textarea':\n if (field.custom && typeof field.custom === 'object' && field.custom.translatorSkip) return;\n\n if (!field.localized && !localizedParent && isEmpty(siblingDataFrom[field.name])) return;\n if (emptyOnly && siblingDataTranslated[field.name]) return;\n\n // do not translate the block ID or admin-facing label\n if (field.name === 'blockName' || field.name === 'id') {\n break;\n }\n\n valuesToTranslate.push({\n onTranslate: (translated: string) => {\n siblingDataTranslated[field.name] = translated;\n },\n value: siblingDataFrom[field.name],\n });\n break;\n\n case 'richText':\n if (!field.localized && !localizedParent && isEmpty(siblingDataFrom[field.name])) break;\n if (emptyOnly && siblingDataTranslated[field.name]) return;\n const richTextDataFrom = siblingDataFrom[field.name] as object;\n\n siblingDataTranslated[field.name] = richTextDataFrom;\n\n if (!richTextDataFrom) break;\n\n const isSlate = Array.isArray(richTextDataFrom);\n\n const isLexical = 'root' in richTextDataFrom;\n\n if (!isSlate && !isLexical) break;\n\n if (isLexical) {\n const root = (siblingDataTranslated[field.name] as Record<string, unknown>)\n ?.root as Record<string, unknown>;\n\n if (root)\n traverseRichText({\n onText: (siblingData) => {\n valuesToTranslate.push({\n onTranslate: (translated: string) => {\n siblingData.text = translated;\n },\n value: siblingData.text,\n });\n },\n root,\n });\n } else {\n for (const root of siblingDataTranslated[field.name] as unknown[]) {\n traverseRichText({\n onText: (siblingData) => {\n valuesToTranslate.push({\n onTranslate: (translated: string) => {\n siblingData.text = translated;\n },\n value: siblingData.text,\n });\n },\n root: root as Record<string, unknown>,\n });\n }\n }\n\n break;\n\n default:\n break;\n }\n });\n};\n"],"names":["ObjectID","tabHasName","isEmpty","traverseRichText","traverseFields","dataFrom","emptyOnly","fields","localizedParent","siblingDataFrom","siblingDataTranslated","translatedData","valuesToTranslate","forEach","field","type","tabs","tab","hasName","tabDataFrom","name","tabDataTranslated","localized","groupDataFrom","groupDataTranslated","arrayDataFrom","arrayDataTranslated","length","map","id","toHexString","item","index","blocksDataFrom","blocksDataTranslated","blockType","block","blocks","find","each","slug","custom","translatorSkip","push","onTranslate","translated","value","richTextDataFrom","isSlate","Array","isArray","isLexical","root","onText","siblingData","text"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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,MAAMM,IAAI,CAAC,GAAG;gBAClF,IAAId,aAAaI,qBAAqB,CAACI,MAAMM,IAAI,CAAC,EAAE;gBACpD,MAAM2B,mBAAmBtC,eAAe,CAACK,MAAMM,IAAI,CAAC;gBAEpDV,qBAAqB,CAACI,MAAMM,IAAI,CAAC,GAAG2B;gBAEpC,IAAI,CAACA,kBAAkB;gBAEvB,MAAMC,UAAUC,MAAMC,OAAO,CAACH;gBAE9B,MAAMI,YAAY,UAAUJ;gBAE5B,IAAI,CAACC,WAAW,CAACG,WAAW;gBAE5B,IAAIA,WAAW;oBACb,MAAMC,OAAQ1C,qBAAqB,CAACI,MAAMM,IAAI,CAAC,EAC3CgC;oBAEJ,IAAIA,MACFjD,iBAAiB;wBACfkD,QAAQ,CAACC;4BACP1C,kBAAkB+B,IAAI,CAAC;gCACrBC,aAAa,CAACC;oCACZS,YAAYC,IAAI,GAAGV;gCACrB;gCACAC,OAAOQ,YAAYC,IAAI;4BACzB;wBACF;wBACAH;oBACF;gBACJ,OAAO;oBACL,KAAK,MAAMA,QAAQ1C,qBAAqB,CAACI,MAAMM,IAAI,CAAC,CAAe;wBACjEjB,iBAAiB;4BACfkD,QAAQ,CAACC;gCACP1C,kBAAkB+B,IAAI,CAAC;oCACrBC,aAAa,CAACC;wCACZS,YAAYC,IAAI,GAAGV;oCACrB;oCACAC,OAAOQ,YAAYC,IAAI;gCACzB;4BACF;4BACAH,MAAMA;wBACR;oBACF;gBACF;gBAEA;YAEF;gBACE;QACJ;IACF;AACF,EAAE"}
|
1
|
+
{"version":3,"sources":["../../src/translate/traverseFields.ts"],"sourcesContent":["import ObjectID from 'bson-objectid';\nimport { type Field, tabHasName } from 'payload/types';\n\nimport { isEmpty } from '../utils/isEmpty';\nimport { traverseRichText } from './traverseRichText';\nimport type { ValueToTranslate } from './types';\n\nexport const traverseFields = ({\n dataFrom,\n emptyOnly,\n fields,\n localizedParent,\n siblingDataFrom,\n siblingDataTranslated,\n translatedData,\n valuesToTranslate,\n}: {\n dataFrom: Record<string, unknown>;\n emptyOnly?: boolean;\n fields: Field[];\n localizedParent?: boolean;\n siblingDataFrom?: Record<string, unknown>;\n siblingDataTranslated?: Record<string, unknown>;\n translatedData: Record<string, unknown>;\n valuesToTranslate: ValueToTranslate[];\n}) => {\n siblingDataFrom = siblingDataFrom ?? dataFrom;\n siblingDataTranslated = siblingDataTranslated ?? translatedData;\n\n fields.forEach((field) => {\n switch (field.type) {\n case 'tabs':\n field.tabs.forEach((tab) => {\n const hasName = tabHasName(tab);\n\n const tabDataFrom = hasName\n ? (siblingDataFrom[tab.name] as Record<string, unknown>)\n : siblingDataFrom;\n\n if (!tabDataFrom) return;\n\n const tabDataTranslated = hasName\n ? (siblingDataTranslated[tab.name] as Record<string, unknown>) ?? {}\n : siblingDataTranslated;\n\n traverseFields({\n dataFrom,\n emptyOnly,\n fields: tab.fields,\n localizedParent: tab.localized,\n siblingDataFrom: tabDataFrom,\n siblingDataTranslated: tabDataTranslated,\n translatedData,\n valuesToTranslate,\n });\n });\n\n break;\n\n case 'group':\n const groupDataFrom = siblingDataFrom[field.name] as Record<string, unknown>;\n\n if (!groupDataFrom) break;\n\n const groupDataTranslated =\n (siblingDataTranslated[field.name] as Record<string, unknown>) ?? {};\n\n traverseFields({\n dataFrom,\n emptyOnly,\n fields: field.fields,\n localizedParent: field.localized,\n siblingDataFrom: groupDataFrom,\n siblingDataTranslated: groupDataTranslated,\n translatedData,\n valuesToTranslate,\n });\n\n break;\n\n case 'array':\n const arrayDataFrom = siblingDataFrom[field.name] as {\n id: string;\n }[];\n\n if (isEmpty(arrayDataFrom)) break;\n\n let arrayDataTranslated =\n (siblingDataTranslated[field.name] as { id: string }[] | undefined) ?? [];\n\n if (field.localized || localizedParent) {\n if (arrayDataTranslated.length > 0 && emptyOnly) break;\n\n arrayDataTranslated = arrayDataFrom.map(() => ({\n id: ObjectID().toHexString(),\n }));\n }\n\n arrayDataTranslated.forEach((item, index) => {\n traverseFields({\n dataFrom,\n emptyOnly,\n fields: field.fields,\n localizedParent: localizedParent ?? field.localized,\n siblingDataFrom: arrayDataFrom[index],\n siblingDataTranslated: item,\n translatedData,\n valuesToTranslate,\n });\n });\n\n siblingDataTranslated[field.name] = arrayDataTranslated;\n\n break;\n\n case 'blocks':\n const blocksDataFrom = siblingDataFrom[field.name] as { blockType: string; id: string }[];\n\n if (isEmpty(blocksDataFrom)) break;\n\n let blocksDataTranslated =\n (siblingDataTranslated[field.name] as { blockType: string; id: string }[] | undefined) ??\n [];\n\n if (field.localized || localizedParent) {\n if (blocksDataTranslated.length > 0 && emptyOnly) break;\n\n blocksDataTranslated = blocksDataFrom.map(({ blockType }) => ({\n blockType,\n id: ObjectID().toHexString(),\n }));\n }\n\n blocksDataTranslated.forEach((item, index) => {\n const block = field.blocks.find((each) => each.slug === item.blockType);\n\n if (!block) return;\n\n traverseFields({\n dataFrom,\n emptyOnly,\n fields: block.fields,\n localizedParent: localizedParent ?? field.localized,\n siblingDataFrom: blocksDataFrom[index],\n siblingDataTranslated: item,\n translatedData,\n valuesToTranslate,\n });\n });\n\n siblingDataTranslated[field.name] = blocksDataTranslated;\n\n break;\n\n case 'collapsible':\n case 'row':\n traverseFields({\n dataFrom,\n emptyOnly,\n fields: field.fields,\n localizedParent,\n siblingDataFrom,\n siblingDataTranslated,\n translatedData,\n valuesToTranslate,\n });\n break;\n\n // long ass cases here we have\n case 'date':\n case 'checkbox':\n case 'json':\n case 'code':\n case 'email':\n case 'number':\n case 'point':\n case 'radio':\n case 'relationship':\n case 'select':\n case 'upload':\n siblingDataTranslated[field.name] = siblingDataFrom[field.name];\n\n break;\n\n case 'text':\n case 'textarea':\n if (field.custom && typeof field.custom === 'object' && field.custom.translatorSkip) break;\n\n if (!(field.localized || localizedParent) || isEmpty(siblingDataFrom[field.name])) break;\n if (emptyOnly && siblingDataTranslated[field.name]) break;\n\n // do not translate the block ID or admin-facing label\n if (field.name === 'blockName' || field.name === 'id') {\n break;\n }\n\n valuesToTranslate.push({\n onTranslate: (translated: string) => {\n siblingDataTranslated[field.name] = translated;\n },\n value: siblingDataFrom[field.name],\n });\n break;\n\n case 'richText':\n if (!(field.localized || localizedParent) || isEmpty(siblingDataFrom[field.name])) break;\n if (emptyOnly && siblingDataTranslated[field.name]) break;\n\n const richTextDataFrom = siblingDataFrom[field.name] as object;\n\n siblingDataTranslated[field.name] = richTextDataFrom;\n\n if (!richTextDataFrom) break;\n\n const isSlate = Array.isArray(richTextDataFrom);\n\n const isLexical = 'root' in richTextDataFrom;\n\n if (!isSlate && !isLexical) break;\n\n if (isLexical) {\n const root = (siblingDataTranslated[field.name] as Record<string, unknown>)\n ?.root as Record<string, unknown>;\n\n if (root)\n traverseRichText({\n onText: (siblingData) => {\n valuesToTranslate.push({\n onTranslate: (translated: string) => {\n siblingData.text = translated;\n },\n value: siblingData.text,\n });\n },\n root,\n });\n } else {\n for (const root of siblingDataTranslated[field.name] as unknown[]) {\n traverseRichText({\n onText: (siblingData) => {\n valuesToTranslate.push({\n onTranslate: (translated: string) => {\n siblingData.text = translated;\n },\n value: siblingData.text,\n });\n },\n root: root as Record<string, unknown>,\n });\n }\n }\n\n break;\n\n default:\n break;\n }\n });\n};\n"],"names":["ObjectID","tabHasName","isEmpty","traverseRichText","traverseFields","dataFrom","emptyOnly","fields","localizedParent","siblingDataFrom","siblingDataTranslated","translatedData","valuesToTranslate","forEach","field","type","tabs","tab","hasName","tabDataFrom","name","tabDataTranslated","localized","groupDataFrom","groupDataTranslated","arrayDataFrom","arrayDataTranslated","length","map","id","toHexString","item","index","blocksDataFrom","blocksDataTranslated","blockType","block","blocks","find","each","slug","custom","translatorSkip","push","onTranslate","translated","value","richTextDataFrom","isSlate","Array","isArray","isLexical","root","onText","siblingData","text"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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