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

WordPress Trac noreply at wordpress.org
Tue May 31 10:36:31 UTC 2016


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

Comment (by pbearne):

 The current function allows you to switch a random locale e.g. xx_XX

 Is this a good idea?

 If not I can add a test to catch that. e.g.

 {{{#!php
 <?php
 if ( ! in_array( $locale, get_available_languages() ) ) {
         return false;
 }
 }}}


 But this test doesn't test that we have we have the language file (*.mo)
 installed so we could add call to  the wp_get_available_translations()
 function ( a file system call - not cheap), But all this tells us is
 install or not. If it is not installed we shouldn't switch otherwise will
 have a broken set global locales.

 We could get into loading the file from WP.org but this doesn't work on
 all sites and is slow.

 I have come to the conclusion that we should just add the languages files
 for ALL languages returned via get_available_languages() to WP so we know
 we can switch and know that the data we need to load the locale is
 installed.

 It's a lot of files but they are small.

 Thoughts

 Paul

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


More information about the wp-trac mailing list