Commit 932c3a62278 for woocommerce

commit 932c3a62278b6eedc29364733599d24af11b9a72
Author: Yuliyan Slavchev <yuliyan.slavchev@gmail.com>
Date:   Fri Oct 23 16:47:56 2026 +0300

    Use site language for block emails instead of hardcoded 'en' (#70175)

    * Use site language for block emails instead of hardcoded 'en'

    * Control the language translation in the block email language test

diff --git a/plugins/woocommerce/changelog/wooplug-8073-block-emails-site-language b/plugins/woocommerce/changelog/wooplug-8073-block-emails-site-language
new file mode 100644
index 00000000000..31557010735
--- /dev/null
+++ b/plugins/woocommerce/changelog/wooplug-8073-block-emails-site-language
@@ -0,0 +1,4 @@
+Significance: patch
+Type: fix
+
+Send block editor emails in the site language and text direction, so right-to-left sites get right-to-left emails.
diff --git a/plugins/woocommerce/src/Internal/EmailEditor/BlockEmailRenderer.php b/plugins/woocommerce/src/Internal/EmailEditor/BlockEmailRenderer.php
index 25b1166fdea..641be4c0974 100644
--- a/plugins/woocommerce/src/Internal/EmailEditor/BlockEmailRenderer.php
+++ b/plugins/woocommerce/src/Internal/EmailEditor/BlockEmailRenderer.php
@@ -139,9 +139,9 @@ class BlockEmailRenderer {
 			$preheader = $wc_email->get_preheader();

 			if ( $email_post ) {
-				$rendered_email_data = $this->renderer->render( $email_post, $subject, $preheader, 'en' );
+				$rendered_email_data = $this->renderer->render( $email_post, $subject, $preheader, get_bloginfo( 'language' ) );
 			} else {
-				$rendered_email_data = $this->renderer->render_from_content( $file_template_content, ( new WooEmailTemplate() )->get_slug(), $subject, $preheader, 'en' );
+				$rendered_email_data = $this->renderer->render_from_content( $file_template_content, ( new WooEmailTemplate() )->get_slug(), $subject, $preheader, get_bloginfo( 'language' ) );
 			}

 			$personalized_email = $this->personalizer->personalize_content( $rendered_email_data['html'] );
diff --git a/plugins/woocommerce/tests/php/src/Internal/EmailEditor/BlockEmailRendererTest.php b/plugins/woocommerce/tests/php/src/Internal/EmailEditor/BlockEmailRendererTest.php
index 8aafd9e47d8..b695e0bd8f5 100644
--- a/plugins/woocommerce/tests/php/src/Internal/EmailEditor/BlockEmailRendererTest.php
+++ b/plugins/woocommerce/tests/php/src/Internal/EmailEditor/BlockEmailRendererTest.php
@@ -317,6 +317,52 @@ class BlockEmailRendererTest extends \WC_Unit_Test_Case {
 		$this->assertStringContainsString( $test_woo_content, $rendered_email, 'The Woo content placeholder must be replaced in the file template output' );
 	}

+	/**
+	 * @testdox Should render the email with the site language and text direction.
+	 * @dataProvider provide_render_sources
+	 *
+	 * @param string $email_id Email ID that selects the rendering source.
+	 */
+	public function testItRendersWithSiteLanguageAndDirection( string $email_id ): void {
+		$this->skip_if_unsupported_environment();
+
+		$wc_mail_mock = $this->create_wc_email_mock( $email_id, 'Test Woo Content' );
+
+		$this->personalizer->set_context(
+			array(
+				'wc_email'        => $wc_mail_mock,
+				'recipient_email' => $wc_mail_mock->get_recipient(),
+			)
+		);
+
+		// get_bloginfo( 'language' ) reads this translation, as on a real Arabic site.
+		$lang_filter = function ( $translation, $text, $domain ) {
+			return 'html_lang_attribute' === $text && 'default' === $domain ? 'ar' : $translation;
+		};
+		add_filter( 'gettext', $lang_filter, 10, 3 );
+		try {
+			$rendered_email = $this->block_email_renderer->maybe_render_block_email( $wc_mail_mock );
+		} finally {
+			remove_filter( 'gettext', $lang_filter, 10 );
+		}
+
+		$this->assertNotNull( $rendered_email );
+		$this->assertStringContainsString( 'lang="ar"', $rendered_email );
+		$this->assertStringContainsString( 'dir="rtl"', $rendered_email );
+	}
+
+	/**
+	 * Email IDs that render from the saved post and from the file template.
+	 *
+	 * @return array<string, array{0: string}>
+	 */
+	public function provide_render_sources(): array {
+		return array(
+			'saved post'    => array( 'test_email' ),
+			'file template' => array( 'email_without_mapping' ),
+		);
+	}
+
 	/**
 	 * Build a WC_Email mock whose block template resolves to the default block content file.
 	 *