[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 17:03: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 has-patch has-unit-      |     Focuses:
  tests dev-feedback                             |
-------------------------------------------------+-------------------------

Comment (by TimothyBlynJacobs):

 The issue is that a custom post type will still have incorrect labels. For
 instance:


 {{{
 add_action( 'init', function() {
   register_post_type( 'my-cpt', [
     'label' => __( 'My CPTs' ),
   ] );
 } );
 }}}

 That label will be translated on `init` and set to a static string in the
 post type object. When the locale is switched it will still be "My CPTs"
 in the site locale as opposed to the desired locale. Core works around
 this by hooking into `change_locale` and re-registering the post type, but
 most people don't listen for that action now. So their strings will be
 untranslated.

 This would apply to any static strings setup, not just CPTs, though CPTs
 are the most obvious example.

 Static as opposed to a function callback that returns the string.

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


More information about the wp-trac mailing list