Make WordPress Core

Opened 7 months ago

Closed 4 months ago

Last modified 3 months ago

#61518 closed enhancement (fixed)

Switch locale to admin locale when sending admin notifications

Reported by: benniledl's profile benniledl Owned by: swissspidy's profile swissspidy
Milestone: 6.7 Priority: normal
Severity: normal Version:
Component: I18N Keywords: has-patch has-unit-tests has-dev-note
Focuses: administration Cc:

Description

This patch takes the locale of the user associated with the admin_email and falls back to the site language if there is no user associated with this email address.

Change History (13)

This ticket was mentioned in PR #6919 on WordPress/wordpress-develop by @benniledl.


7 months ago
#1

  • Keywords has-patch added

This patch adds a new funciton called get_admin_locale it takes the locale of the user associated with the admin_email and falls back to the site language if there is no user associated with this email address.

Also the patch switches to the get_admin_locale function in the admin email notifications instead of get_locale

Trac ticket: https://core.trac.wordpress.org/ticket/61518

#3 @benniledl
7 months ago

Do you think we can milestone this to 6.7? @swissspidy

This ticket was mentioned in Slack in #core-i18n by benniledl. View the logs.


6 months ago

#5 @swissspidy
6 months ago

  • Keywords needs-refresh needs-unit-tests added
  • Milestone changed from Awaiting Review to 6.7

@swissspidy commented on PR #6919:


6 months ago
#6

@at-benni I just pushed some changes to your branch to also update wp_notify_postauthor() and wp_notify_moderator to do the same thing. They're a bit more complex as they loop through a bunch of emails, but they would also benefit from switching to the correct locale per recipient.

We might want to do a single restore_current_locale() instead of doing restore_previous_locale() in a loop, for performance reasons.

In addition to manual testing, this change would benefit from some unit tests. At least wp_new_user_notification has some test coverage already, so we can start there.

This ticket was mentioned in Slack in #core-test by benniledl. View the logs.


5 months ago

This ticket was mentioned in Slack in #core-i18n by benniledl. View the logs.


4 months ago

#9 @swissspidy
4 months ago

  • Owner set to swissspidy
  • Status changed from new to assigned

#10 @swissspidy
4 months ago

  • Resolution set to fixed
  • Status changed from assigned to closed

In 59128:

I18N: Switch locale to admin locale when sending admin notifications.

If sending an email to the site administrator's email address, look up if a user with the same email exists and switch to that user's locale.
If not, falls back to the site locale as usual.

Props benniledl, swissspidy, mukesh27.
Fixes #61518.

#12 @swissspidy
4 months ago

  • Keywords has-unit-tests needs-dev-note added; needs-refresh needs-unit-tests removed

#13 @swissspidy
3 months ago

  • Keywords has-dev-note added; needs-dev-note removed
Note: See TracTickets for help on using tickets.