Send notification emails in the recipient's preferred language#431
Send notification emails in the recipient's preferred language#431
Conversation
Co-authored-by: Alanaktion <236490+Alanaktion@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR fixes notification email localization by switching template rendering to run per-recipient using each recipient’s stored language preference, instead of using the sender/current session language.
Changes:
- Updated issue notification senders to render templates inside the per-recipient loop and temporarily switch
LANGUAGEfor each recipient. - Extended
_issue_watchers()to returnemail+languagepairs and adjusted related SQL queries (including group membership lookup). - Added
_set_language(?string $language): stringhelper and applied it to non-issue notifications (user_reset,user_due_issues).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
app/helper/notification.php
Outdated
| $original = (string) $f3->get("LANGUAGE"); | ||
| if ($language) { | ||
| $f3->set("LANGUAGE", $language); | ||
| } | ||
| return $original; |
There was a problem hiding this comment.
_set_language() always casts the previous LANGUAGE to a string and callers always restore via set("LANGUAGE", $previous). If LANGUAGE was previously unset/null, this forces it to "" on restore, which can change how locale fallback behaves. Consider tracking whether LANGUAGE originally existed and using clear("LANGUAGE") (or not restoring) when it didn’t.
There was a problem hiding this comment.
@copilot apply changes based on this feedback
If the original value was null, it should be null when changing back. Don't skip restoring.
There was a problem hiding this comment.
Fixed in 348ff36. Changed the return type of _set_language() from string to ?string and removed the (string) cast when reading the original value, so a null LANGUAGE is preserved and restored as null rather than "".
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Alanaktion <236490+Alanaktion@users.noreply.github.com>
_issue_watchers()to return email + language per recipient_set_language()helper to temporarily set language per recipient_set_language()return type to?stringand remove(string)cast so anullLANGUAGE is restored asnull, not""Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.