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
+20 -5
View File
@@ -9,6 +9,9 @@
/** WordPress Administration Bootstrap */
require_once( dirname( __FILE__ ) . '/admin.php' );
/** WordPress Translation Install API */
require_once( ABSPATH . 'wp-admin/includes/translation-install.php' );
if ( ! current_user_can( 'manage_options' ) )
wp_die( __( 'You do not have sufficient permissions to manage options for this site.' ) );
@@ -63,6 +66,15 @@ function options_general_add_js() {
date : format.val()
}, function(d) { format.siblings('.spinner').hide(); format.siblings('.example').text(d); } );
});
var languageSelect = $( '#WPLANG' );
$( 'form' ).submit( function() {
// Don't show a spinner for English and installed languages,
// as there is nothing to download.
if ( ! languageSelect.find( 'option:selected' ).data( 'installed' ) ) {
$( '#submit', this ).after( '<span class="spinner language-install-spinner" />' );
}
});
});
//]]>
</script>
@@ -318,10 +330,11 @@ endfor;
<?php
$languages = get_available_languages();
$translations = wp_get_available_translations();
if ( ! is_multisite() && defined( 'WPLANG' ) && '' !== WPLANG && 'en_US' !== WPLANG && ! in_array( WPLANG, $languages ) ) {
$languages[] = WPLANG;
}
if ( $languages ) {
if ( ! empty( $languages ) || ! empty( $translations ) ) {
?>
<tr>
<th width="33%" scope="row"><label for="WPLANG"><?php _e( 'Site Language' ); ?></label></th>
@@ -333,10 +346,12 @@ if ( $languages ) {
}
wp_dropdown_languages( array(
'name' => 'WPLANG',
'id' => 'WPLANG',
'selected' => $locale,
'languages' => $languages,
'name' => 'WPLANG',
'id' => 'WPLANG',
'selected' => $locale,
'languages' => $languages,
'translations' => $translations,
'show_available_translations' => ( ! is_multisite() || is_super_admin() ) && wp_can_install_language_pack(),
) );
// Add note about deprecated WPLANG constant.