@justanarthur/payload-plugin-translator 3.3.1 → 3.3.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/client.js CHANGED
@@ -303,8 +303,7 @@ var CustomButtonWithTranslator = ({ type }) => {
303
303
  if (!id && !globalSlug)
304
304
  return /* @__PURE__ */ jsx6(DefaultButton, {});
305
305
  const { localization } = config;
306
- const isSourceLocale = Boolean(localization) && locale.code === localization.defaultLocale;
307
- if (isSourceLocale)
306
+ if (localization && locale.code === localization.defaultLocale)
308
307
  return /* @__PURE__ */ jsx6(DefaultButton, {});
309
308
  return /* @__PURE__ */ jsx6(TranslatorProvider, {
310
309
  children: /* @__PURE__ */ jsxs4("div", {
package/dist/index.js CHANGED
@@ -8,15 +8,15 @@ import {
8
8
  isTranslateMode,
9
9
  createTranslateTask2,
10
10
  createTranslateWorkflow2
11
- } from "./shared/chunk-hg50cgsw.js";
12
- import"./shared/chunk-3rz1t943.js";
11
+ } from "./shared/chunk-12hf0kdf.js";
12
+ import"./shared/chunk-pmxe5c20.js";
13
13
  import {
14
14
  readLocales,
15
15
  parseEntityKey,
16
16
  hasTranslateWorkflow,
17
17
  queueBulkTranslation,
18
18
  runQueuedTranslations
19
- } from "./shared/chunk-gd0rak8x.js";
19
+ } from "./shared/chunk-xgsxe28w.js";
20
20
  import {
21
21
  TRANSLATION_STATUS_SLUG2,
22
22
  REVIEW_VIEW_PATH
package/dist/jobs.js CHANGED
@@ -3,11 +3,11 @@ import {
3
3
  createAutoTranslateGlobalHook2,
4
4
  createTranslateTask2,
5
5
  createTranslateWorkflow2
6
- } from "./shared/chunk-hg50cgsw.js";
6
+ } from "./shared/chunk-12hf0kdf.js";
7
7
  import {
8
8
  TRANSLATE_TASK_SLUG2,
9
9
  TRANSLATE_WORKFLOW_SLUG2
10
- } from "./shared/chunk-3rz1t943.js";
10
+ } from "./shared/chunk-pmxe5c20.js";
11
11
 
12
12
  // src/exports/jobs.ts
13
13
  var jobs = {
package/dist/rsc.js CHANGED
@@ -1,11 +1,11 @@
1
- import"./shared/chunk-3rz1t943.js";
1
+ import"./shared/chunk-pmxe5c20.js";
2
2
  import {
3
3
  readLocales,
4
4
  loadCollectionReview,
5
5
  loadGlobalsReview,
6
6
  loadEntityLocaleReview,
7
7
  loadJobsProgress
8
- } from "./shared/chunk-gd0rak8x.js";
8
+ } from "./shared/chunk-xgsxe28w.js";
9
9
  import {
10
10
  REVIEW_VIEW_PATH
11
11
  } from "./shared/chunk-31qgv1zk.js";
@@ -7,7 +7,7 @@ import {
7
7
  collectTranslatableFields,
8
8
  entityKey,
9
9
  sourceHash
10
- } from "./chunk-3rz1t943.js";
10
+ } from "./chunk-pmxe5c20.js";
11
11
  import {
12
12
  TRANSLATION_STATUS_SLUG2
13
13
  } from "./chunk-31qgv1zk.js";
@@ -107,10 +107,9 @@ var translateOperation2 = async (args) => {
107
107
  payload: args.payload
108
108
  };
109
109
  const { collectionSlug, globalSlug, id, locale, localeFrom, overrideAccess } = args;
110
- const localization = req.payload.config.localization;
111
- const defaultLocale = localization ? localization.defaultLocale : undefined;
112
- if (defaultLocale && locale === defaultLocale) {
113
- throw new APIError3(`Refusing to translate into the default locale "${defaultLocale}" — it is the source of truth. Translate from it into a target locale instead.`, 400);
110
+ const { localization } = req.payload.config;
111
+ if (localization && locale === localization.defaultLocale) {
112
+ throw new APIError3(`Refusing to translate into the default locale "${localization.defaultLocale}" — it is the source of truth. Translate from it into a target locale instead.`, 400);
114
113
  }
115
114
  const { config, doc: dataFrom } = await findEntityWithConfig({
116
115
  collectionSlug,
@@ -157,6 +157,7 @@ var buildLocalizedRows = (from, existing, isBlocks, emptyOnly) => {
157
157
  return from.map((row, index) => {
158
158
  const previous = existing[index] && (!isBlocks || existing[index].blockType === row.blockType) ? existing[index] : undefined;
159
159
  return {
160
+ ...structuredClone(row),
160
161
  ...previous ?? {},
161
162
  id: previous?.id ?? ObjectID().toHexString(),
162
163
  ...isBlocks ? { blockType: row.blockType, blockName: row.blockName ?? previous?.blockName } : {}
@@ -377,8 +378,12 @@ var traverseFields = (args) => {
377
378
  const current = siblingDataTranslated[field.name];
378
379
  const richTextPath = joinPath(path, field.name);
379
380
  onField?.({ path: richTextPath, type: "richText", source: richTextDataFrom, target: current });
380
- if (!richTextDataFrom || !hasText(richTextDataFrom))
381
+ if (!richTextDataFrom || !hasText(richTextDataFrom)) {
382
+ if (richTextDataFrom && current === undefined) {
383
+ siblingDataTranslated[field.name] = structuredClone(richTextDataFrom);
384
+ }
381
385
  break;
386
+ }
382
387
  if (keepsTarget(richTextDataFrom, current))
383
388
  break;
384
389
  const isSlate = Array.isArray(richTextDataFrom);
@@ -7,7 +7,7 @@ import {
7
7
  collectTranslatableFields,
8
8
  entityKey,
9
9
  sourceHash
10
- } from "./chunk-3rz1t943.js";
10
+ } from "./chunk-pmxe5c20.js";
11
11
  import {
12
12
  TRANSLATION_STATUS_SLUG2
13
13
  } from "./chunk-31qgv1zk.js";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@justanarthur/payload-plugin-translator",
3
3
  "description": "Translator plugin for Payload CMS — automatic localization via Google, OpenAI, LibreTranslate, or custom resolvers.",
4
- "version": "3.3.1",
4
+ "version": "3.3.3",
5
5
  "type": "module",
6
6
  "private": false,
7
7
  "files": [