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.

Tagged: 

This topic contains 21 replies, has 2 voices.

Last updated by Dražen 1 year, 6 months ago.

Assisted by: Dražen.

Author Posts
June 5, 2023 at 1:13 pm #13771341

Dražen
Supporter

Languages: English (English )

Timezone: Europe/Zagreb (GMT+01:00)

Hello,

just to update you, our ATE team is still checking on this issue, seems it could be a bug from our side.

I will let you know as soon as I have some news.

Regards,
Drazen

June 19, 2023 at 9:51 am #13849793

bjornL-7

Any news? Thanks

June 19, 2023 at 10:35 am #13850375

Dražen
Supporter

Languages: English (English )

Timezone: Europe/Zagreb (GMT+01:00)

Hello,

our devs are still working on the issue.

Let me ping them again and get an update on this.

Regards,
Drazen

June 23, 2023 at 6:58 am #13881951

Dražen
Supporter

Languages: English (English )

Timezone: Europe/Zagreb (GMT+01:00)

Hello,

I got some updates, it seems for now it is a complex edge case that would require to many changes from our side to work, we are still checking and debugging it further and I will update you in the future when there is some news, but it will not be soon.

For this page, the best would be to manually edit the 2nd language page and add the code there manually rather than using ATE.

Regards,
Drazen

June 26, 2023 at 9:55 am #13894093

bjornL-7

"the best would be to manually edit the 2nd language page and add the code there manually rather than using ATE."
This is not an option for us. If we were to do it this way for the translated languages, and then later on update the page in the default language and send the translations to our translators to translate via ATE, the manual edit of the schema would be deleted.

Is there really no other way for us to achieve a translation of schema markup??

Even if I add the schema to a regular Avada text block, ATE does not add it to the ATE translation.

<script type="application/ld+json">
{
"@context": "hidden link",
"@type": "FAQPage",
"mainEntity": {
"@type": "Question",
"name": "A question",
"acceptedAnswer": {
"@type": "Answer",
"text": "An answer."
}
}
}
</script>

June 26, 2023 at 11:12 am #13894743

Dražen
Supporter

Languages: English (English )

Timezone: Europe/Zagreb (GMT+01:00)

Hello,

I am afraid for now, as I explained it will not work with ATE, and the only way as a workaround would be to translate it manually or use a manual translation method for this page.

Our team will be working further on this issue and contacting also probably Avada to find the best solution for this, but please note it will be soon and might take some time before we progress or permanent fix.

That is why we are advising you to use the suggested method as a workaround, and when we have some news or progress I will update you here.

Hope you understand.

Regards,
Drazen

June 30, 2023 at 6:38 am #13920979

Dražen
Supporter

Languages: English (English )

Timezone: Europe/Zagreb (GMT+01:00)

Hello,

Our compatibility devs are providing next workaround, I tested it and works fine, you can translate the script via ATE.

These are the steps:

- Make sure that the "Code Block Encoding" option from avada is enabled

- Add the following XML code to WPML > Settings > Custom XML Configuration:

<wpml-config>
  <shortcodes>
    <shortcode>
      <tag encoding="base64_with_script_tag" encoding-condition="option:avada_disable_encoding=1">fusion_code</tag>
    </shortcode>
  </shortcodes>
</wpml-config>

- Add the following code to the functions.php file:

// WPMl Workaround for compsupp-6846
function wpml_compsupp6846_decode_base64_with_script_tag( $string, $encoding, $original_string ) {  

    if ( $encoding == 'base64_with_script_tag') {
        if (!empty($string) && base64_encode(base64_decode($string, true)) === $string) {
            $string = base64_decode($string);

            if (preg_match('#(.*)(<script[^>]*>)(.*?)(</script>)(.*)#is', $string, $matches)) {
                
				$results = $matches;
				unset($results[0]);

				$string = array();
				
				foreach ($results as $key => $value) {
                    if (preg_match('/^<script.*>$/i', $value) || preg_match('/^<\/script>$/i', $value)) {
                        $string[$key] = array( 'value' => $value, 'translate' => false );
                    } else {
                        $string[$key] = array( 'value' => $value, 'translate' => true );
                    }
                }
            }
        }
    }

    return $string;  
}
add_filter( 'wpml_pb_shortcode_decode', 'wpml_compsupp6846_decode_base64_with_script_tag', 10, 3 );


function wpml_compsupp6846_encode_base64_with_script_tag( $string, $encoding, $original_string ) {

	if ($encoding == 'base64_with_script_tag') {
		if (is_array($string)) {
			$processed_string = '';
			foreach ($string as $key => $value) {
				$processed_string .= $value;
			}	
			
		}

		$processed_string = base64_encode($processed_string);

		return $processed_string;
	}

    return $string;  
}
add_filter( 'wpml_pb_shortcode_encode', 'wpml_compsupp6846_encode_base64_with_script_tag', 10, 3 );

Go to the original page, do a small modification and save.

You should be able to translate the JSON part with ATE now. In same cases if encoding was not enabled, you might need to create new page.

Let me know how it goes.
Regards,
Drazen