Bỏ qua điều hướng

Open

Topic Tags: Compatibility

Overview of the issue

Users of the Divi theme have encountered an issue where translated library items do not display correctly in the Divi builder when a page includes a custom shortcode. This occurs specifically when the ‘Add from Library’ feature is used while editing translated pages in the Divi builder. The library displays content in the default language instead of the translated language.

Please not that our recommended workflow for translating sites created with Divi is using the Advanced Translation Editor (ATE).

Workaround

Please, make sure of having a full site backup of your site before proceeding.

  • Open your theme’s functions.php file.
  • Add the following code:
    
    
  • With:
    // 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');
    

Alternative Workaround

Use the Advanced Translation Editor (ATE) for translating pages, which avoids issues related to manual translations and ensures that all elements of the page, including those pulled from the library, are correctly displayed in the intended language.

2 phản hồi đến “Divi - Library Items Displaying in Incorrect Language When Using Custom Shortcodes”

Để lại phản hồi

Vui lòng bám sát chủ đề và tôn trọng người khác. Nếu bạn cần trợ giúp với các vấn đề không liên quan đến bài đăng này, hãy sử dụng Diễn đàn Hỗ trợ của chúng tôi để bắt đầu trò chuyện hoặc gửi yêu cầu hỗ trợ.

Bạn có thể sử dụng các thẻ sau:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>