[wp-trac] [WordPress Trac] #26511: Introduce a locale-switching function

WordPress Trac noreply at wordpress.org
Wed Sep 21 15:18:22 UTC 2016


#26511: Introduce a locale-switching function
--------------------------------------+------------------------
 Reporter:  johnbillion               |       Owner:
     Type:  feature request           |      Status:  reviewing
 Priority:  normal                    |   Milestone:  4.7
Component:  I18N                      |     Version:
 Severity:  normal                    |  Resolution:
 Keywords:  has-patch has-unit-tests  |     Focuses:
--------------------------------------+------------------------

Comment (by swissspidy):

 Replying to [comment:55 ocean90]:
 > [attachment:26511.4.diff] looks good so far. Note that is uses
 `get_user_locale()` from #29783 which shouldn't be part of the initial
 commit. (Depends on which ticket lands first.)

 Good catch. Should

 >
 > * Is there a reason why `$GLOBALS['wp_locale'] = new WP_Locale();`
 happens after the actions?

 I think I did this after your [comment:41:ticket:26511 previous comment]:

 > The actions `restore_locale` and switch_locale are running _after_ the
 locale has been switched. Should they be named `locale_restored` and
 `locale_switched`?

 Instead of removing the actions I moved them up, similar to
 `switch_to_blog()`.

 > * The docs for `WP_Locale_Switcher` can be improved:
 >    * 'Class for switching locales.' => 'Core class used for switching
 locales.'
 >    * 'Locale switcher object.' => 'Locale API: WP_Locale_Switcher class'

 Agreed, though the whole class name might still change. See #38098.

 > * Is the `get_translations_for_domain()` call in
 `WP_Locale_Switcher::load_translations()` required? Tests are still
 passing when removing the line.

 I think it can be removed as it's a leftover from the caching in the
 previous patches. Again, needs some benchmarking to decide if caching
 should be considered.

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


More information about the wp-trac mailing list