跳转至内容 跳转至侧边栏

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>