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 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?
https://wpml.org/documentation/translating-your-contents/page-builders/how-to-register-page-builder-modules-and-theme-options/#finding-the-name-of-your-page-builder-modules

Is there a similar example that we can see?
\[trx_sc_icons type="modern" align="left" size="medium" icons_animation="" icons="%5B%7B%22title%22%3A%22PRO%C4%8C%3F%22%2C%22description%22%3A%22B%C3%BDt%20p%C5%99ipraven%20znamen%C3%A1%20tr%C3%A9novat%20v%20co%20nejre%C3%A1ln%C4%9Bj%C5%A1%C3%ADm%20a%20dynamick%C3%A9m%20prost%C5%99ed%C3%AD%20ostr%C3%A9%20st%C5%99elby%20%E2%80%93%20st%C5%99%C3%ADlet%20do%20pap%C3%ADrov%C3%A9ho%20ter%C4%8De%20na%20st%C5%99elnici%20nesta%C4%8D%C3%AD.%22%2C%22icon%22%3A%22icon-untitled-17%22%7D%5D" title_style="default" columns="1"\]

What is the link to your site?
alfarenge.com

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:
[{"title":"PROČ?","description":"Být připraven znamená trénovat v co nejreálnějším a dynamickém prostředí ostré střelby – střílet do papírového terče na střelnici nestačí.","icon":"icon-untitled-17"}]

October 26, 2022 at 11:58 am #12315077

oldrichH

I have found the addition info here:
https://wpml.org/documentation/support/translating-urlencoded-shortcodes/

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:
hidden link

October 26, 2022 at 1:08 pm #12315575

oldrichH

My issue is not resolved now. Thank you!

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