[wp-trac] [WordPress Trac] #49263: Switching blog doesn't switch locale

WordPress Trac noreply at wordpress.org
Thu Jan 23 16:47:20 UTC 2020


#49263: Switching blog doesn't switch locale
-------------------------+------------------------------
 Reporter:  iandunn      |       Owner:  (none)
     Type:  enhancement  |      Status:  new
 Priority:  normal       |   Milestone:  Awaiting Review
Component:  I18N         |     Version:
 Severity:  normal       |  Resolution:
 Keywords:  2nd-opinion  |     Focuses:  multisite
-------------------------+------------------------------

Comment (by iandunn):

 [attachment:"49263.1.diff"] is a rough start. `switch_to_blog()` needs a
 way to get the new site's locale, but `get_locale()` caches the old one. I
 added a param to bypass that, so that we can reuse the logic there in a
 DRY way.

 That updates `$GLOBALS['locale']`, though, which causes
 `switch_to_locale()` to return early. It looks like modularizing the inner
 logic out of `get_locale()` and into something like `_get_raw_locale()`
 might be the best way, but I'm still playing around with things.

 Let me know if anyone has any feedback.

 We'll also need to account for user locales, and work out how to
 ''restore'' the previous locale and other flags in
 `restore_current_blog()`.

 ---

 I'm also making progress on
 [https://github.com/WordPress/wordcamp.org/compare/6c88df55145b71a1ee34682d97823e92364f0e34...9d7f58b11b6d030caefdfcf954a3b9adbeea5355
 a workaround for sites that need to fix it before this lands], which shows
 some of what may be necessary here.

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


More information about the wp-trac mailing list