Skip Navigation

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

Problem:
The client was experiencing an issue where links in automatically translated pages were not converting to contain the other language slug. Instead, links remained pointing to the English pages even when switching languages.
Solution:
We identified that the client was using a widget from an Gutenberg add-on. To resolve this, we manually registered the widget for translation by creating a custom XML configuration file. We followed the instructions provided on the WPML documentation page: https://wpml.org/documentation/support/language-configuration-files/make-custom-gutenberg-blocks-translatable/
Additionally, we modified the XML configuration using the xpath method to allow manual translation of the links.

<wpml-config>
<gutenberg-blocks>
<gutenberg-block type="greenshift-blocks/buttonbox" translate="1">
<xpath type="link">//a/@href</xpath>
<xpath>//span</xpath>
</gutenberg-block>
</gutenberg-blocks>
</wpml-config>

If this solution does not resolve your issue or seems outdated, we 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 problem persists, please open a new support ticket for further assistance.

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 12 replies, has 2 voices.

Last updated by Nicolas V. 2 months, 2 weeks ago.

Assisted by: Nicolas V..

Author Posts
September 2, 2024 at 4:13 pm #16132858

basselS-2

Background of the issue:
I remember the first time I translated a page automatically, every link was converted to contain the other language slug. After that, the links only contained the English translation when I am in the other language pages.

Symptoms:
Links in my pages are not converted automatically to contain the other language slug. For example, when I switch to the other language, the links are still pointing to the English pages.

Questions:
Why are the links not converting to the other language slug automatically?
How can I ensure that links point to the correct language pages when switching languages?

September 2, 2024 at 4:16 pm #16132870

basselS-2

While proceeding in opening this ticket, I received two issues to be resolved:
1- Fluent Forms: I ignored this issue for now because it's note related and I had a workaround by creating a form for each language.
2- Minimum memory limit: I do not know how to edit the file mentioned, and I am not sure this is the causing issue either.

September 2, 2024 at 4:54 pm #16132961

Nicolas V.
Supporter

Languages: English (English ) French (Français )

Timezone: America/Lima (GMT-05:00)

Hello,

Welcome to the WPML support forum.

WPML should automatically translate your internal links. Please check the following:
1. Ensure that you are using absolute links (and not relative links) on the original page (e.g. hidden link instead of /contact).
2. The linked page must be translated already. In my example, the "Contact" page needs to be translated, otherwise WPML convert the link.
If you translated the linked page afterward, go to "WPML > Settings > Translate Link Targets" to scan and adjust your links.

If that doesn't resolve the issue, could you please provide me with more details:
- How did you insert the link on the original page? Is it a normal content link inserted in a paragraph?
- Can you share an URL where I can see the issue (a page where links weren't translated)?

---

Regarding the PHP memory allocation, while it may not be directly related to the issue, it could impact your translations. Here's how to increase it:
- Access your server via FTP and open wp-config.php (in your WordPress root directory).
- Insert those lines just before /* That's all, stop editing! Happy blogging. */

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

More info: https://wpml.org/home/minimum-requirements/

September 3, 2024 at 12:37 am #16133669

basselS-2

"1. Ensure that you are using absolute links (and not relative links) on the original page (e.g. hidden link instead of /contact)."
- I am using absolute links.

------------------------------------------

"2. The linked page must be translated already. In my example, the "Contact" page needs to be translated, otherwise WPML convert the link.
If you translated the linked page afterward, go to "WPML > Settings > Translate Link Targets" to scan and adjust your links."
- They are translated.
- I have tried the scanning multiple times and the response is always the same:
"All posts and strings have been processed. 0 links were changed to point to the translated content."

-------------------------------------------

- More details
"How did you insert the link on the original page? Is it a normal content link inserted in a paragraph?"
It's a link that I put for a button as url. The screenshot is attached.

- Can you share an URL where I can see the issue (a page where links weren't translated)?
Sure, you can see it also on the buttons in the home page as well:
hidden link

Side note: For the WP_MEMORY_LIMIT, I have set it to 512M.

Screenshot 2024-09-03 033448.png
September 3, 2024 at 3:39 am #16133738

basselS-2

I noticed that while I am in my browser in where I am into my wordpress account, I can see the other language page, while when I open it in another browser or incognito mode, the home page in the other language doesn't exist at all !

September 3, 2024 at 3:44 am #16133741

basselS-2

Also when I change the pictures in the English version, the other language version is not reflecting the changes. I am not sure if all the above issues are related to one root issue.

September 3, 2024 at 11:18 am #16135278

Nicolas V.
Supporter

Languages: English (English ) French (Français )

Timezone: America/Lima (GMT-05:00)

Hi Bassel,

Let's try something else. When translating your page in our Advanced Translation Editor (ATE), use the top left search bar and search for "http" it will show you all links used on that page and you will be able to translate them.

If you can't access the translation when you're not logged into your admin account is means that the translated page isn't published yet.

To speed up the support, I'd like to request a temporary admin access – preferably to your staging site – so I can further investigate. I will activate a private field for your next answer where you can provide that information safely (this field is only visible by you and the support team). Don't share your own admin account, create a new one that you will delete when we finish troubleshooting.

IMPORTANT: Before we proceed, please backup your site and database.

September 3, 2024 at 9:03 pm #16137884

Nicolas V.
Supporter

Languages: English (English ) French (Français )

Timezone: America/Lima (GMT-05:00)

Hello,

Thank you for providing access! In this case, you're not using the default Gutenberg "button" block but a widget from an add-on. I had to manually register this widget for translation by creating a custom XML configuration file, following the instructions here: https://wpml.org/documentation/support/language-configuration-files/make-custom-gutenberg-blocks-translatable/

I've made a short video to show you how easy it is to register these widgets. This way, if you need to register other widgets from this add-on, you can do it in just a few minutes.

Video tutorial: hidden link

September 4, 2024 at 12:43 am #16138133

basselS-2

Thank you Nicolas ! Really appreciate your time making the video for me.

But I think there is still an issue. I have tested adding the gutenberg default button and adding a link, I have translated the button text. After that, when I switch to the other language. I see the link is still pointing to the original language. I do not think translating the link manually is a solution since this is not scalable at all.

You can check the button at the end of the home page.

Am I misunderstanding something here ?

September 4, 2024 at 2:33 am #16138207

basselS-2

I think even the buttons translation are not working now though they were working before on the home page.

Can we have a chat or meeting instead to make it faster.

Thank you.

September 4, 2024 at 12:27 pm #16140359

Nicolas V.
Supporter

Languages: English (English ) French (Français )

Timezone: America/Lima (GMT-05:00)

Hello,

I changed a little bit the XML configuration for you and used the xpath method instead.

<wpml-config>
  <gutenberg-blocks>
    <gutenberg-block type="greenshift-blocks/buttonbox" translate="1">
       <xpath type="link">//a/@href</xpath>
       <xpath>//span</xpath>
    </gutenberg-block>
  </gutenberg-blocks>
</wpml-config>

Please note that this will allow you to translate the link manually but WPML won't be able to translate it automatically because it's not a content link. The widget block will actually create a code that looks like this:

<!-- wp:greenshift-blocks/buttonbox {"id":"gsbp-ade26ef","buttonContent":"Contact Us","spacing":{"margin":{"values":{"bottom":["0px"]},"locked":false},"padding":{"values":{},"locked":false}},"buttonLink":"URL_HERE","dynamicEnable":true} -->
<div class="gspb_button_wrapper gspb_button-id-gsbp-ade26ef" id="gspb_button-id-gsbp-ade26ef"><a class="wp-block-greenshift-blocks-buttonbox gspb-buttonbox wp-element-button" href="URL_HERE" rel="noopener"><span class="gspb-buttonbox-textwrap"><span class="gspb-buttonbox-text"><span class="gspb-buttonbox-title">Contact Us</span></span></span></a></div>
<!-- /wp:greenshift-blocks/buttonbox -->
September 4, 2024 at 2:20 pm #16141107

basselS-2

Thank you. Could you please explain what a content link is?
I am still struggling on why links are not converted automatically to point to the other language (sticky links stuff), even though the button is a gutenberg block.

Regards,

September 4, 2024 at 5:02 pm #16142075

Nicolas V.
Supporter

Languages: English (English ) French (Français )

Timezone: America/Lima (GMT-05:00)

Hello,

Let me clarify my response:

- WPML can automatically translate links within your content (such as links inside a paragraph).
- However, Gutenberg blocks generate code, and WPML cannot translate links embedded within this code.

This is why those links aren't translated automatically.

The Sticky Links add-on serves a different purpose. It replaces the URL of a page with its ID, which is helpful if your URLs change frequently and you want to avoid 404 errors. I recommend using it only if you often change URLs; otherwise, you can deactivate it. Please note that the same limitation applies to Sticky Links: it only works with links placed directly in your content.