Skip Navigation

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.

Sun Mon Tue Wed Thu Fri Sat
- 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 -
- 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 -

Supporter timezone: Asia/Ho_Chi_Minh (GMT+07:00)

Tagged: 

This topic contains 6 replies, has 2 voices.

Last updated by Long Nguyen 1 year, 3 months ago.

Assisted by: Long Nguyen.

Author Posts
January 4, 2024 at 11:26 pm #15153095

billJ-4

This is the same site as we've been working on in recent tickets, which uses a FSE homepage with gutenberg static blocks and custom dynamic blocks.

All the content is translating fine, our problem is that when we create a link in (for example) the homepage footer to an existing page, that link isn't translated when viewing the homepage in a different language. So if I switch to Spanish the link still links to the english version of the post.

I can see the url in the advanced translation view if I filter by https or something. I can translate it explicitly. But it seems like WPML should be able to translate links to posts it has itself created. Are we doing something wrong?

I've tried using the Translate Link Targets button in settings and the translate_link_target attribute in wpml-config and modifying and re-translating the footer, but WPML still seems to want me to manually translate the links.

What's the correct workflow for creating links in a gutenberg block and having WPML translate them?

January 5, 2024 at 2:17 am #15153146

Long Nguyen
WPML Supporter since 02/2022

Languages: English (English )

Timezone: Asia/Ho_Chi_Minh (GMT+07:00)

Hi Bill,

Thank you for contacting WPML support, I'd be happy to help you with this issue.

WPML can adjust the internal URL automatically on the translation page if the post/page is already translated. When registering the custom XML configuration code for the link field of a block, you can tell WPML that it is a link type. For example:

<wpml-config>
  <gutenberg-blocks>
    <gutenberg-block type="core/some-block" translate="1">
        <xpath type="link">//a/@href</xpath>
    </gutenberg-block>
  </gutenberg-blocks>
</wpml-config>

Please read more about the type link in the documentation https://wpml.org/documentation/support/language-configuration-files/make-custom-gutenberg-blocks-translatable/#a9518_innerdiv

Look forward to your reply.
Thanks

January 5, 2024 at 3:39 pm #15155466

billJ-4

Those settings seem to work when we're referencing hrefs in core blocks, but WPML doesn't seem to want to translate hrefs in custom blocks. So we've got the following wpml-config (image 1).

This works on our core paragraphs in the footer, because the url I've linked to doesn't show up in the translation manager at all and shows up correctly on the rendered page (image 2, image 3).

With our custom blocks, though, the url *does* show up in the translation manager, which makes me think it's not being picked up as a link that can be translated (image 4). The destination URL does definitely have a translation (image 5).

This is the core problem. Our custom block text fields show up for manual translation fine when defined in the wp-config, but the links are not automatically translated.

I'm not sure what the difference could be in how WPML is handling the core paragraph block (markup in image 6) and the custom block (markup in image 7). Maybe it treats the key element different than the xpath element or doesn't like that these values are in attributes?

Thank you for all your help, Long.

image 4.png
image 2.png
image 1.png
image 3.png
image 5.png
image 6.png
image 7.png
January 8, 2024 at 3:29 am #15158058

Long Nguyen
WPML Supporter since 02/2022

Languages: English (English )

Timezone: Asia/Ho_Chi_Minh (GMT+07:00)

Hi,

Can you please replicate the issue on a clean installation of WordPress? You can access the admin area with this link
hidden link

Kindly follow the steps below:

- Don’t restore your site there.
- Install the block plugin.
- Try to replicate the issue with minimal steps.
- Then let me know the steps to replicate it.

Look forward to your reply.
Thanks

January 8, 2024 at 3:33 pm #15161392

billJ-4

OK, I've uploaded our theme, which contains all the blocks. The site exhibits the same behavior: core paragraph blocks in Footer display no links in the advanced translation editor, I assume because they have been automatically translated. (image a, image b).

Custom blocks like front-page-carousel in Front Page display links in the advanced translation editor, so it appears they have not been automatically translated (image c, image d, image e).

image e.png
image b.png
image a.png
image c.png
image d.png
January 9, 2024 at 2:14 am #15162855

Long Nguyen
WPML Supporter since 02/2022

Languages: English (English )

Timezone: Asia/Ho_Chi_Minh (GMT+07:00)

Hi,

I see the custom block and URL in the ATE for translation. I'm asking our 2nd tier support about this case and I will update you here when I have something to share.

Thanks.

January 9, 2024 at 8:03 am #15163135

Long Nguyen
WPML Supporter since 02/2022

Languages: English (English )

Timezone: Asia/Ho_Chi_Minh (GMT+07:00)

Hi,

I got some information from our 2nd tier support: This is a limitation. We can't adjust the URL inside the block attribute automatically.

There are two options:

- Translate URL manually in Advanced Translation Editor.
- Translate URL in front-end when they render. For this, please share the code that you are using to render the block and we can suggest the changes to translate the link.

Look forward to your reply.
Thanks

The topic ‘[Closed] Can WPML automatically translate URLs?’ is closed to new replies.