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

WordPress Trac noreply at wordpress.org
Fri Oct 19 09:39:27 UTC 2018


#44758: The REST API is not respecting the user's locale properly.
-------------------------------------------------+-------------------------
 Reporter:  youknowriad                          |       Owner:  pento
     Type:  enhancement                          |      Status:  assigned
 Priority:  normal                               |   Milestone:  5.0
Component:  REST API                             |     Version:
 Severity:  normal                               |  Resolution:
 Keywords:  2nd-opinion has-patch has-unit-      |     Focuses:  rest-api
  tests dev-feedback                             |
-------------------------------------------------+-------------------------

Comment (by swissspidy):

 I don't think a `wp_` prefix is absolutely needed. Not many functions in
 WordPress have that, especially not the i18n functions. A quick search
 through the plugin repository revealed only a single plugin that defined a
 `determine_locale()` function. It's a closed one with no real installs:
 https://wordpress.org/plugins/cartrabbit/

 As for the patch, it feels a bit odd to have that REST API specific code
 in such a low-level function. Perhaps the function could be made
 filterable instead and the REST API specific code is added via that
 filter?

 Also, there is some similar code in `wp-login.php` where the `wp_lang` GET
 param is checked to switch the locale to one of the user's choice (similar
 to how https://login.wordpress.org does it). It currently uses
 `switch_to_locale()` to do so, but with a filterable `determine_locale`
 function that could be leveraged instead.

 Of course these two parts don't necessarily have to be split up into their
 own functions and added via a filter, but a filter in general could still
 be beneficial.

 Happy to iterate on the patch if these suggestions sounds reasonable.

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


More information about the wp-trac mailing list