Home›Support›English Support›[Resolved] Anchor links in translation buttons are copied from original when updated
[Resolved] Anchor links in translation buttons are copied from original when updated
This thread is resolved. Here is a description of the problem and solution.
Problem: The client tries to translate the IDs and anchor links for Gutenberg Heading Blocks. Solution: This issue arises because WPML's XML configuration, on purpose, does not allow translating ID selectors for such blocks. If you have added a custom XML configuration, it will override the default configuration and affect how WPML handles the Gutenberg Block. To ensure that links continue to be translated, your custom XML configuration should include the necessary paths. Here is an example of how you can configure it:
Please test this configuration and let us know if you need further assistance.
Note that this solution might be irrelevant if it's outdated or not applicable to your case. 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 at WPML support forum.
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 is because your config allows translating the IDs of those Headings. If the IDs are not translated, the anchor links will not work.
The Generate Blocks Team would need to update their wpml-config.xml file in this case, to always allow translating the IDs.
The same counts for our config for the Gutenberg heading block:
<gutenberg-block type="core/heading" translate="1">
<xpath>//*[self::h1 or self::h2 or self::h3 or self::h4 or self::h5 or self::h6]</xpath>
</gutenberg-block>
It only considers the text, not the IDs.
I suppose that this is expected in this case, as most users might not expect that they need to translate the IDs. This is why we allow adding a custom XML config for specific use cases.
I suggest that, for now, you keep using the custom config for your use case.
I am following up with our compatibility team about whether the behavior is currently expected or if it would be something we would adapt.
I have had XML config to allow translating the id attribute on both Gutenberg and GeneratePress heading blocks for a long time. The heading ids are visible in ATE as well.
While investigating this myself I added XML config for the href attribute on buttons. That seemed to have some effect. See previous messages.
Thank you for checking with the compatibility team.
According to our compatilbity team, the reported behavior is expected. We do not consider those IDs by default to be translatable, as this is expected by the majority of users.
If you need to translate those IDs, you can use a custom XML configuration.
I know that IDs are not translated by default. That is why I have added them to my XML config long before this ticket. They do show up in ATE. My issue isn't even with ID attrbutes, it is with HREF attributes referring to those IDs
In my site there seem to be a case where the translation of href attributes are reverted to that of the original, event if the IDs and HREFs are shown in ATE.
Have you had time to check my staging site? See previous messages for repro steps.
1) You need a specific config to translate the IDs. We do not cover this by default.
2) The anchor links like "#contact" should always be translatable, but it might be the case that by default, they will not appear inside the Advanced Translation Editor. You might need to search for them first in the text search field on the top right.
Anyhow, it would not be recommended to translate those anchor links unless you use a custom config to translate the IDs.
---
What exactly are you expecting in your use case? Please provide an exact example.
Please confirm that you understand that XML config for translating IDs was there from the beginning. I mentioned this a few times now - but from your replies it sounds to me like you think these are missing.
Given that I have XML config for translating heading IDs, I expect these to be visible in ATE. I also expect links to be visible in ATE without any custom configuration. Both of these are true.
When updating the original page, I expect the translated links to be applied in the translated page. What I observe, is that they are not if the change to the original was style/layout only. If I make a second edit on the original, the links will be updated.
The IDs were translatable, as you used a custom config at WPML > Settings > Custom XML Configuration. Our devs do not include those IDs by default on purpose.
You will need to use a custom XML configuration for your use case.
What about the links (href attributes)? Are custom configuration needed for that as well?
As I mentioned before, my experience is that links are always visible in ATE. But if I make a style change only to the original, links will be overwritten with that of the original in the translation. Did you check my repro steps in my staging site?
Your steps included:
- Remove the XML workaround for button blocks
The links will not work if I remove the XML config, and this is expected, as without the XML configuration, the IDs will not be translated.
If I did not understand the issue correclty, please let me know on which content on your site this issue can be replicated, and name me the exact steps.
Thank you for clarifying. "Remove the XML workaround for button blocks" was referring to my workaround adding '//a/@href' to the XML config, not IDs on headings.
As of today the issue is slightly different. I noticed a pending update for WPML but that does not seem to make a difference. Added login information to the private form.
I updated Step 1 below. At first the repro steps was that under 'Yesterday'. At some point, they changed to those under 'Today'.
Yesterday:
1. Add XML config for translating ID attributes on headings and remove XML config for HREF attributes on links
2. Edit /sv/insikter/
3. Change orientation on the buttons block
4. Go to /en/insights/
5. Notice automatic orientation change and links being same as original
Today:
1. Add XML config for translating ID attributes on headings and remove XML config for HREF attributes on links
2. Edit /sv/insikter/
3. Change orientation on the buttons block
4. Go to /en/insights/
5. Notice that orientation remains unchanged
6. Edit in ATE
7. Notice the anchor links in ATE are translated
8. Save translation
9. Notice orientation change and links being same as original
You are saying:
Add XML config for translating ID attributes on headings and remove XML config for HREF attributes on links
If you first use a config for the links and then remove this config, it might be expected that they will no longer be translated.
Anyhow, there should not be a need for any config for links. In doubt, you can always search the links inside the text field on the top right of the Advanced Translation Editor.
The XML for HREF attributes was not there when I found the issue or when the links was originally translated. I added it on advise from your chat bot. It seemed to fix or workaround the issue. But like you say - it should not be needed.
I can not confirm this on my test site. I just need to search the link in the top right text field inside the Advanced Translation Editor and translate it. No config needed.
One-Click-Login: hidden link
The config for the ID will be needed, as our devs do not cover it on purpose.