Resolved
Reported for: WPML Multilingual CMS 4.5.14
Resolved in: WPML 4.6.4
Overview of the issue
If you are using the Elementor loop template feature, buttons aren’t translated on the front-end even if they are available for translation in the Advanced Translation Editor.
Workaround
Please be sure of making a full backup of your site before proceeding.
- Open the /wp-content/plugins/sitepress-multilingual-cms/addons/wpml-page-builders/classes/Integrations/Elementor/class-wpml-elementor-translate-ids.php file.
- Look for line 108.
- Replace the
WPML_Elementor_Translate_IDs::translate_global_widget_ids()
method:public function translate_global_widget_ids( $data_array, $post_id ) { foreach ( $data_array as &$data ) { if ( isset( $data['elType'] ) && 'widget' === $data['elType'] ) { if ( 'global' === $data['widgetType'] ) { $data['templateID'] = $this->translate_id( $data['templateID'] ); } elseif ( 'template' === $data['widgetType'] ) { $data['settings']['template_id'] = $this->translate_id( $data['settings']['template_id'] ); } } $data['elements'] = $this->translate_global_widget_ids( $data['elements'], $post_id ); } return $data_array; }
With:
public function translate_global_widget_ids( $data_array, $post_id ) { foreach ( $data_array as &$data ) { if ( isset( $data['elType'] ) && 'widget' === $data['elType'] ) { if ( 'global' === $data['widgetType'] ) { $data['templateID'] = $this->translate_id( $data['templateID'] ); } elseif ( 'template' === $data['widgetType'] || 'loop-grid' === $data['widgetType'] || 'loop-carousel' === $data['widgetType']) { $data['settings']['template_id'] = $this->translate_id( $data['settings']['template_id'] ); } } $data['elements'] = $this->translate_global_widget_ids( $data['elements'], $post_id ); } return $data_array; }
- Translate the Elementor loop template in WPML → Translation Management.
Works very well. Thanks 🙂
I’m glad to know it works. 🙂
Thank you for your feedback!
Please include this fix in the next WPML release.
Hello Joris,
Sure, we will keep this erratum updated once the fix is released.
Regards
This works really well for loop grids.
But it does not for loop carousel 🙁
Hi there,
Could you please open a new ticket witht eh details in our forum? https://wpml.org/forums/forum/english-support/
We would like to do some tests to see how the loop carousel works.
it seems like loop items are having issues
The button is part of the loop item and doesn’t get translated.
the loop items do not have template ids and get skipped over because they are actually linked to the loop item id
The id im having issues with is 187bf51
https://gc.tdgrepo.com/es/?s=jaws
I got the new code but it doesnt work…I added some var dumps to track the issue…any help is appreciated.
public function translate_global_widget_ids( $data_array, $post_id ) {
foreach ( $data_array as &$data ) {
if(is_search()){
echo ‘ Type: ‘ . $data[‘elType’] . ”;
if(isset( $data[‘templateID’])){
echo ‘ Template ID ‘ . $data[‘templateID’] . ”;
} else {
echo ”;var_dump($data);echo ”;
}
if(isset( $data[‘id’])){echo ‘ ID ‘ . $data[‘id’] . ”;}
}
if ( isset( $data[‘elType’] ) && ‘widget’ === $data[‘elType’] ) {
if ( ‘global’ === $data[‘widgetType’] ) {
$data[‘templateID’] = $this->translate_id( $data[‘templateID’] );
} elseif ( ‘template’ === $data[‘widgetType’] || ‘loop-grid’ === $data[‘widgetType’] || ‘loop-carousel’ === $data[‘widgetType’]) {
$data[‘settings’][‘template_id’] = $this->translate_id( $data[‘settings’][‘template_id’] );
}
}
$data[‘elements’] = $this->translate_global_widget_ids( $data[‘elements’], $post_id );
}
return $data_array;
}
Hello Chris,
According to your description, it seems like an edge case. Could you please open a chat in our support so we can investigate your case?
Thank you for your help.
Andrés
That works well for my website, thank you so much!
I’m glad to know it worked. 🙂
I just want to confirm the suggested workaround fixes the problem. Any plans on when will it be included in WPML?
I’m glad to know that it worked and you can continue translating your site. 🙂
Yes, it will be include in one of our next releases very soon. We will keep this erratum updated.
Regards
Hello i tried the fix but it seems to not fix issue, we have loop templates items and icon are not translated, any idea ?
example :
https://oman-reit.com/ar/%d8%b9%d9%84%d8%a7%d9%82%d8%a7%d8%aa-%d8%a7%d9%84%d9%85%d8%b3%d8%aa%d8%ab%d9%85%d8%b1%d9%8a%d9%86/
Hello there,
This may be an exception or a different edge case, could you please report it in our forum?
Regards
Hi guys,
I had the bug again in a new website and remembered this.
Would be nice you push this in the new version ? Is it plan ?
Thanks
Johann
Hello Johann,
I’m glad it helped. Yes, this fix is already in our devs roadmap.
We will keep this erratum updated once we release it.
Regards
Thanks for the fix.
The button text is now translated, the link on the other hand is not. Is there also a new fix for that?
https://www.avita.at/en/packages-list/
I’m glad it helped, Jakob. Now, have you tried to translate your link as explained in this link? Otherwise, please open a chat in our assistance to better check your situation.
Regards
Hi guys. I’ve tried to use this fix and It broke my site… Might have done something wrong.
Can you check my code and tell me what to fix? or send me a fresh one to override the one I modified?
Hi guys. I’ve tried to use this fix and something got wrong. Can you take a look at my code and tell me where it’s wrong please?
Hello Omer,
Could you please open a chat in our support and add this erratum link? In that way, one of our specialists can check your website and verify why this code is broking your website.
Thank you for your help.
Hello everyone,
This should be solved with WPML 4.6.4. Please don’t hesitate to make a full backup before updating your websites.
Cheers!