Opened 7 years ago
Closed 3 years ago
#47547 closed defect (bug) (invalid)
switch_to_locale( 'en_US' ) is unreliable
| Reported by: | johnbillion | Owned by: | johnbillion |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | I18N | Version: | |
| Severity: | normal | Keywords: | needs-patch reporter-feedback close |
| Cc: | Focuses: | administration |
Description (last modified by )
Given a site that uses en_US as its language, a user with their user language set to something else, and that user logged into the admin dashboard, calling switch_to_locale( 'en_US' ) appears to be unreliable.
- ❌The return value of
determine_locale()is the user's language, noten_US. - ✅Localised text without a textdomain (ie. text from core) is correctly displayed in
en_US. - ❌Localised text with a textdomain (ie. text from plugins or themes) is incorrectly displayed in the user's language. This may be related to #39210.
Given a site that itself uses a language other than en_US, calling switch_to_locale( 'en_US' ) does appear to work although I haven't tested it extensively.
Change History (8)
#2
@
7 years ago
- Description modified (diff)
Sorry about the emoji's disappearing, was fixed in meta#3838 so added them back.
Note:
See TracTickets
for help on using tickets.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
I may be off-base but I believe some findings here can shed some light;
"switch_to_locale() only does something if the locale passed to it is different than the value of get_locale() outside of the admin. Inside the admin, it only switches if it's different than the locale of the current user."