Skip to content

[5.9]: system messages / preferred locale #18787

@rauwebieten

Description

@rauwebieten

What happened?

Description

System messages always use the preferred language from the user profile, even if it is called from a frontend site request in another site language.

Steps to reproduce

I have 2 websites, two different locales (language).
For example EN en FR
I have a password-reset form, with an action request to "users/send-password-reset-email"

Expected behavior

I'd expect the mail in the language taken from the current site.

Actual behavior

This mail is always sent in language according to the the users preferredLanguage.
Not in the language from the current site request.
(the link to set-password is in the site request's locale though)

Example:
User has preferred language EN
Visits frontend site FR
triggers password reset on FR page

Mail is rendered in EN language (because of preffered language)
But the link in the mail leads to the FR website.

See vendor/craftcms/cms/src/mail/Message.php line 96:
if the recipient is a user, and the user has a preferred language, it is set as the language in the message.

Craft CMS version

Craft Pro 5.9.18

PHP version

8.2.30

Operating system and version

Debian

Database type and version

Mysql

Image driver and version

No response

Installed plugins and versions

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions