[wp-trac] [WordPress Trac] #57945: Locale bug in short-circuited WP REST API request via rest_pre_dispatch?

WordPress Trac noreply at wordpress.org
Sun Mar 19 15:34:44 UTC 2023


#57945: Locale bug in short-circuited WP REST API request via rest_pre_dispatch?
-------------------------------------+------------------------------
 Reporter:  joeyojoeyo12             |       Owner:  (none)
     Type:  defect (bug)             |      Status:  new
 Priority:  normal                   |   Milestone:  Awaiting Review
Component:  REST API                 |     Version:  6.1.1
 Severity:  normal                   |  Resolution:
 Keywords:  reporter-feedback close  |     Focuses:
-------------------------------------+------------------------------

Comment (by joeyojoeyo12):

 Hi there, thanks for the fast reply.

 Adding {{{?_locale=site}}} to the REST API requests' route from the
 requesting client did not change anything in the above-mentioned
 behaviour. Please note that the locale is correct. If I echo get_locale()
 right before returning the WP_Error instance in my callback hooked onto
 rest_pre_dispatch, I get the correct locale. But the message of the
 returned WP_Error, written via __('to be translated','my'plugin'), and
 having an according translation in the plugins' mo and po files as
 mentioned above, is not returned in the requests' locale, but in the
 sites' default locale instead. Please note again that this behaviour only
 happens for requests which are short-circuited via the rest_pre_dispatch
 hook.

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


More information about the wp-trac mailing list