WordPress.org

Make WordPress Core

Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#38482 closed defect (bug) (fixed)

Admin notices in the wrong language when switching language

Reported by: afercia Owned by: ocean90
Milestone: 4.7 Priority: normal
Severity: normal Version: 4.7
Component: I18N Keywords: has-screenshots has-patch needs-testing
Focuses: Cc:

Description

To reproduce, on trunk go in the Settings pages and, for example, change the admin language from English to German. Save and after the page reloads, the admin is in German but the notice is in English:

https://cldup.com/Zw01-1y-H4.png

Switch back to English, save, and the admin will be in English but the notice in German:

https://cldup.com/_ioKOMunEJ.png

Attachments (3)

38482.diff (709 bytes) - added by swissspidy 4 years ago.
38482.2.diff (916 bytes) - added by ocean90 4 years ago.
38168.3.diff (1.1 KB) - added by ocean90 4 years ago.
+ comment

Download all attachments as: .zip

Change History (17)

#1 follow-up: @swissspidy
4 years ago

What's the user's language?

#2 in reply to: ↑ 1 @afercia
4 years ago

Replying to swissspidy:

What's the user's language?

Initially English US. When I switch "Site Language" to German, the Language under my profile changes to "Deutsch".

#3 @swissspidy
4 years ago

  • Keywords needs-patch added
  • Owner set to swissspidy
  • Status changed from new to assigned

OK, in that case the user doesn't have a locale set yet. Under these circumstances I am able to reproduce this issue.

#4 @afercia
4 years ago

Yep can confirm I had no locale usermeta set, yet.

@swissspidy
4 years ago

#6 @swissspidy
4 years ago

  • Keywords has-patch needs-testing added; needs-patch removed

Patch attached. Happy testing!

#7 follow-up: @swissspidy
4 years ago

Note that 38482.diff doesn't unload text domains as $language is never empty. I used $GLOBALS['locale'] because later on in the file the settings errors are saved and the user gets redirected.

@ocean90 Perhaps you wanna chime in?

This ticket was mentioned in Slack in #core by helen. View the logs.


4 years ago

#9 @ocean90
4 years ago

  • Owner changed from swissspidy to ocean90
  • Status changed from assigned to reviewing

#10 in reply to: ↑ 7 @ocean90
4 years ago

Replying to swissspidy:

Note that 38482.diff doesn't unload text domains as $language is never empty.

$language is empty when the site language is set to en_US. Changing the site language from de_DE to en_US shows the admin notice in German with 38482.diff.

@ocean90
4 years ago

#11 @ocean90
4 years ago

38482.2.diff should do it by comparing get_user_locale() before and after.

@ocean90
4 years ago

+ comment

#12 @swissspidy
4 years ago

Works like a charm on single sites and multisite alike.

#13 @ocean90
4 years ago

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

In 39122:

I18N: Show "Settings saved." in the correct language after switching the site language.

This simplifies the logic by comparing get_user_locale() before and after an settings update.

Props swissspidy, ocean90.
See #29783, #29281.
Fixes #38482.

#14 @ocean90
4 years ago

#38662 was marked as a duplicate.

Note: See TracTickets for help on using tickets.