#38632 closed defect (bug) (fixed)
Ability to change a user language back to site's language is missing
Reported by: | ocean90 | Owned by: | swissspidy |
---|---|---|---|
Milestone: | 4.7 | Priority: | normal |
Severity: | normal | Version: | 4.7 |
Component: | I18N | Keywords: | has-patch has-unit-tests commit |
Focuses: | administration | Cc: |
Description
Previously: #29783 and related discussion on Slack
In the admin (and via REST API #38528) it's currently not possible to set a user language back to site's language. get_user_locale()
falls back to get_locale()
only if the meta field is a falsy value.
wp_dropdown_languages()
uses an empty string value for en_US
which gets replaced with en_US
in https://core.trac.wordpress.org/browser/trunk/src/wp-admin/includes/user.php?rev=38705&marks=99-106#L99.
I'm not sure if there really needs to be a way for this so I'm moving this to 4.7 for a decision.
Attachments (5)
Change History (19)
#3
@
8 years ago
- Keywords has-unit-tests added
38632.3.diff adds the empty string to the locales enum. @joehoyle How does this look to you?
#4
@
8 years ago
@ocean90 I think that would work, If you updated to ''
, I presume the locale would show as en_US
in the response?
#5
@
8 years ago
@joehoyle No, it'd be the value of get_locale()
, see 38632.4.diff and get_user_locale()
.
#6
@
8 years ago
@ocean90 Hmm ok, my only concern with this is it's not easy to localize things for API clients when the majority of users are going to have the site's locale (that's by default anyway), which renders this field fairly useless in the case of the REST API. It seems like most of the time one would need to get the site's locale "global" setting rather than relying on this fields, as this field is going to be ''
most of the time.
I'm tempted to suggest that the API's value for a user's locale should fall through to the site's default, so it's more usable for api consumers. Like settings, you could then send locale => null
to the REST API reset it to it's default (site setting), under the hood this would just set it to an empty string of course.
This ticket was mentioned in Slack in #core-restapi by ocean90. View the logs.
8 years ago
#8
@
8 years ago
After chatting to @ocean90 in slack - I think we are good here as far as the api is concerned, I had misunderstood the "default value" behaviour, as it is, actually set to the site's locale, in which case API consumers can just rely on this field always when showing user-specific locales.
This ticket was mentioned in Slack in #core by helen. View the logs.
8 years ago
#10
@
8 years ago
- Owner set to swissspidy
- Status changed from new to reviewing
Can't I get a final review, @swissspidy? Thanks!
#11
@
8 years ago
- Keywords commit added; 2nd-opinion removed
In 38632.5.diff:
- Fix the order of
sprintf()
arguments - Add docs
- Add unit tests for
wp_dropdown_languages()
38632.2.diff:
lang
attribute since it's in the same language as the current pagesite-default
as the value for the site language