Set langcode with LegacyEmailBuilder

Created on 8 January 2024, about 1 year ago

Problem/Motivation

When using LegacyEmailBuilder, the email langcode is always set to the current langcode. Since a langcode is provided to the mail method on the MailManager, we should use that langcode.

Proposed resolution

Use the legacy message langcode during the processing in Mailer.

โœจ Feature request
Status

Active

Version

1.4

Component

Code

Created by

๐Ÿ‡จ๐Ÿ‡ญSwitzerland aerzas

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @aerzas
  • Status changed to Needs review about 1 year ago
  • ๐Ÿ‡จ๐Ÿ‡ญSwitzerland aerzas

    Here is a patch proposition.

  • Status changed to Needs work about 1 year ago
  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom adamps

    Thanks for the issue and patch. Strange, I thought I had written code for this already๐Ÿ˜ƒ.

    The issue is only about LegacyEmailBuilder so the fix should also be in the legacy code. I believe we can fix it in LegacyMailerHelper::emailFromArray(). On line 141 there is a call to $email->setAddress(). We can pass a second parameter of $message['langcode']. This should be only for the to address.

    This project now uses merge requests not patches please.

  • First commit to issue fork.
  • Status changed to Needs review about 1 year ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia viren18febs

    This project now uses merge requests not patches please.

    Please review.

  • Pipeline finished with Failed
    about 1 year ago
    Total: 163s
    #77253
  • Status changed to Needs work about 1 year ago
  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom adamps

    Thanks, I mean pass langcode as second parameter to parseAddress()

  • Status changed to Needs review about 1 year ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia viren18febs

    I have updated langcode as second parameter to parseAddress(), please review.

  • Pipeline finished with Success
    about 1 year ago
    Total: 175s
    #78626
  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom adamps

    That looks good to me. @Aerzas please can you test?

  • Status changed to Needs work about 1 year ago
  • ๐Ÿ‡จ๐Ÿ‡ญSwitzerland aerzas

    Thank you for the updated code @viren18febS .

    Unfortunately, it doesn't seem to fix my issue. The langcode is correctly set on the address but it is still the current langcode that it is used by Mailer::doSend. In the context of a legacy email, the __disable_customize__ parameter is set and the langcode processing in the Mailer::doSend method is ended early intentionally, no address is parsed. The address langcode is correct but not the email langcode.

    We could prevent the setting of the __disable_customize__ parameter in LegacyEmailBuilder::createParams, but then the account will also be updated/processed in Mailer::doSend which may have unwanted side effects.

    We could otherwise split the disabling parameter into two: __disable_customize_langcode__ and __disable_customize_account__. This would offer a fine-grained way of handling overrides but will require additional conditions in the process loop.

    Or we could consider that __disable_customize__ only excludes account customization and still gather the langcode from the to addresses.

  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom adamps

    Good point, thanks @Aerzas. How about this?

    - LegacyEmailBuilder creates the To address with the current langcode and also current account. Add an extra param to parseAddress.
    - Remove all code for __disable_customize__

  • ๐Ÿ‡ง๐Ÿ‡ชBelgium yorder.be

    Has there been any progress on this issue?
    Seems quite the priority since this affects all Core user mails.
    Or is there another workaround to be able to send the mails in the correct language?

  • ๐Ÿ‡จ๐Ÿ‡ญSwitzerland aerzas

    @yorder.be The patch I proposed fixes the issue in the meanwhile.

  • ๐Ÿ‡จ๐Ÿ‡ญSwitzerland aerzas

    @AdamPS Thank you for your feedback, I'll work on a new MR as soon as I can.

  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom adamps

    __disable_customize__ has now been removed from 2.x. It should now be a 1 line fix to LegacyMailer::send() to pass $message['langcode'] as the 2nd parameter.

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia koustav_mondal Kolkata
  • Pipeline finished with Success
    12 days ago
    Total: 222s
    #420919
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia koustav_mondal Kolkata

    @adamps Made the changes. Previous MR was forked form 1.4.0 and LegacyMailer class was not present in that specific version. So, pull the latest 2.x-dev and raised new MR-139 and made the changes in that MR. Kindly review it.

  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom adamps

    Thank please see the comment in the MR

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia koustav_mondal Kolkata

    Added 2nd parameter to parseAddress().

  • Pipeline finished with Success
    11 days ago
    Total: 238s
    #421763
Production build 0.71.5 2024