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

Last updated by alexanderP-2 1 month ago.

Assigned support staff: Alejandro.

Author Posts
September 11, 2019 at 8:07 pm #4556359

alexanderP-2

Hello! I make my website with Elementor page builder and there is a widget called Shortcode which I can place 3rd party plugins' shortcodes. The issue is that WPML string doesn't support this widget translation and I should edit other languages independently. However it's inconvenient because I wand single design for some languages.

What am I trying.
I want to place price estimation in 2 languages. I made two forms in different languages and I have 2 shortcodes. If I place 1st shortcode I see it in all languages and cannot to translate with strings.

Here are the links of the same page in different languages
hidden link
hidden link

September 12, 2019 at 1:52 pm #4561433

Alejandro
Supporter

Languages: English (English ) Spanish (Español ) Italian (Italiano )

Timezone: Europe/Rome (GMT+02:00)

Hello!
Welcome to WPML Support.
I'll do my best to help you solve this issue.

Could you please upload the plugin that creates the shortcodes and try to replicate the problem over here, in this sandbox site, please? --> hidden link

I'll take a look at it and try to see what's going on (and hopefully fix it).

Regards.

September 15, 2019 at 5:42 pm #4575119

alexanderP-2

Hello and thank you for assistance!
Done with installation. It named WP Cost Estimation & Payment Forms Builder

Waiting for your help ))

September 16, 2019 at 2:54 pm #4581681

Alejandro
Supporter

Languages: English (English ) Spanish (Español ) Italian (Italiano )

Timezone: Europe/Rome (GMT+02:00)

So, shortcodes are not meant to be translated as you want to translate it, and in this particular case, it seems that what you want to achieve is not really possible with the shortcode translation (there is a way to do that which i'll explain shortly).

What i suggest you do is:

Instead of using the shortcode widget, use the Text editor widget and add the shortcode there. that way you will be able to edit it freely.

The way to translate shortcodes if you ever wanted to do that (but i suggest you avoid this as much as you can) is to wrap the shortcode into this other shortcode:

[php][wpml-string context="my-domain" name="my-name"] THE OTHER SHORTCODE GOES IN HERE [/wpml-string]</code

as documented here: https://wpml.org/documentation/support/wpml-coding-api/shortcodes/#wpml-string

i ran a test and it seems to work with many shortcodes (like WordPress' gallery, for example) but unfortunately it doesn't work with the one you want, and i believe it's because the shortcode doesn't manage to send accross the needed javascript for the shortcode to load correctly.

I asked our developers about this, just to check if this is an expected behavior or not and i'll keep you updated about what they tell me, but in the meantime you can use the solution i mentioned above.

September 16, 2019 at 8:59 pm #4584129

alexanderP-2

My issue is resolved now but still need extra plugin feature. Thank you!

September 18, 2019 at 2:44 pm #4597669

Alejandro
Supporter

Languages: English (English ) Spanish (Español ) Italian (Italiano )

Timezone: Europe/Rome (GMT+02:00)

Hello, i actually managed to fix that problem.

Please add in the functions.php file of your theme this code:

add_action('init', function (){
add_filter( 'wpml_elementor_widgets_to_translate', 'shortcode_widget_registration' );
});

/**
* Translate Shortcodes widget by elementor
* @param array $widgets
* @return array
*/
function shortcode_widget_registration($widgets) {
$widgets['shortcode'] = [
'conditions' => ['widgetType' => 'shortcode'],
'fields' => [
[
'field' => 'shortcode',
'type' => __('Enter your shortcode', 'sitepress'),
'editor_type' => 'AREA'
],

],
];

return $widgets;
}
September 18, 2019 at 3:58 pm #4598433

alexanderP-2

You're awesome! All works as Swiss clock ))
I will talk about it on my WP blog hidden link