Index: /trunk/wp-admin/ms-edit.php =================================================================== --- /trunk/wp-admin/ms-edit.php (revision 12945) +++ /trunk/wp-admin/ms-edit.php (revision 12946) @@ -24,5 +24,5 @@ wp_die( __("You probably need to go back to the options page") ); - if ( isset($_POST['WPLANG']) ) + if ( isset($_POST['WPLANG']) && ( '' === $_POST['WPLANG'] || in_array($_POST['WPLANG'], get_available_languages()) ) ) update_site_option( "WPLANG", $_POST['WPLANG'] ); Index: /trunk/wp-admin/ms-options.php =================================================================== --- /trunk/wp-admin/ms-options.php (revision 12945) +++ /trunk/wp-admin/ms-options.php (revision 12946) @@ -253,11 +253,7 @@
Index: /trunk/wp-includes/l10n.php =================================================================== --- /trunk/wp-includes/l10n.php (revision 12945) +++ /trunk/wp-includes/l10n.php (revision 12946) @@ -485,3 +485,29 @@ return translate_with_gettext_context( before_last_bar($name), 'User role' ); } + +/** + * 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(); + + if ( empty($dir) ) + $dir = WP_LANG_DIR; + + if ( is_dir( $dir ) && $dh = opendir( $dir ) ) { + while ( ( $lang_file = readdir( $dh ) ) !== false ) { + if ( substr( $lang_file, -3 ) == '.mo' ) + $languages[] = basename($lang_file, '.mo'); + } + closedir($dh); + } + + return $languages; +} + ?> |