Fekide / strapi-plugin-translate

Strapi plugin for automated translations using different Translate Providers
https://market.strapi.io/plugins/strapi-plugin-translate
MIT License
42 stars 16 forks source link

[BUG]: Translating with nested components containing JSON field does not work. #403

Open Discountrobot opened 2 months ago

Discountrobot commented 2 months ago

Describe the bug When you have a entity with a repeatable component, that itself contains the JSON field type, translation will fail to save - even if the component is marked as non-translatable.

To Reproduce

  1. create a reusable component with a json field Screenshot 2024-05-02 at 14 44 25

  2. create a entity that uses the reusable compoinent

  3. fill out the original entity

  4. create a new locale

  5. try to translate the entity after saving.

  6. observe the following error

TypeError: (i.doc || "").split is not a function
    at na.create (main.1c8cf574.js:3702:27812)
    at main.1c8cf574.js:3711:66977
    at Li (main.1c8cf574.js:1102:25330)
    at Kf (main.1c8cf574.js:1102:44207)
    at mh (main.1c8cf574.js:1102:42943)
    at Vf (main.1c8cf574.js:1102:41960)
    at d4 (main.1c8cf574.js:1102:38431)
    at Hl (main.1c8cf574.js:1100:3311)
    at main.1c8cf574.js:1102:35725

Expected behavior

It looks like it is an issue with mapping to the component structure, naturally the translation should succeed.

Screenshots If applicable, add screenshots to help explain your problem.

System (please complete the following information):

Plugin config Please add your plugin config here, e.g.

module.exports = {
  translate: {
    enabled: true,
    config: {
      // Choose one of the available providers
      provider: "deepl",
      // Pass credentials and other options to the provider
      providerOptions: {
        // use custom locale mapping (for example 'en' locale is deprecated so need to choose between 'EN-GB' and 'EN-US')
        localeMap: {
          // use uppercase here!
          EN: "EN-US",
        },
        apiOptions: {
          formality: "default",
        },
      },
      translatedFieldTypes: [
        "string",
        { type: "json", format: "plain" },
        { type: "text", format: "plain" },
        { type: "richtext", format: "markdown" },
        "component",
        "dynamiczone",
      ],
      translateRelations: true,
    },
}

Additional context Add any other context about the problem here.