Saltar navegación

Waiting for author

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.

Deje una respuesta

Por favor, mantente dentro del tema y sé respetuoso con los demás. Si necesitas ayuda con cuestiones no relacionadas con este post, utiliza nuestro Foro de soporte para iniciar un chat o enviar un ticket.

Puede utilizar estas etiquetas:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>