pkp / pkp-lib

The library used by PKP's applications OJS, OMP and OPS, open source software for scholarly publishing.
https://pkp.sfu.ca
GNU General Public License v3.0
306 stars 445 forks source link

Announcement emails do not consider a user's preferred language #10128

Open jnugent opened 4 months ago

jnugent commented 4 months ago

Describe the bug In a multilingual installation, a journal manager can create an announcement in more than one language, based on journal settings. However, when this email is ultimately sent to the user base, the language chosen for the announcement message body is based on the UI choice of the user who is creating the announcement.

The MailTemplate is built using the current user's locale since no locale is passed into the constructor:

https://github.com/pkp/pkp-lib/blob/stable-3_3_0/classes/notification/managerDelegate/AnnouncementNotificationManager.inc.php#L103

Calling:

https://github.com/pkp/pkp-lib/blob/stable-3_3_0/classes/mail/MailTemplate.inc.php#L64

This poses a problem in multilingual journals because users who may not speak the language of the person crafting the announcement end up receiving an email that they cannot understand. This leads to emails being ignored or possibly marked as spam.

The difficulty with fixing this right now is that we do not currently store a user's language preference, although the issue is still open:

https://github.com/pkp/pkp-lib/issues/7702

A possible work around right now would be including all language versions of an announcement in the email, although this becomes unwieldy if there are many languages in the UI.

To Reproduce Steps to reproduce the behavior:

  1. Create an announcement in a multilingual installation
  2. Send the announcement to users and toggle the UI of the interface between tries
  3. Users will receive an announcement based on the UI of the sender

What application are you using? OJS 3.3.0.17

Note: this may affect other emails as well. We've only really noticed it happening with announcements though.

ajnyga commented 2 months ago

@jnugent probably also New Issue Published?

jnugent commented 2 months ago

@ajnyga yes, most likely!