[wp-trac] [WordPress Trac] #44758: The REST API is not respecting the user's locale properly.

WordPress Trac noreply at wordpress.org
Thu Aug 23 18:40:47 UTC 2018


#44758: The REST API is not respecting the user's locale properly.
-------------------------+------------------------------
 Reporter:  youknowriad  |       Owner:  (none)
     Type:  enhancement  |      Status:  new
 Priority:  normal       |   Milestone:  Awaiting Review
Component:  REST API     |     Version:
 Severity:  normal       |  Resolution:
 Keywords:  2nd-opinion  |     Focuses:
-------------------------+------------------------------
Changes (by mnelson4):

 * keywords:   => 2nd-opinion


Comment:

 In today's meeting, @TimothyBlynJacobs and I discussed whether the check
 for the locale parameter would be best in `serve_request()` or
 `dispatch()`.

 PROS to `serve_request()`:

 * if we check it before issuing error messages, those error messages could
 be translated
 * `locale` becomes a "global" lifecycle parameter, affecting all internal
 REST API requests (so even if you are going to make internal requests, the
 locale would be set once and reused, which is probably what we usually
 want)

 PROs to `dispatch()`:

 * internal requests can also set `locale`, which they'd probably expect
 * `locale` becomes a "local" lifecycle parameter, affecting only one
 internal REST API request (so it needs to be set on each request)

 @TimothyBlynJacobs and I preferred to do it in `serve_request()`. He said

 > Global requests to `/wp-json/` go through serve_request while internal
 requests only are dispatched. Historically, server level parameters (
 prefixed with an underscore ) are only applied on the server level
 requests... So if we have another server parameter, at this point, I’m not
 sure where it is intended to be handled.

 > FWIW handling just in serve_request would be much simpler.

 but

 > I worry about the inconsistency and I’m not sure where we stand there on
 the API design side of things

 So, we'd like confirmation from component maintainer that setting the
 locale during `serve_request` is a good idea.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/44758#comment:9>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list