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.

This topic contains 5 replies, has 2 voices.

Last updated by Waqas Bin Hasan 1 year, 2 months ago.

Assisted by: Waqas Bin Hasan.

Author Posts
February 20, 2023 at 4:44 pm #13072585

Angeloca

Hi, I'm building a custom block using the LinkControl component.

I'm saving it in a "link" attribute (type object). So the resulting data is strctured like link->url.

I was wondering how is it possible to make those link translatable.

I've tried with this sintax:

``` <gutenberg-block type="glocal/iconbox" translate="1" label="Iconbox" >
<key name="title" label="Iconbox titolo"/>
<key name="description" label="Iconbox descrizione" />
<key name="link">
<key name="url" />
</key>
</gutenberg-block>```

but with no success... (the URL does not appear in the translation editor) :-/

Any suggestion?

February 21, 2023 at 11:04 am #13078111

Waqas Bin Hasan
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi,

Thank you for contacting the support.

You'll need to register your block in WPML's Custom XML Configuration. I'll advise to look into the following guides:

- https://wpml.org/documentation/support/language-configuration-files/#gutenberg-blocks
- https://wpml.org/documentation/support/language-configuration-files/how-to-register-page-builder-widgets-for-translation/
- https://wpml.org/documentation/support/language-configuration-files/overriding-language-configuration-files/

Regards.

February 21, 2023 at 12:45 pm #13079081

Angeloca

Hi Waqas, as you can see from my initial post, I've already registered it in the xml config file.

Every string works, except the url created with the LinkControl component

February 21, 2023 at 1:35 pm #13079575

Waqas Bin Hasan
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi,

Thank you for the update.

I am not sure how that LinkControl component works. As per my understanding, your custom block is incorporating another component which offers some controls or fields for the said purpose.

In theory, the block should ultimately produce some HTML/XML scaffold. If simple key/name isn't working (as you mentioned in your first message), please try the "Translation of links in Gutenberg blocks" example at https://wpml.org/documentation/support/language-configuration-files/#gutenberg-blocks, like:

<xpath type="link">//a/@href</xpath>

Notice that xpath encapsulates the scaffold path to the example URL element.

Regards.

February 23, 2023 at 11:23 am #13097839

Angeloca

Hi Waqas, I'll try that thank you.

One question though the html scaffold output is it refferred to the one in the save function or in the edit one?

February 23, 2023 at 1:21 pm #13099391

Waqas Bin Hasan
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi,

Sure, please take your time.

It should be like what's saved, since that's what is rendered I think.

Regards.

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.