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

WordPress Trac noreply at wordpress.org
Thu Sep 6 19:04:37 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 mnelson4):

 == 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?

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


More information about the wp-trac mailing list