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

WordPress Trac noreply at wordpress.org
Fri Sep 14 05:00:20 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 has-patch has-unit-      |     Focuses:
  tests dev-feedback                             |
-------------------------------------------------+-------------------------

Comment (by swissspidy):

 > == Summary of the issue
 >
 > Calling `switch_locale()` during `WP_REST_Server::serve_request()` would
 change the site's locale much later than it normally is (an exception
 being when emailing users, locale switching happens very late in those
 cases). By that point, many strings (including CPT strings) were already
 translated and so will be in the wrong language.
 >
 > So: I think REST API design says we'd prefer to switch the locale during
 `WP_REST_Server::serve_request()`, but all the rest of WP's code expects
 the locale to be set much earlier and not change (with a few exceptions).
 So what do we do?

 Doesn't sound like an issue to me. If we fix the post type label ticket
 first, this is the way to go IMO. That's a perfect use case for
 `switch_to_locale()`.

 As mentioned yesterday, I'll take another stab at #38218.

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


More information about the wp-trac mailing list