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

WordPress Trac noreply at wordpress.org
Wed Sep 7 16:39:59 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 ocean90):

 Replying to [comment:46 swissspidy]:
 > Do you have a use case for temporarily switching the user locale? If
 yes, a context switch could make sense and is fairly easy. Just needs a
 second stack.
 >
 > Otherwise I was more thinking that developers could use it like this:
 >
 > {{{#!php
 > <?php
 > $switched = switch_to_locale( get_user_locale() );
 > // Do stuff
 > if ( $switched ) {
 >   restore_previous_locale();
 > }
 > }}}

 Yes: An author should get a comment moderation email in their language.
 But `switch_to_locale( get_user_locale() );` should work, I think.


 > As these two tickets are so tied to each other, should we perhaps merge
 the patches?

 No, but we should maybe move the other one to 4.7 too. :)

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


More information about the wp-trac mailing list