• Resolved mobilmacher

    (@mobilmacher)


    Hi there

    I’m using Polylang and Hyyan WooCommerce Polylang Integration (WooPoly) for managing the translation of my shop. In general, Germanized for WooCommerce (WGZD) works great with these plugins, however, I’m having trouble with the translation of various emails and PDFs.

    This generally applies to all emails and PDFs that have been initiated by the admin itself after the customer placed his order (shipment email, packaging slip, cancellation email, cancellation invoice). Other emails (e.g., customer paid for order) and PDFs (e.g., customer invoice), that are sent automatically after the customer placed his order, are translated correctly.

    Emails and PDFs that are initiated by the admin aren’t translated into the order language (English), but the website’s language (German). Thus, it seems that the order language is being ignored for these email and PDF types.

    I checked that the translation of emails is enabled in the WooPoly settings.

    I also tried adding the shipment email (shipment_email) to the WGZD emails via the filters 'woocommerce_gzd_polylang_order_emails' and 'woocommerce_gzd_polylang_emails', but with no luck. I could notice that the cancellation email (customer_invoice_cancellation) is already added within the WGZD Pro plugin, but apparently not being translated.

    Can you reproduce this issue?

    I’m using the latest versions:
    WordPress: 5.3.2
    Avada Theme: 6.1.2
    WooCommerce: 3.9.1
    Germanized for WooCommerce: 3.1.2
    Germanized for WooCommerce Pro: 2.0.12
    Polylang: 2.6.9
    WooPoly: 1.4.3

    and PHP 7.2.18 on an Apache webserver.

    Please let me know if you need additional information.

    Thanks in advance

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author vendidero

    (@vendidero)

    Hi there,

    translating emails is a huge problem. By default, emails triggered by the admin will be sent in the language the admin has chosen within it’s profile. We’ve added explicit compatibility to translate emails using WPML. PolyLang does not natively support email translation for WooCommerce order emails. Maybe you should consider switching to PolyLang Pro (which I guess offers a Woo Plugin itself) to improve email translation. You might need to contact the support beforehand.

    Cheers

    Thread Starter mobilmacher

    (@mobilmacher)

    Thank you for your reply. I contacted the support of the Polylang Pro plugin and they gave me the following answer:

    Emails are sent through actions. And we need to hook Polylang to these actions to translate the email. So Polylang will translate emails only for known actions (the email itself doesn’t matter, only the action name). These actions are the ones used by WooCommerce. If this plugin sends emails upon an action unknown to Polylang, it won’t be translated. If this plugin use the WooCommerce actions so it will work. I recommend you to contact the plugin authors to check with them if they are using the same actions that use WooCommerce to send the emails.

    Do the WGZD and WGZD Pro plugins only use WooCommerce actions or do they use their own?

    Regarding the PDF emails it requires a specific compatibility to generate them in the correct language. … You should ask to the Germanized for WooCommerce Pro authors if they have already included a compatibility with Polylang for WooCommerce in order to translate the PDF.

    As you already stated before, explicit compatibility to translate emails using WPML is given. Can you tell me if this compatibility is also given for PDFs?

    Thread Starter mobilmacher

    (@mobilmacher)

    So, I talked to the Polylang support team. They did some investigation work and came up with the following code, you might consider including in your next update:

    add_action( 'pllwc_init', function() {
    		$actions = array(
    			// order shipped
    			'woocommerce_gzd_shipment_status_draft_to_shipped_notification',
    			'woocommerce_gzd_shipment_status_processing_to_shipped_notification',
    			//order return
    			'woocommerce_gzd_return_shipment_status_draft_to_processing_notification',
    			'woocommerce_gzd_return_shipment_status_requested_to_processing_notification',
    			//order return delivered
    			'woocommerce_gzd_return_shipment_status_processing_to_delivered_notification',
    			'woocommerce_gzd_return_shipment_status_shipped_to_delivered_notification',	
    		);
    
    		foreach ( $actions as $action ) {
    			add_action( $action, function( $shipment_id ) {
    				$shipment = wc_gzd_get_shipment( $shipment_id );
    				PLLWC()->emails->before_order_email( $shipment->get_order() );
    			}, 1 ); // Switch the language for the email
    			
    			add_action( $action, array( PLLWC()->emails, 'after_email' ), 999 ); // Switch the language back after the email has been sent
    		}
    } );

    However, they couldn’t figure out how the “customer invoice cancellation” email is triggered. Can you please tell me how this is done or contact the Polylang support directly at [email protected].

    Thanks

    Plugin Author vendidero

    (@vendidero)

    Hi there,

    the invoice cancellation email is being sent as soon as it was generated and/or the shop administrator used the “send button” to send the invoice to the customer. The woocommerce_gzd_switch_email_locale hook might be used to change the email language of any email sent by Germanized.

    Cheers

    • This reply was modified 4 years, 9 months ago by vendidero.
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Translation with Polylang not working properly for some emails and PDFs’ is closed to new replies.