Open
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.