[wp-trac] [WordPress Trac] #47547: switch_to_locale( 'en_US' ) is unreliable

WordPress Trac noreply at wordpress.org
Thu Jul 4 03:11:50 UTC 2019


#47547: switch_to_locale( 'en_US' ) is unreliable
--------------------------+------------------------------
 Reporter:  johnbillion   |       Owner:  (none)
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  I18N          |     Version:
 Severity:  normal        |  Resolution:
 Keywords:  needs-patch   |     Focuses:  administration
--------------------------+------------------------------

Old description:

> Given a site that uses `en_US` as its language, a user with their user
> language set to something else, and that user logged into the admin
> dashboard, calling `switch_to_locale( 'en_US' )` appears to be
> unreliable.
>
> 1.  The return value of `determine_locale()` is the user's language, not
> `en_US`.
> 2.  Localised text without a textdomain (ie. text from core) is correctly
> displayed in `en_US`.
> 3.  Localised text with a textdomain (ie. text from plugins or themes) is
> incorrectly displayed in the user's language. This may be related to
> #39210.
>
> Given a site that itself uses a language other than `en_US`, calling
> `switch_to_locale( 'en_US' )` does appear to work although I haven't
> tested it extensively.

New description:

 Given a site that uses `en_US` as its language, a user with their user
 language set to something else, and that user logged into the admin
 dashboard, calling `switch_to_locale( 'en_US' )` appears to be unreliable.

 1.  ❌The return value of `determine_locale()` is the user's language, not
 `en_US`.
 2.  ✅Localised text without a textdomain (ie. text from core) is
 correctly displayed in `en_US`.
 3.  ❌Localised text with a textdomain (ie. text from plugins or themes)
 is incorrectly displayed in the user's language. This may be related to
 #39210.

 Given a site that itself uses a language other than `en_US`, calling
 `switch_to_locale( 'en_US' )` does appear to work although I haven't
 tested it extensively.

--

Comment (by garrett-eclipse):

 Sorry about the emoji's disappearing, was fixed in
 [https://meta.trac.wordpress.org/ticket/3838 meta#3838] so added them
 back.

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


More information about the wp-trac mailing list