ข้ามไปยังเนื้อหาหลัก ข้ามไปยังแถบด้านข้าง

Waiting for author

Topic Tags: Compatibility, WCML

Overview of the issue

When using Germanized for WooCommerce with WPML, you might experience the following issue: the strings associated with legal checkboxes, such as the label and error message, do not appear in the WPML String Translation interface and cannot be translated.

Workaround

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

  • Add the following code to your theme’s functions.php file.
    // WPML Workaround for compsupp-8083
    if ( class_exists('Sitepress') ) { 
    
    	add_action( 'update_option_woocommerce_gzd_legal_checkboxes_settings', function( $old_value, $new_value ) {
    		$current_lang = apply_filters( 'wpml_current_language', null );
    		update_option( 'woocommerce_gzd_legal_checkboxes_settings_' . $current_lang, $new_value );
    	}, 10, 2 );
    
    	add_filter( 'pre_option_woocommerce_gzd_legal_checkboxes_settings', function( $default ) {
    
    		$current_lang = apply_filters( 'wpml_current_language', null );
    		$translated = get_option( 'woocommerce_gzd_legal_checkboxes_settings_' . $current_lang );
    
    		return is_array( $translated ) ? $translated : $default;
    	});
    	
    }
            

This workaround ensures that the checkbox strings are stored per language. Once added:

  • Go to “WooCommerce > Settings > Germanized > Legal checkboxes > (Your checkbox)” in your default language, make a small edit to the labels, and save.
  • Then switch to the secondary language using the language switcher in the top admin bar, translate the labels, and save.

แสดงความคิดเห็น

โปรดอยู่ในหัวข้อและให้ความเคารพผู้อื่น หากคุณต้องการความช่วยเหลือในประเด็นที่ไม่เกี่ยวข้องกับโพสต์นี้ ให้ใช้ฟอรัมสนับสนุนของเราเพื่อเริ่มการแชทหรือส่งตั๋ว.

คุณสามารถใช้แท็กเหล่านี้:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>