-
Notifications
You must be signed in to change notification settings - Fork 9.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Translation does not work for email invoice_new template item layout #7426
Comments
Hi there, In synchronous mode the translation gets initialized like that: The async mode gets triggered by Magento cron. There is no controller action and therefore the translation is completely missing. As long as Magento does not provide a fix for that, we have to do it on our own. It is indeed a bit tricky to initialize it anyway.
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<type name="Magento\Sales\Model\EmailSenderHandler">
<plugin name="sendSalesEmails" type="Vendor\Module\Plugin\EmailSenderHandler"/>
</type>
</config>
<?php
namespace Vendor\Module\Plugin;
use \Magento\Framework\App\Config\ScopeConfigInterface;
use \Magento\Framework\App\AreaList;
use \Magento\Framework\App\State;
use \Magento\Framework\App\Area;
class EmailSenderHandler
{
/**
* @var ScopeConfigInterface
*/
private $globalConfig;
/**
* @var AreaList
*/
private $areaList;
/**
* @var State
*/
private $appState;
/**
* EmailSenderHandler constructor.
* @param ScopeConfigInterface $globalConfig
* @param AreaList $areaList
* @param State $appState
*/
public function __construct(
ScopeConfigInterface $globalConfig,
AreaList $areaList,
State $appState
){
$this->globalConfig = $globalConfig;
$this->areaList = $areaList;
$this->appState = $appState;
}
/**
* Initializes the translation if emails get send async by cron
* This is a core bug and can be removed when this is solved:
* https://github.com/magento/magento2/issues/7426
*/
public function beforeSendEmails()
{
if ($this->globalConfig->getValue('sales_email/general/async_sending')) {
$area = $this->areaList->getArea($this->appState->getAreaCode());
$area->load(Area::PART_TRANSLATE);
}
}
} |
@ostmond, thank you for your report. |
B2B-2135, B2B-212, B2B-2152 combined PR
Preconditions
Steps to reproduce
Expected result
Actual result
The text was updated successfully, but these errors were encountered: