[wp-trac] [WordPress Trac] #21691: WPLANG not set in multisite

WordPress Trac wp-trac at lists.automattic.com
Mon Aug 27 21:41:23 UTC 2012


#21691: WPLANG not set in multisite
--------------------------+------------------------------
 Reporter:  foxinni       |       Owner:
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  Multisite     |     Version:
 Severity:  normal        |  Resolution:
 Keywords:                |
--------------------------+------------------------------

Comment (by wonderboymusic):

 In {{{sanitize_option()}}}:

 {{{
 case 'WPLANG':
         $allowed = get_available_languages();
         if ( ! in_array( $value, $allowed ) && ! empty( $value ) )
                 $value = get_option( $option );
         break;
 }}}

 In {{{get_available_languages()}}}:

 {{{
 /**
  * Get all available languages based on the presence of *.mo files in a
 given directory. The default directory is WP_LANG_DIR.
  *
  * @since 3.0.0
  *
  * @param string $dir A directory in which to search for language files.
 The default directory is WP_LANG_DIR.
  * @return array Array of language codes or an empty array if no languages
 are present. Language codes are formed by stripping the .mo extension from
 the language file names.
  */
 function get_available_languages( $dir = null ) {
         $languages = array();

         foreach( (array)glob( ( is_null( $dir) ? WP_LANG_DIR : $dir ) .
 '/*.mo' ) as $lang_file ) {
                 $lang_file = basename($lang_file, '.mo');
                 if ( 0 !== strpos( $lang_file, 'continents-cities' ) && 0
 !== strpos( $lang_file, 'ms-' ) &&
                         0 !== strpos( $lang_file, 'admin-' ))
                         $languages[] = $lang_file;
         }

         return $languages;
 }
 }}}

 Do you have proper {{{*.mo}}} files for the languages you want?
 Are they being loaded properly?

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/21691#comment:4>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list