Translate emails with TranslatePress

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #1581552
    István Tornyos
    Participant

    Hello,

    Has anyone tried to translate emails sent by hotel booking into another language using the TranslatePress translation plugin?

    If so, could you please share your experience in this regard.

    In principle, there is such a function in TranslatePress, but it doesn’t work for me, or I’m doing something wrong. I see that only the title and subject of the email can be translated, which would be enough, but that doesn’t work for me either.

    Someone who has already used it could write how to translate at least the header and subject of the letter with this plugin.

    Or would you suggest another solution for translating emails.

    Thanks
    István

    #1587552
    J. Davis
    Keymaster

    Hi István,
    Just a reminder that the Hotel Booking plugin is compatible with WPML so we recommend it for translating the content added with the Hotel Booking plugin. It allows translating emails as well.

    #1593054
    István Tornyos
    Participant

    Thanks.

    #1634199
    Joffrey Nicoloff
    Participant

    Hello,

    one workaround is to use the TranslatePress shortcode and allow shortcodes in Hotel Booking emails only.

    Add this code to your child theme, custom plugin or snippet plugin :
    It will allow shortcodes in Hotel Booking emails.

    add_action( 'mphb_before_send_mail', 'add_filter_a3w_mphb_wp_mail', 10, 1 );
    add_action( 'mphb_after_send_mail', 'remove_filter_a3w_mphb_wp_mail', 10, 1 );
    
    function add_filter_a3w_mphb_wp_mail( $mailer ) {
    	add_filter( 'wp_mail', 'a3w_mphb_wp_mail', 10, 1 );    
    }
    function remove_filter_a3w_mphb_wp_mail( $mailer ) {
    	remove_filter( 'wp_mail', 'a3w_mphb_wp_mail', 10, 1 );    
    }
    
    function a3w_mphb_wp_mail( $wp_mail ) {
        $wp_mail[ 'subject' ] = do_shortcode( $wp_mail[ 'subject' ] );
        $wp_mail[ 'message' ] = do_shortcode( $wp_mail[ 'message' ] );
        return $wp_mail;
    }

    Now in Hotel Booking emails settings pages, you can use the TranslatePress shortcode [trp_language language="en_US"]Your content only for english[/trp_language] in each fields : Subject, Header and Email Template.

    TranslatePress documentation of shortcode here : https://translatepress.com/docs/restrict-by-language/translation-shortcode/

    In my case, I’m using WPML but I made some tests with TranslatePress on one site using Hotel Booking and I’m sharing my results.

    #1636154
    István Tornyos
    Participant

    Thanks, I’ll try it.

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.