I have a problem that transactional emails like order comment or shipment comment are sent alsways in english instead of store language.
Tried already a lot with setting areaCodes, StoreIds and so on.
Everytime english even if store 3 (german) is set.
$storeId = 3; /// Get Website ID $state = $objectManager->get('Magento\Framework\App\State'); $state->setAreaCode(\Magento\Framework\App\Area::AREA_FRONTEND, 'store' => $storeId); // AREA_ADMINHTML or // AREA_GLOBAL $storeManager = $objectManager->get('\Magento\Store\Model\StoreManagerInterface'); $websiteId = $storeManager->getWebsite()->getWebsiteId(); $storeManager->setCurrentStore($storeId); $Order_ID=53; $order = $objectManager->create('\Magento\Sales\Model\Order')->load($Order_ID); $comments="Ist versendet"; $orderCommentSender = $objectManager ->create('Magento\Sales\Model\Order\Email\Sender\OrderCommentSender'); $orderCommentSender->send($order, true, $comments);
Any Ideas?
Hello Mobilize,
Please check your html file of mail template and be sure that the string should be inside {{trans}} directive.
{{trans "Thank you for your order from %store_name." store_name=$store.getFrontendName()}}
Also check that the string translation is present in translation csv file and then deploy the static content for that locale.
For more detail please refer the link
Hope it will help you.
Hola,
Tenemos el mismo problema, cuando los emails se envían desde la tienda la traducción funciona, pero cuando lo hacemos mediante programación se envían siempre en inglés.
@Mobilize llegaste a solucionarlo? Si es así serías tan amable de compartir la solución, por favor.
Gracias!
Hello, @Mobilize
We have exactly the same issue. The emails are send correctly translated from the website, but when we create an order programmatically the email with he order resume is send always in english.
In case you solved the problem would you be so kind to share the solution with us, please?
Thanks!
Seems like you need to load translator as it is not there if you trying to sent it programmatically.
$objectManager->get('\Magento\Framework\View\DesignLoader')->load(\Magento\Framework\App\Area::PART_TRANSLATE);
Also if needed you should be able to change language to another one by using localeInterface:
$localeInterface = $objectManager->create('Magento\Framework\Locale\ResolverInterface'); $localeInterface->setLocale('de_DE'); $localeInterface->setDefaultLocale('de_DE');