Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure all Paragraph types are translatable #739

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

dipakmdhrm
Copy link
Collaborator

@dipakmdhrm dipakmdhrm commented Oct 24, 2024

#738

Update

  • Make all paragraphs types translatable
  • Add hook to make all paragraphs types translatable on creation.
  • Add form alter to enable translations for new paragraphs.

@dipakmdhrm
Copy link
Collaborator Author

Add hook to make all paragraphs types translatable on creation.

This is slightly complicated. This means we'll have to do the following:

  • Enable translations for a paragraph bundle on its creation i.e. when it has no fields.
  • Possibly enable translations for the field on its creation.

While looking into this I came across the following error when trying to manually enable translations for a node type with no fields:

At least one field needs to be translatable to enable %bundle for translation

The code in content_translation_form_language_content_settings_validate doesn't describe why this is needed.
I am looking into whether this is a 'common sense' error or if something can go wrong if the translation is enabled for a bundle without making any field on it translatable.

@amitaibu
Copy link
Member

If the hooks are complex, we can skip it -- and only form alter the form, so the checkbox is checked and disabled.

Possibly enable translations for the field on its creation.

We should prevent that.

https://www.drupal.org/docs/contributed-modules/paragraphs/multilingual-paragraphs-configuration

This field must not be translatable, so avoid checking the "Users may translate this field" checkbox.

@dipakmdhrm
Copy link
Collaborator Author

Added form alter to enable translations for new paragraphs.

Before After
tmp tmp2

@dipakmdhrm dipakmdhrm requested a review from amitaibu November 13, 2024 09:30
@dipakmdhrm dipakmdhrm force-pushed the translatable-paragraphs branch from 99918ac to 8d4b7ba Compare November 13, 2024 09:33
@amitaibu
Copy link
Member

amitaibu commented Nov 13, 2024

What is the page shown in #739 (comment) - field translation ? Is it correct? Shouldn't we not translate those fields?

@dipakmdhrm dipakmdhrm changed the title WIP: Ensure all Paragraph types are translatable Ensure all Paragraph types are translatable Nov 13, 2024
@dipakmdhrm
Copy link
Collaborator Author

What is the page shown in #739 (comment) - field translation ? Is it correct? Shouldn't we not translate those fields?

@amitaibu According to the drupal.org documentation, we shouldn't translate the paragraph reference fields, but we should translate other fields. I've added the form alter to do the same.

@amitaibu
Copy link
Member

Thanks. Ready for review? Needs a re-roll

@dipakmdhrm dipakmdhrm force-pushed the translatable-paragraphs branch from d9b9633 to 35920bb Compare November 18, 2024 12:47
@dipakmdhrm
Copy link
Collaborator Author

Thanks. Ready for review? Needs a re-roll

Done. This is ready for review.

@amitaibu
Copy link
Member

Thanks, Please indicate how to QA

@dipakmdhrm
Copy link
Collaborator Author

Testing instructions

Make all paragraphs types translatable

Navigate to /config/regional/content-language. All paragraphs (except search) should already be translatable.

Let's add a hook that, upon creating a new Paragraph type, forces it to be translatable.

  1. Create a new paragraph type and add the following fields to it:
    1.1. Text field
    1.2. Term reference field
    1.3. Content reference field
    1.4. Paragraph reference field
  2. Navigate to /config/regional/content-language.
    2.1. The checkbox to make this new paragraph type should already be checked.
    2.2. The following should be unchecked for this new paragraph type:
    2.2.1. Checkbox to make 'Published' translatable
    2.2.2. Checkbox to make 'Authored on' translatable
    2.2.3. Checkbox to make paragraph reference field translatable.
    2.3. The following should be checked for this new paragraph type:
    2.3.1. Checkbox to make the text field translatable.
    2.3.2. Checkbox to make the term reference field translatable.
    2.3.3. Checkbox to make the content reference field translatable.

@amitaibu
Copy link
Member

@aleksbelousovqa please test this. You can create a new Drupal-starter instance by going to https://github.com/Gizra/drupal-starter/pull/739/files and clicking here and creating a new Codespace.

image

Once the installation is complete (takes about 10 minutes), you can use ddev login to log in to the site as admin user using your default browser.

@aleksbelousovqa
Copy link

/admin/config/regional/content-language

QA Review

Found issues and questions

1 Paragraph reference checkbox expected to be unchecked

image

Checked and approved

1 The rest settings look fine

new paragraph and fields checkboxes
image image

@amitaibu
Copy link
Member

@dipakmdhrm ^^

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants