Home›Support›English Support›[Resolved] Links in my pages are not converted automatically to contains the other language slug
[Resolved] Links in my pages are not converted automatically to contains the other language slug
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.
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.
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?
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.
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. */
"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.
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 !
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.
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.
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.
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.
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:
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.
- 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.