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.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 -

Supporter timezone: Asia/Singapore (GMT+08:00)

Tagged: 

This topic contains 12 replies, has 2 voices.

Last updated by Kor 2 months ago.

Assisted by: Kor.

Author Posts
June 27, 2024 at 10:06 am #15842699

casperB-5

Background of the issue:
We have an issue on a client's website regarding Divi Layouts/Library and WPML. Even though we have made translation for Divi layouts (like global sections), we can only insert the main language version (which is English in this case). This issue only applies to the Divi frontend builder and not if you do it in the backend block builder. I have cloned the site to a staging environment and deactivated all other plugins than the WPML plugins: hidden link

Symptoms:
Translations are made with the WordPress Editor because not all language versions will use the same content and layout. You can only insert the English version of saved Divi layouts on all languages when using the Divi frontend builder. When using the backend builder, it works as intended and as it works on other client sites.

Questions:
Why are the translated Divi layouts not appearing in the frontend builder?
How can we ensure the correct language version of global sections is inserted in the frontend builder?

June 27, 2024 at 11:33 am #15843493

Kor
Supporter

Languages: English (English )

Timezone: Asia/Singapore (GMT+08:00)

Thank you for your patience.

Here is the sandbox site link: hidden link . Please install the required plugins/theme to replicate the issue. Once done, let me know, and I will investigate further for you.

June 28, 2024 at 7:10 am #15849831

casperB-5

Hi Kor,

I've set up what I need on the sandbox site.

I've also figured out the issue. It's when you insert a shortcode into the Divi page builder - even the simplest shortcode will cause the issue.

On the Danish page, I've inserted a simple shortcode created through the child theme's functions.php. If you try and insert the saved global section, it will show the English verison. If you remove the shortcode and reload the page builder, you can now insert the Danish global section.

I've also tested creating the shortcode through a plugin like Code Snippets, but the issue remains. So it's not an issue with child themes.

June 28, 2024 at 8:19 am #15850367

Kor
Supporter

Languages: English (English )

Timezone: Asia/Singapore (GMT+08:00)

Thanks for your reply.

I've followed your instructions and inserted a shortcode to the page here hidden link and translated it. However, I still cannot replicate the issue that you mentioned. Am I missing a step or could you replicate it for me so that I could check?

June 28, 2024 at 8:46 am #15850533

casperB-5

Hi Kor,

Yes, you are missing a couple of steps.

First off, you have to use a Danish page.
Secondly, it has to be an active shortcode. The shortcode you have inserted is not rendering anything, so it's basically just text.

Use this basic shortcode on a Danish page: [greeting]

I have made a new video showing you this: hidden link

It's a very simple shortcode with no errors and you can find it in the child theme:
function demo_shortcode() {
$message = 'Hello world!';
return $message;
}
add_shortcode('greeting', 'demo_shortcode');

July 1, 2024 at 2:44 pm #15869360

Kor
Supporter

Languages: English (English )

Timezone: Asia/Singapore (GMT+08:00)

Thanks for your patience.

I've escalated this to our 2nd Tier Support and will get back to you as soon as I have feedback.

July 2, 2024 at 11:38 am #15874817

Kor
Supporter

Languages: English (English )

Timezone: Asia/Singapore (GMT+08:00)

Thank you for your patience.

Our second-tier support team has advised that it is always recommended to translate Divi using our Advanced Translation Editor rather than manually. Additionally, issues related to manual translation may receive lower priority as it is not the preferred method for translating content.

Our second-tier support will continue to investigate this and I will come back to you once I've more feedback.

July 3, 2024 at 9:10 am #15882706

casperB-5

Hi Kor.

Using your Advanced Translation Editor to translate the global sections makes no difference though. I've already tried that and it will still only insert the English version if there's a shortcode active on the page.

I've created a new global section translated through your Advanced Translation Editor and as you can see, the problem remains.

I think that you should raise the priority again since this is an issue no matter which translation method/editor you use.

Thank you.

Example of issue using WPML Advanced Translation Editor.png
July 3, 2024 at 9:18 am #15882745

Kor
Supporter

Languages: English (English )

Timezone: Asia/Singapore (GMT+08:00)

Thank you for getting back to me.

I'm still awaiting feedback on this matter, but I'll prioritize this report for you. I'll update you as soon as I receive any feedback.

July 17, 2024 at 5:46 pm #15967776

Kor
Supporter

Languages: English (English )

Timezone: Asia/Singapore (GMT+08:00)

Thanks for your patience.

Could you please insert the custom PHP code below into your theme's functions.php and see if it fixes the issue?

// WPML: Workaround for compsupp-7452
function wpml_compsupp7452_fix_divi_editor_ajax_lang() {
    if ( isset($_POST['is_fb_preview']) && $_POST['is_fb_preview'] == 'true' ) {

        foreach ($_COOKIE as $name => $value) {
            if (strpos($name, 'wp-wpml_current_admin_language') === 0) {
                $my_current_lang = apply_filters( 'wpml_current_language', NULL );

                if ( $my_current_lang != $value ) {
                    do_action( 'wpml_switch_language', $value);
                }
                break;
            }
        }
    }
}

add_action('et_builder_structure_elements_loaded', 'wpml_compsupp7452_fix_divi_editor_ajax_lang');
July 29, 2024 at 9:53 am #16015064

casperB-5

Hi Kor.

Sorry for my late reply. I've been away on vacation.

The code snippet works but there is still an issue with it. If you have a backend window opened at the same time as the window with the page builder, it will always choose the language from the backend window.

So if we have multiple windows open, we would have to switch the language on all of them and to make sure all windows are the same language at all times.

I have a made a video showing the issue, which you can watch here: hidden link

July 29, 2024 at 3:48 pm #16017156

Kor
Supporter

Languages: English (English )

Timezone: Asia/Singapore (GMT+08:00)

Thanks for your reply.

I've shared your feedback with our 2nd Tier Support and they will check this and I will come back to you once I've feedback.

August 1, 2024 at 7:49 pm #16031265

Kor
Supporter

Languages: English (English )

Timezone: Asia/Singapore (GMT+08:00)

Thanks for your patience.

I have feedback from our 2nd Tier Support and this is what they mentioned.

This problem arises because WPML relies on a cookie to determine the current language, and all tabs in the same browser share this cookie. Consequently, if you open several tabs with different languages, the AJAX content will be loaded in the language of the last tab opened, causing inconsistencies.

Details:

AJAX and WPML Cookie Dependency:

WPML uses cookies to keep track of the language settings for AJAX actions.
When multiple tabs are open in the same browser, they all share the same cookie.
As a result, the language setting is overwritten by the most recently opened tab, leading to issues with AJAX content loading.

Issue Scope:
This problem is not specific to the Divi theme but affects any situation where multiple tabs with different languages are open simultaneously.
Resolution and Constraints:

Fixing this issue would require significant changes to the WPML core.
Our team is aware of similar issues but does not have an immediate fix available.

Proposed Workarounds:
To mitigate this issue, we suggest the following workarounds:

Use Different Browsers: Open each language in a separate browser.
Use Incognito Mode: Open each language in an incognito or private browsing window within the same browser. This prevents the sharing of cookies between tabs.
These workarounds should help you manage different language versions of your site without the AJAX content loading issues.

The topic ‘[Closed] Issue regarding Divi Layouts/Library translations’ is closed to new replies.