跳过导航

Open

Topic Tags: Compatibility

Overview of the issue

Certain strings in the PDF generated by the PDF Invoices & Packing Slips for WooCommerce plugin are not being translated, even though they are translated in WPML’s String Translation. This issue affects labels in invoice and receipt totals.

Workaround

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

  • Open the …/wp-content/plugins/woocommerce-pdf-ips-pro/includes/wcpdf-pro-multilingual-full.php file.
  • Look for line 297.
  • Replace:
    if ( !empty($setting['label']) ) {
    	// WPML
    	if( class_exists('\\SitePress') ) {
    		$setting['label'] = __( $setting['label'], $textdomain );
    	// Polylang
    	} elseif( function_exists('pll__') ) {
    		$setting['label'] = pll__( $setting['label'] );
    	}
    }
    
  • With:
    if ( !empty($setting['label']) ) {
    	// WPML
    	if( class_exists('\\SitePress') ) {
    
    		$setting['label'] = __( $setting['label'], $textdomain ); // HERE
    
    		$textdomain = '	wpo_wcpdf_pro';
    		$string_name = 'PDF String: '.substr($setting['label'], 0, 20);
    
    		do_action( 'wpml_register_single_string', $textdomain, $string_name, $setting['label'] );
    
    		// Apply the translation to the string
    		$setting['label'] = apply_filters('wpml_translate_single_string', $setting['label'] , $textdomain, $string_name);
    
    	// Polylang
    	} elseif( function_exists('pll__') ) {
    		$setting['label'] = pll__( $setting['label'] );
    	}
    }
    
  • Generate a new PDF. This action will register the strings.
  • Go to WPML > String Translation page.
  • Look for the related strings. They should be under the wpo_wcpdf_pro textdomain.
  • Switch the string language to the default language, then translate it.

留下回复

紧扣主题并尊重他人。如果您需要帮助解决与本帖无关的问题,请使用我们的 Support Forum 开始聊天或提交票据。

您可以使用这些标签:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>