- Issue created by @mxr576
- ππΊHungary mxr576 Hungary
Templated emails has a locale option, but they are not used by the module atm.
https://github.com/symfony/symfony/commit/d912384b7f2e46c5053e0f42514a9e...
- πΊπΈUnited States zengenuity
Do
$message
arrays typically have alangcode
key in them, or is that something that you're going to add on your site manually withhook_mail_alter
or in thehook_mail
? If so, I think you should be able to just add$message['headers']['X-Langcode']
right there, and it wouldn't require any changes to the module. I think it would only make sense to change the module if Drupal was automatically addinglangcode
and we're currently ignoring that.Also, it appears there is an official header for language, and it's
Content-Language
: https://www.rfc-editor.org/rfc/rfc4021.html#section-2.2.10. So, if we add something to the module, we should probably try to use that. - ππΊHungary mxr576 Hungary
MailManagerInterface
requires a langcode to be specified every time and the defaultMailManager
implementation does add that to the $message payload: https://github.com/drupal/core/blob/10.3.0/lib/Drupal/Core/Mail/MailMana....Also, it appears there is an official header for language, and it's Content-Language: https://www.rfc-editor.org/rfc/rfc4021.html#section-2.2.10. So, if we add something to the module, we should probably try to use that.
Good catch, thumbs up on that!
- ππΊHungary mxr576 Hungary
I am considering to open a Drupal core issue (over the weekend) for adding the Content-Language header to all emails sent by the mail manager...
- πΊπΈUnited States zengenuity
Okay, I'm also fine with coding the header into this module, given that
$langcode
should always be present in the$message
array. We should just have a check to make sure it's notLANGUAGE_NONE
. In that case, we should skip the header.