• Resolved elijahtailor

    (@elijahtailor)


    Hello!

    Add please <body dir="rtl"> to email template for Hebrew and Arabic translations. E-mails sent by form today look awful when written in RTL language. ??

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Takayuki Miyoshi

    (@takayukister)

    You can add them using the wpcf7_mail_html_header filter if it is an HTML mail.

    Thread Starter elijahtailor

    (@elijahtailor)

    I can and I’ve already done that, but it seems a bit strange to add some mandatory for the chosen language stuff using the filters that are usually used for some more precise customisation…

    Plugin Author Takayuki Miyoshi

    (@takayukister)

    I’ll consider adding lang and dir attributes to the <html> element in the future release.

    Did you give it more thought in those months?

    Meanwhile, I’ve tried what you asked and it’s simply ignored as if I didn’t do it.
    Why is that? I do have “Use HTML content type” enabled.

    function filter_wpcf7_mail_html_header($tag) { 
       if (is_rtl()) {
         $tag = preg_replace('/(<body)(>)/', '$1 dir="rtl"$2', $tag);
         file_put_contents('0.log', $tag); // just to prove it actually runs
       }
       return $tag;
    }; 
             
    add_filter( 'wpcf7_mail_html_header', 'filter_wpcf7_mail_html_header');

    Ok, it’s not the plugin’s fault. Turns out some webmail services censor header parts (like body) of messages.
    For everyone interested in supporting RTL, the following seems more compatible.
    I’ve also used auto and not rtl to support message contents in LTR content in RTL sites, and vice versa.
    Although in some cases (e.g. Gmail) it checks the plugin’s translation and not the message’s content (for example, if the word “from” is in English, then “auto” will be LTR even if the message’s content is in a RTL language, and vice versa).

    function filter_wpcf7_mail_html_header($tag) {
       $tag .= '<div dir="auto">';
       return $tag;
    };
    function filter_wpcf7_mail_html_footer($tag) {
       $tag = '</div>' . $tag;
       return $tag;
    };
    
    add_filter( 'wpcf7_mail_html_header', 'filter_wpcf7_mail_html_header');
    add_filter( 'wpcf7_mail_html_footer', 'filter_wpcf7_mail_html_footer');
Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘RTL support for email template’ is closed to new replies.