System generated email that is sent to the user (account approved, request new password etc) is able to override the users preferred language. Is there any good reason for this?

This could be reproduced by activating the locale module, enabling another language, create a new account with the new language as the preferred language. And then, logout and request a new password. The email will be sent in the sites default language, rather than the users preferred language.

In my opinion, the user should always receive the email in the language that she/he has chosen, with a fallback to the sites default language.

This is easy to achieve, with a simple modification to the _user_mail_notify() function and the corresponding function call in user_pass_submit(). But maybe there's a reason why this works the way it does?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

olofbokedal’s picture

This patch applies my suggested changes.

AdamGerthel’s picture

Status: Active » Needs review

Patch needs testing

Status: Needs review » Needs work

The last submitted patch, 1197400-user_mail_notify-1.patch, failed testing.

webflo’s picture

Title: _user_mail_notify() shouldn't be able to override the users preferred language » Use users preferred language in "request a new password" mails.
Status: Needs work » Needs review
FileSize
821 bytes

I think the optional language argument in _user_mail_notify, but user_pass_submit should not pass the language from the current request.

IcePhenom’s picture

Update patch for drupal 7.38

cilefen’s picture

Title: Use users preferred language in "request a new password" mails. » Use user's preferred language in "request a new password" mails
shortspoken’s picture

I totally agree with @olofjohansson but it's still not fixed. I fiddled around a little bit but could not get it to work in Drupal 7-56.

Isn't there anyone out there who has a fix for this?

zuruckzugehen’s picture

It's true. It doesn't work, either, for Drupal 7.63

poker10’s picture

Title: Use user's preferred language in "request a new password" mails » Use user's preferred language in system emails
Status: Needs review » Needs work

The last patch does not apply anymore. Switching to needs work.

Probably the good idea will be also to test and verify the problem while using i18n module, as mentioned in the duplicate issue here: #1702468: account_activated email language depends on website language - not user preferred language, and check also this scenario (if it working, or not, and if it is a core responsibility to be working). See the steps to reproduce from the referenced issue:

Steps to reproduce:
1) Install drupal, set up registration mode to "user can register; approval required", enable english and russian languages for interface
2) enable i18n_variable module, activate translation for account-related emails
3) translate user_activated email body and subject to russian
4) open website as anonymous, using russian language, create new account
5) open website as admin, using english language, approve new user