Sauter la navigation

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.

Laisser une réponse

Veuillez rester dans le sujet et respecter les autres. Si vous avez besoin d'aide pour des questions qui ne sont pas liées à ce message, utilisez notre Forum d'assistance pour entamer une discussion ou soumettre un ticket.

Vous pouvez utiliser ces balises :
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>