Skip Navigation

This thread is resolved. Here is a description of the problem and solution.

Problem:
The client has a custom Gutenberg block with a heading attribute and content. The heading translates correctly when there are no nested blocks, but fails to do so when nested blocks are present, with only the nested blocks being translated.
Solution:
We resolved the issue by registering the custom blocks for translation. Here are the steps we recommend you follow:
1- Navigate to WPML-> Settings-> Custom XML tab.
2- Add the following code:

<wpml-config><gutenberg-blocks><gutenberg-block type="ssw/introduction-block" translate="1"><xpath>//h2</xpath></gutenberg-block><gutenberg-block type="ssw/anchor-section" translate="1"><xpath>//h2</xpath><key name="anchorTitle"></key></gutenberg-block><gutenberg-block type="ssw/anchor-content" translate="1"><xpath>//div/ul/li/a</xpath></gutenberg-block><gutenberg-block type="ssw/section" translate="1"><xpath>//h2</xpath></gutenberg-block><gutenberg-block type="ssw/posts-carousel" translate="1"><key name="ctaLabel"></key></gutenberg-block></gutenberg-blocks></wpml-config>

3- Save the changes.
4- Edit the page in the default language.
5- Click the Update button.
6- Update the translation using the translation editor.
For more information on registering blocks for translation, please check this guide.

If this solution does not apply to your case, or if it seems outdated, we highly recommend checking related known issues at https://wpml.org/known-issues/, verifying the version of the permanent fix, and confirming that you have installed the latest versions of themes and plugins. If the issue persists, please open a new support ticket.

This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

This topic contains 2 replies, has 2 voices.

Last updated by Osama Mersal 3 months, 1 week ago.

Assisted by: Osama Mersal.

Author Posts
August 5, 2024 at 1:00 pm #16040108

davidH-179

Background of the issue:
I have a custom Gutenberg block which has the heading attribute and content. So the heading translates correctly when there are no nested blocks, but fails to do so when nested blocks are present (only nested blocks are translated)

Password for this page is: cqc7kdy9ayz*mcu-TBA
hidden link

Symptoms:

Questions:

August 5, 2024 at 3:01 pm #16040888

Osama Mersal
Supporter

Languages: English (English ) Arabic (العربية )

Timezone: Africa/Cairo (GMT+02:00)

Hi,

1) I would need to look closely at your site, so I would need to request temporary access (WP-Admin and FTP)
Preferably to a test site where the problem has been replicated.

Your answer will be private, meaning only you and I can access it.

❌ Please backup your database and website ❌

✙ I need your permission to deactivate and reactivate the plugins and themes and change site configurations. This is also why the backup is critical.

✙ I also need your permission to take a local copy of your site to debug the issue without affecting your live site.

2) It's not related to the issue, but according to your Debug.info, the WP memory limit needs to be increased. PHP memory is fine, but WordPress uses 40Mb as default. The minimum requirements for WPML are 128 MB. (Kindly check this page https://wpml.org/home/minimum-requirements/)

You can increase it by adding the following code in your wp-config.php file right before the /* That's all, stop editing! Happy publishing. */ line:

/* Memory Limit */
define('WP_MEMORY_LIMIT', '256M');
define( 'WP_MAX_MEMORY_LIMIT', '256M');

Best regards,
Osama

August 6, 2024 at 11:01 am #16043562

Osama Mersal
Supporter

Languages: English (English ) Arabic (العربية )

Timezone: Africa/Cairo (GMT+02:00)

Hi,

Thanks for the access details. I checked the issue and was able to fix it by registering your custom blocks for translation. Kindly check the following steps:

1- Go to WPML-> Settings-> Custom XML tab
2- Add the following code

<wpml-config>
  <gutenberg-blocks>
    <gutenberg-block type="ssw/introduction-block" translate="1">
      <xpath>//h2</xpath>
    </gutenberg-block>
    <gutenberg-block type="ssw/anchor-section" translate="1">
      <xpath>//h2</xpath>
      <key name="anchorTitle" />
    </gutenberg-block>
    <gutenberg-block type="ssw/anchor-content" translate="1">
      <xpath>//div/ul/li/a</xpath>
    </gutenberg-block>
    <gutenberg-block type="ssw/section" translate="1">
      <xpath>//h2</xpath>
    </gutenberg-block>
    <gutenberg-block type="ssw/posts-carousel" translate="1">
      <key name="ctaLabel" />
    </gutenberg-block>
  </gutenberg-blocks>
</wpml-config>

3- Save
4- Edit the page in the default language
5- Click the Update button
6- Update the translation using the translation editor

Kindly check this guide to know more about registering blocks for translation.

Please check if the hidden link">translated page works correctly.

Best regards,
Osama