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 1 voice.
Last updated by oldrichH 1 year, 6 months ago.
Author | Posts |
---|---|
October 26, 2022 at 9:42 am #12313691 | |
oldrichH |
Tell us what you are trying to do? Translate site Is there any documentation that you are following? Is there a similar example that we can see? What is the link to your site? Is possible to map this gibberish to translate? |
October 26, 2022 at 9:46 am #12313705 | |
oldrichH |
It uses URL encode. Here is a decoded string: |
October 26, 2022 at 11:58 am #12315077 | |
oldrichH |
I have found the addition info here: So it should be: <shortcode> <tag>trx_sc_icons</tag> <attributes> <attribute type="area" encoding="urlencoded_json">icons</attribute> </attributes> </shortcode> and to the function: add_filter( 'wpml_pb_shortcode_encode', 'wpml_pb_shortcode_encode_urlencoded_json', 10, 3 ); function wpml_pb_shortcode_encode_urlencoded_json( $string, $encoding, $original_string ) { if ( 'urlencoded_json' === $encoding ) { $output = array(); foreach ( $original_string as $combined_key => $value ) { $parts = explode( '_', $combined_key ); $i = array_pop( $parts ); $key = implode( '_', $parts ); $output[ $i ][ $key ] = $value; } $string = urlencode( json_encode( $output ) ); } return $string; } add_filter( 'wpml_pb_shortcode_decode', 'wpml_pb_shortcode_decode_urlencoded_json', 10, 3 ); function wpml_pb_shortcode_decode_urlencoded_json( $string, $encoding, $original_string ) { if ( 'urlencoded_json' === $encoding ) { $rows = json_decode( urldecode( $original_string ), true ); $string = array(); foreach ( $rows as $i => $row ) { foreach ( $row as $key => $value ) { if ( in_array( $key, array( 'title', 'description', 'icon' ) ) ) { $string[ $key . '_' . $i ] = array( 'value' => $value, 'translate' => true ); } else { $string[ $key . '_' . $i ] = array( 'value' => $value, 'translate' => false ); } } } } return $string; } I have detected more TRX_SC shortcodes in the content, so XML config should be like: <wpml-config> <shortcodes> <shortcode> <tag>trx_sc_icons</tag> <attributes> <attribute type="area" encoding="urlencoded_json">icons</attribute> </attributes> </shortcode> <shortcode> <tag>trx_sc_title</tag> <attributes> <attribute>title</attribute> </attributes> </shortcode> <shortcode> <tag>trx_sc_button</tag> <attributes> <attribute>title</attribute> </attributes> </shortcode> <shortcode> <tag>trx_sc_layouts_iconed_text</tag> <attributes> <attribute>text2</attribute> </attributes> </shortcode> <shortcode> <tag>trx_widget_contacts</tag> <attributes> <attribute>address</attribute> </attributes> </shortcode> </shortcodes> </wpml-config> Is it right? How I can say which shortcodes shoud not be listed for translation? Many of them doesn't have any strings. |
October 26, 2022 at 12:36 pm #12315357 | |
oldrichH |
Anyway, I dont know how to merge my config with Wp bakery config: |
October 26, 2022 at 1:08 pm #12315575 | |
oldrichH |
My issue is not resolved now. Thank you! |