one store view, using locale de_DE with some german translations for the order confirmation mail. (the actual language is irrelevant as long as there are translations other than en_US so that the problem is shown)
enable asynchronous mail sending
wait for next cron run and check the order confirmation mail
order confirmation mail is in the language de_DE
order confirmation mail is in the language en_US
when turning off asynchronous mail sending, the mail is sent in the correct language, in our case in german. asynchronous mail sending does not seem to be setting the app store context to the correct store.
The problem is that when executing cron or running a command from the command line, the renderer is not set correctly on the \Magento\Framework\Phrase, i.e. the method public static function setRenderer(RendererInterface $renderer) is not called with the renderer as defined by the di.xml files.
Usually this is done by Magento\Framework\App\Area in the protected function _initTranslate() method.
Find attached a patch, that gets the area from the AreaList and calls the load method with the correct part parameter.
affected are as @ktruehl mentioned all mails generated by cron / from a command line function
Thanks for reporting, internal ticket created MAGETWO-58198
Same here
@ktruehl
Thanks!
this issue seems still present in CE 2.1.3
issue is still present in CE 2.1.4, but https://github.com/magento/magento2/pull/8413 will likely fix it in a future release.
@heldchen, thank you for your report.
The fix for this issue is already available in the develop branch and upcoming 2.2.0 release. See https://github.com/magento/magento2/pull/8413.
Most helpful comment
The problem is that when executing cron or running a command from the command line, the renderer is not set correctly on the
\Magento\Framework\Phrase, i.e. the methodpublic static function setRenderer(RendererInterface $renderer)is not called with the renderer as defined by thedi.xmlfiles.Usually this is done by
Magento\Framework\App\Areain theprotected function _initTranslate()method.Find attached a patch, that gets the area from the
AreaListand calls the load method with the correct part parameter.load_translate_part_of_frontend_area_in_app_emulation-vendor_modulestore_model_app_emulation.diff.zip