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

WordPress Trac noreply at wordpress.org
Mon Sep 5 05:58:59 UTC 2016


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

Comment (by tfrommen):

 Hey, cool this is moving forward!

 Thanks, @swissspidy - and brilliant how you got rid of the extra class.
 Also, great to see you were able to take most of my patch as is for your
 version.

 Some small improvements:

 In `WP_Locale_Switcher::switch_to_locale()`, instead of this:

 {{{#!php
 <?php
 if ( null === $l10n ) {
     $l10n = array();
 }

 if ( empty( $l10n ) ) {
     load_default_textdomain();
 }
 }}}

 we could to that (and save an '''unnecessary''' extra check):

 {{{#!php
 <?php
 if ( ! $l10n ) {
     $l10n = array();

     load_default_textdomain();
 }
 }}}

 Also, in `WP_Locale_Switcher::restore_locale()`, move the initialization
 of `$previous_locale` to after the check, so we have this instead:

 {{{#!php
 <?php
 if ( ! array_pop( $this->locales ) ) {
     // The stack is empty, bail.
     return false;
 }

 $previous_locale = end( $this->locales );
 }}}

 If you would like, I can provide a new patch for this.

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


More information about the wp-trac mailing list