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

Last updated by Subash Chandra Poudel 1 year, 6 months ago.

Assisted by: Subash Chandra Poudel.

Author Posts
July 27, 2023 at 9:04 am #14108845

roliM

We have pages with a Hubspot form which are placed by an embed JS code in a Custom HTML block

For example
hidden link

Translating it to French goes without error but the Dutch version will not save because the "core/html script" field does not take content and keeps the translation on 97%.

Additional; it would be nice if we could localise the embed code in WPML but this also seems not possible.

July 30, 2023 at 10:00 am #14122339

Subash Chandra Poudel

Hi there,

I don't see the HubSpot’s WordPress plugin on your site but if you use the HubSpot’s WordPress plugin on your site it could be easier to trnalsate the form as there is a proper way and documentation to trnalsate the forms with HubSpot plugin as explained in the next link:

https://wpml.org/documentation/plugins-compatibility/integrating-hubspot-with-multilingual-sites-that-use-wpml/

As you said, you use custom HTML for HubSpot form the beat way to translate the custom HTML is to translate the page embedding the HTML manually and manually add the translation version of HTML in the translation page as expalined in the next link:

https://wpml.org/documentation/translating-your-contents/using-different-translation-editors-for-different-pages/

It might also be possible to translate the HTML based on what is it's structure, I can confirm if it is possible after checking what exactly is the main language and the translation HTML, but the best way to trnalsate custom HTML is to use manual translation method as expalined above.

Regards,
Subash

July 31, 2023 at 7:19 am #14124379

roliM

Hi Subash,

Thanks for your reply.

It is not really clear to my what you are trying to say. sorry. But it might be I was not very clear either

We don't create a html form inside Custom HTML blocks. We use Custom HTML block to embed forms we create on Hubspot. The only thing we put in the Custom HTML block is a fiew lines of embed code in javascript.

We only need to be able to change the embed code per langauge since we have different forms per language on Hubspot.

We are migrating the content from our current website to a new one. We have a lot of forms build this way and it is impossible for us to change them all to a different way of working.

The issue is not with the Hubspot forms since they all exist on Hubspot. The issue is also not because of the embed code. Or because it is Hubspot embed code.

As mentioned, in the example above everything works nicely on the french version of the item with embed code in the Custom HTML block. The Dutch version will not save with similar embed code (just a different embed id). To me this seems to be a WPML issue.

August 1, 2023 at 3:55 am #14130127

Subash Chandra Poudel

Hi there,

Sorry for the confusions.

What I am trying to say exactly is normally HTML blocks are not well translated with ATE and if you need to use different HTML for Translated page the best way to do that is to translate the page manually instead of using WPML Translation Editor as expalined in the next link:

https://wpml.org/documentation/translating-your-contents/using-different-translation-editors-for-different-pages/

Sometimes, based on how your custom HTML is structured it might also be possible to translate it with WPML's translation editor though. I understand the form is translating well to french and not on dutch but this might be due to the structure of HTML.

To confirm that and see if the HTML you have for the form is translatable without using Manual Translation and if yes what's the best way to do that, I would need to take a closer look at your site. So would you please mind sharing temporary access (WP-Admin and FTP) to your site?

I have enabled a private reply for you to share the credentials securely, which means only you and I have access to it.

IMPORTANT: Please take a complete backup of the site first to avoid data loss.

Also, please share the HTML code for the two forms? Or HTML code for English form and for Dutch Form.

Regards,
Subash

August 3, 2023 at 8:19 am #14146743

Subash Chandra Poudel

Hi there,

Thank you for the details.

To translate the HTML successfully every time you might need to use our Manual Translation method instead as explained in the next link:

https://wpml.org/documentation/translating-your-contents/using-different-translation-editors-for-different-pages/

However to make it easier I did the following:

- I coded a shortcode for Form or basically placed the following code to your child theme's functions.php file:

function hubspot_customform_html($atts, $content = null) {
	$default = array(
		'formid' => 'b1fde73a-c7f7-4eda-b084-faf531e47f7a',
    );
	$attribute = shortcode_atts($default, $atts);
    $content = '<script charset="utf-8" type="text/javascript" src="//js.hsforms.net/forms/v2.js"></script><script>hbspt.forms.create({region: "na1",portalId: "437281",formId: "'.$attribute['formid'].'"});</script>';
    return $content;
}
add_shortcode('hubspot_customform_html', 'hubspot_customform_html');

- Now to add the form in your page please use format like:

[hubspot_customform_html formid="b1fde73a-c7f7-4eda-b084-faf531e47f7a"]

- While you trnalsate the page now, search for the id in the advanced translation editor at the top b1fde73a then translate the form ID with the Id of the translated form and you will see the translated form in the translated form.

Please let me know how it goes.

Regards,
Subash

August 3, 2023 at 8:54 am #14147237

roliM

Although I think it's a bit strange that you would add scripts to our function.php but it might come in handy later on so thank you.

However, it did not solve the issue of not being able to save the Dutch version. I fixed this by temporary removing the Hubspot embed code from the English version. Then I was able to save the Dutch translation after which I replaced the embed code in the English version.