Перейти к содержанию Перейти к боковой панели

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>