Skip to content Skip to sidebar

This thread is resolved. Here is a description of the problem and solution.

Problem:
The client reported an issue where the admin receives New Order Emails in Hebrew with incorrect left alignment, despite the admin's language setting being Hebrew. This misalignment occurs when the site language is set to English, and the admin's language is set to Hebrew.
Solution:
We confirmed that this issue is specific to WPML handling Hebrew language emails. We have escalated the problem to our development team for a permanent fix. Meanwhile, we recommend setting the admin language to Hebrew before changing the status of an order that will send an email. Additionally, you can try adding the following code snippet to your theme's functions.php file, but please ensure you have a backup before implementing:

/**
 * Fix the text direction attribute when switching language to an RTL language.
 *
 * @see https://onthegosystems.myjetbrains.com/youtrack/issue/wcml-3838/
 */
add_action( 'wpml_language_has_switched', function ( $newLangCode ) {
    /**
     * @var \WP_Locale|\WPML\ST\MO\WPLocaleProxy $wp_locale
     * @var string                               $text_direction
     * @var \SitePress                           $sitepress
     */
    global $wp_locale, $text_direction, $sitepress;

    static $secondaryWPLocales = [];

    if (
            $wp_locale instanceof \WPML\ST\MO\WPLocaleProxy
            && $sitepress->is_rtl( $newLangCode )
    ) {
        if ( ! isset( $secondaryWPLocales[ $newLangCode ] ) ) {
            $text_direction_bk                  = $text_direction;
            $text_direction                     = 'rtl';
            $secondaryWPLocales[ $newLangCode ] = new \WP_Locale();
            $text_direction                     = $text_direction_bk;
        }

        $wp_locale = $secondaryWPLocales[ $newLangCode ];
    }
}, 20 );

Please note that this solution might be irrelevant if it's outdated or not applicable to your case. We highly recommend checking related known issues at https://wpml.org/known-issues/, verifying the version of the permanent fix, and confirming that you have installed the latest versions of themes and plugins. If the issue persists, please open a new support ticket at WPML support forum.

This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

This topic contains 10 replies, has 1 voice.

Last updated by Dražen 3 months, 1 week ago.

Assisted by: Dražen.

Author Posts
May 7, 2025 at 1:38 pm #17006844

rayaA

Background of the issue:
I created a fresh new WooCommerce store on a website with the default language set to English. The Admin's language is Hebrew. The customer places an order on the English website and receives their email in English with correct alignment. The Admin receives the New Order Email in Hebrew.

Symptoms:
Email sent in Hebrew to Admin was aligned to the left instead of the expected right alignment.

Questions:
Why is the email alignment incorrect for the Admin's New Order Email in Hebrew?
How can I ensure the email is aligned to the right for Hebrew language emails?

May 8, 2025 at 9:40 am #17010562

Bruno Kos
WPML Supporter since 12/2018

Languages: English (English ) German (Deutsch ) French (Français )

Timezone: Europe/Zagreb (GMT+01:00)

Hi,

On this sandbox
hidden link

Can you set site language as Hebrew:
hidden link

And order some product? Don't install or activate WPML. I installed hidden link as well.

This will tell us if this is about general email translations of the way WPML handles them for the Hebrew language.

May 10, 2025 at 5:35 pm #17019314

rayaA

Hi,
You asked that I would set the site language as Hebrew, however in the case that I reported the site's language is English, and the Admin user language is Hebrew.

So in the sandbox that you provided, I set the site language as English, and the admin's language as Hebrew.
I placed an order from the English site, and the email that is sent to the admin is sent in English and aligned left to right.
That would be the first email with "Your Sandbox order has been received!" subject.

After doing so, I set the site language to Hebrew (as you requested) and placed another order.
This time the email received has a right to left alignment (which is the correct alignment for Hebrew).
That would be the second email with "Your Sandbox order has been received!" subject.

So it seems like the admin user language has no effect, but the website's language has an effect.

May 12, 2025 at 6:56 am #17021104

Dražen
Supporter

Languages: English (English )

Timezone: Europe/Zagreb (GMT+02:00)

Hello,

Thanks for taking the time to test this, it seems to work fine on the test site and without WPML.

Can you please set up WPML and try to reproduce the same issue on the test site? This will tell us if this specific WPML issue or bug.

Regards,
Drazen

May 12, 2025 at 11:15 am #17022501

rayaA

In the installation that you provided for me, the email sent to the admin is in English even if the admin chose Hebrew for his language in his profile settings. Maybe it's because I did not translate the WooCommerce but when I try to do that it says that I need credits which I do not have on this site set up by your team.
I have a staging site with minimal installations (WooCommerce, WPML, WCML, String translations, WP Mail Logging and nothing else active) where I was able to reproduce this problem, where can I share the login details?

May 12, 2025 at 12:20 pm #17022873

Dražen
Supporter

Languages: English (English )

Timezone: Europe/Zagreb (GMT+02:00)

Hello,

Thanks for getting back.

I have checked further on the test site, and I was able to reproduce the issue and confirm it. It happens only with WPML; without it works fine.

I have now escalated this issue further to our 2nd tier to check and advise further.

I will update soon when I have some news. Note,it may take a day or two.

Regards,
Drazen

May 12, 2025 at 12:51 pm #17023118

rayaA

No problem, we will be updated with this issue. Thank you very much for your assistance.

May 21, 2025 at 7:29 am #17055345

Dražen
Supporter

Languages: English (English )

Timezone: Europe/Zagreb (GMT+02:00)

Hello,

thanks for the patience, note we have confirmed and escalated this issue to our devs. We will be working on permanent fix, but note it will take time.

We do not have a valid workaround at this point.

I will update when I have some news.

Regards.
Drazen

May 26, 2025 at 10:52 am #17072669

rayaA

Thank you.

July 28, 2025 at 1:32 pm #17275422

rayaA

Greetings,
I found out that this issue also happens if a customer places an order in Hebrew. The "Processing order" email that is sent to the customer upon payment has the correct alignment (because the user is using the website in Hebrew). However, if an admin logs in to the website from English, and sets the status of the order to completed, the customer will receive the "Completed order" email in Hebrew but with the wrong alignment (ltr instead of rtl).

Seems like this problem only happens when the person that initiates the action that ends up with sending the email, is doing so from a language that has a direction opposite of the recipient's language direction.

Since this affects our customers and not just the admin, I was wondering if you have a snippet of code or workaround to use in the meanwhile to make sure that emails that are sent in Hebrew to Hebrew reading users are always aligned rtl even if the initiator of the email sent is doing so from an ltr language.

Thank you

July 28, 2025 at 1:42 pm #17275572

Dražen
Supporter

Languages: English (English )

Timezone: Europe/Zagreb (GMT+02:00)

Hello,

thanks for sharing info.

The fix is scheduled for next WCML version, which should be released soon, together with WPML 4.8, probably in few weeks.

For now best is to change admin language to Hebrew before changing status of order that will send an email.

You can also try to add next snippet to your theme functions.php, but use it with caution and make sure to have a backup, just in case.

/**
 * Fix the text direction attribute when switching language to an RTL language.
 *
 * @see <em><u>hidden link</u></em>
 */
add_action( 'wpml_language_has_switched', function ( $newLangCode ) {
    /**
     * @var \WP_Locale|\WPML\ST\MO\WPLocaleProxy $wp_locale
     * @var string                               $text_direction
     * @var \SitePress                           $sitepress
     */
    global $wp_locale, $text_direction, $sitepress;

    static $secondaryWPLocales = [];

    if (
            $wp_locale instanceof \WPML\ST\MO\WPLocaleProxy
            && $sitepress->is_rtl( $newLangCode )
    ) {
        if ( ! isset( $secondaryWPLocales[ $newLangCode ] ) ) {
            $text_direction_bk                  = $text_direction;
            $text_direction                     = 'rtl';
            $secondaryWPLocales[ $newLangCode ] = new \WP_Locale();
            $text_direction                     = $text_direction_bk;
        }

        $wp_locale = $secondaryWPLocales[ $newLangCode ];
    }
}, 20 );

Regards,
Drazen