This thread is resolved. Here is a description of the problem and solution.
Problem:
You are trying to translate the vc_progress_bar shortcode using WPML, but the value and label fields do not appear in the translation editor despite following the steps in the documentation.
Solution:
We recommend adding specific code to your functions.php file to handle the encoding and decoding of the vc_progress_bar shortcode. Here is the code you should add:
add_filter( 'wpml_pb_shortcode_encode', 'wpml_pb_shortcode_encode_urlencoded_json', 10, 3 );<br />function wpml_pb_shortcode_encode_urlencoded_json( $string, $encoding, $original_string ) {<br /> if ( 'urlencoded_json' === $encoding ) {<br /> $output = array();<br /> foreach ( $original_string as $combined_key => $value ) {<br /> $parts = explode( '_', $combined_key );<br /> $i = array_pop( $parts );<br /> $key = implode( '_', $parts );<br /> $output[ $i ][ $key ] = $value;<br /> }<br /> $string = urlencode( json_encode( $output ) );<br /> }<br /> return $string;<br />}<br /><br />add_filter( 'wpml_pb_shortcode_decode', 'wpml_pb_shortcode_decode_urlencoded_json', 10, 3 );<br />function wpml_pb_shortcode_decode_urlencoded_json( $string, $encoding, $original_string ) {<br /> if ( 'urlencoded_json' === $encoding ) {<br /> $rows = json_decode( urldecode( $original_string ), true );<br /> $string = array();<br /> foreach ( $rows as $i => $row ) {<br /> foreach ( $row as $key => $value ) {<br /> if ( in_array( $key, array( 'text', 'title', 'features', 'substring', 'btn_text', 'label', 'value', 'y_values' ) ) ) {<br /> $string[ $key . '_' . $i ] = array( 'value' => $value, 'translate' => true );<br /> } else {<br /> $string[ $key . '_' . $i ] = array( 'value' => $value, 'translate' => false );<br /> }<br /> }<br /> }<br /> }<br /> return $string;<br />}
This solution might be outdated or not applicable to your specific 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 this does not resolve your issue, 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.
No supporters are available to work today on this forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.
This topic contains 3 replies, has 2 voices.
Last updated by 1 month, 3 weeks ago.
Assisted by: Osama Mersal.