flarum / issue-archive

0 stars 0 forks source link

Email notifications language #103

Open jaspervriends opened 3 years ago

jaspervriends commented 3 years ago

Bug Report

Current Behavior Currently email notifications are being sent in the language of the poster (using the user interface language) .

Running international forums with multiple languages would be more interesting if this system works better (or more standardized).

Now, for example, when you have enabled Dutch and English language pack on a forum and a Dutch person replies to an English person, the recipients (and subscribers) will receive a Dutch email about the new post (or mention). The same is happening the way around and with any other type of email.

Steps to Reproduce

  1. Enable two or more language packs
  2. Make two or more having different language selected
  3. Create a topic
  4. Enable email notifications for the users
  5. Reply or mention with another user that has selected a different language
  6. User will receive an email in a different language then their previous selected language

Expected Behavior I expect that when an email notification is being sent to a user, the translation keys will check the user language setting (if selected previously) and othwerise fallback to the default forum language.

Screenshots Below you can see the current behaviour when sending emails in different languages.

image

Environment

Possible Solution There's a $locale value in the Translator, but as far as I know this isn't being used in any extension to look at the reciever language. For example, see UserMentionedBlueprint.php#L68 file for mentions and this file in subscriptions).

I think it would be great to have something like this properly standardized (or having a different solution) and make sure it's implemented into all core extensions as well.

askvortsov1 commented 3 years ago

This ties into https://github.com/flarum/core/issues/2763. Ideally, we could pass in the user whenever translating, but the user is not always available. For this particular case, we could just override the translator locale when executing queued jobs.