Site Language: Install translations on the fly.

The language dropdown now includes installed languages and all available translations when the filesystem is writable by WordPress.
Go to wp-admin/options-general.php, select one of the available translations, submit the form and let WordPress handle the rest.
Works for Multisite's Default Language too.

see #29395.
Built from https://develop.svn.wordpress.org/trunk@30335


git-svn-id: http://core.svn.wordpress.org/trunk@30334 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Dominik Schilling
2014-11-13 17:01:24 +00:00
parent 4a1cb796fc
commit 8fb6f317ff
11 changed files with 153 additions and 37 deletions

View File

@@ -151,8 +151,8 @@ if ( 'update' == $action ) {
$options = $whitelist_options[ $option_page ];
}
// Handle custom date/time formats.
if ( 'general' == $option_page ) {
// Handle custom date/time formats.
if ( !empty($_POST['date_format']) && isset($_POST['date_format_custom']) && '\c\u\s\t\o\m' == wp_unslash( $_POST['date_format'] ) )
$_POST['date_format'] = $_POST['date_format_custom'];
if ( !empty($_POST['time_format']) && isset($_POST['time_format_custom']) && '\c\u\s\t\o\m' == wp_unslash( $_POST['time_format'] ) )
@@ -163,6 +163,18 @@ if ( 'update' == $action ) {
$_POST['gmt_offset'] = preg_replace('/UTC\+?/', '', $_POST['gmt_offset']);
$_POST['timezone_string'] = '';
}
// Handle translation install.
if ( ! empty( $_POST['WPLANG'] ) && ( ! is_multisite() || is_super_admin() ) ) { // @todo: Skip if already installed
require_once( ABSPATH . 'wp-admin/includes/translation-install.php' );
if ( wp_can_install_language_pack() ) {
$language = wp_download_language_pack( $_POST['WPLANG'] );
if ( $language ) {
$_POST['WPLANG'] = $language;
}
}
}
}
if ( $options ) {