WordPress.org

Make WordPress Core


Ignore:
Timestamp:
11/13/2014 05:00:08 PM (6 years ago)
Author:
ocean90
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/options.php

    r29630 r30335  
    152152    }
    153153
    154     // Handle custom date/time formats.
    155154    if ( 'general' == $option_page ) {
     155        // Handle custom date/time formats.
    156156        if ( !empty($_POST['date_format']) && isset($_POST['date_format_custom']) && '\c\u\s\t\o\m' == wp_unslash( $_POST['date_format'] ) )
    157157            $_POST['date_format'] = $_POST['date_format_custom'];
     
    163163            $_POST['gmt_offset'] = preg_replace('/UTC\+?/', '', $_POST['gmt_offset']);
    164164            $_POST['timezone_string'] = '';
     165        }
     166
     167        // Handle translation install.
     168        if ( ! empty( $_POST['WPLANG'] ) && ( ! is_multisite() || is_super_admin() ) ) { // @todo: Skip if already installed
     169            require_once( ABSPATH . 'wp-admin/includes/translation-install.php' );
     170
     171            if ( wp_can_install_language_pack() ) {
     172                $language = wp_download_language_pack( $_POST['WPLANG'] );
     173                if ( $language ) {
     174                    $_POST['WPLANG'] = $language;
     175                }
     176            }
    165177        }
    166178    }
Note: See TracChangeset for help on using the changeset viewer.