How do you properly enable multilingual support

Created on 31 May 2025, 3 days ago

Problem/Motivation

I have a 3 column component that I am trying to simplify significantly.

It's structure is less than ideal.

Parent paragraph has an entity reference revision field referencing a paragraph called Image Text.

The image text paragraph has two fields, one that references a paragraph called image that just has a media image reference, and one that references a paragraph called text that has a text field.

The nesting was an attempt to keep modularity, but is no longer necessary.

The new ultimate structure is a Custom field with a media library subfield and a text subfield.

You cannot use this module to move nested paragraphs like this so here is what I did.
I created a new field_text and field_media_library on the image text paragraph and configured two migrations one for each sub paragraph field.

I then created a migration that moved the content from those fields to the custom field.

Then I created two update hooks, one that ran the first media field and text field level migration.
Then the second update hook moved the new fields to the final custom field.

I've tried a couple of ways, but I've not gotten the right results.
The first time:
After running the update hooks I found that the default language had all translations and all translations were empty.
I realized that while I had made the custom field translateable, I had forgotten to make the intermediary fields translatable.

The second time all fields were translateable.
This time I found that some content was duplicated on english, spanish still did not get any translations.

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

πŸ’¬ Support request
Status

Active

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States nicxvan

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @nicxvan
  • πŸ‡ΊπŸ‡ΈUnited States apmsooner

    Is that 3 levels of paragraphs it sounds like? You're on the right track with starting from deepest and working you're way up. If the paragraphs and their fields are indeed translated, it should just technically work from the testing that I've done. Maybe you could bullet point the hierarchy and field structure so I could understand better? And if you wanted to attach the updater configs that might be helpful.

  • πŸ‡ΊπŸ‡ΈUnited States apmsooner

    FYI, I'm gonna try to add drush commands this wknd similar to custom_field for this module so it will be easier to test this out locally without having to run update hooks.

  • πŸ‡ΊπŸ‡ΈUnited States nicxvan

    Sure!

    Here is the structure:

    • Level 1: Three column component
      • Level 2: Image Text Paragraph
        • Level 3a: Image Paragraph -> Media reference
        • Level 3b: Text Paragraph -> Text field (yes I know this is redundant)

    So I created two new fields on level 2 one for a media reference, one for a text field. Both translateable.
    I wrote migration 1 from level 3a to the media reference on level 2.
    I wrote migration 2 from level 3b to the text field on level 2.

    I created new custom field with media and text translateable.
    I wrote migration 3 from level 2 media field to custom field media and level 2 text field to custom field text.

    This migrated only the english.

  • πŸ‡ΊπŸ‡ΈUnited States apmsooner

    Are 3a & 3b referenced from the same field on level 2? Its a single field that references both types right? If so, You should be able to just create the custom field on level 2 which in this case the target type is gonna be the paragraph and bundle on level 2 and then the source field would be the paragraphs field and you would check both bundles. The mapping would be relevant to the fields on those paragraphs. The only thing im not sure of around translations is the way paragraphs module handles these in child levels. It gets a little weird with paragraphs and multilingual from my experience.

  • πŸ‡ΊπŸ‡ΈUnited States nicxvan

    Level 2 has separate fields for each one.

    I think for this case it's better to write something custom.

    I'll likely use this module for most other moves since they are almost all just a single level transition.

    This module is super impressive!

Production build 0.71.5 2024