WordPress.org

Make WordPress Core


Ignore:
Timestamp:
08/26/2014 07:58:33 PM (6 years ago)
Author:
ocean90
Message:

Language packs: No WPLANG anymore.

  • The WPLANG constant is no longer needed. Remove define('WPLANG', ); from wp-config-sample.php. Populate WPLANG option based on the WPLANG constant. When get_option('WPLANG') is an empty string it will override WPLANG.
  • Introduce translations_api() which is available to communicate with the translation API. Move translation install related functions to a new file.
  • Replace mu_dropdown_languages() with wp_dropdown_languages(). wp_dropdown_languages() is now populated by the translation API.
  • Remove wp_install_load_language() and allow load_default_textdomain() to switch a core translation.

fixes #13069, #15677, #19760, #28730, #29281.

File:
1 edited

Legend:

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

    r29599 r29630  
    3333require( ABSPATH . 'wp-settings.php' );
    3434
    35 require( ABSPATH . 'wp-admin/includes/upgrade.php' );
     35/** Load WordPress Administration Upgrade API */
     36require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
     37
     38/** Load WordPress Translation Install API */
     39require_once( ABSPATH . 'wp-admin/includes/translation-install.php' );
    3640
    3741nocache_headers();
     
    8690} // end function setup_config_display_header();
    8791
     92$language = '';
     93if ( ! empty( $_REQUEST['language'] ) ) {
     94    $language = preg_replace( '/[^a-zA-Z_]/', '', $_REQUEST['language'] );
     95}
    8896switch($step) {
    8997    case -1:
    90 
    91         if ( empty( $_GET['language'] ) && ( $languages = wp_get_available_translations_from_api() ) ) {
     98        if ( empty( $language ) && ( $languages = wp_get_available_translations() ) ) {
    9299            setup_config_display_header( 'language-chooser' );
    93100            echo '<form id="setup" method="post" action="?step=0">';
     
    100107
    101108    case 0:
    102         if ( ! empty( $_REQUEST['language'] ) ) {
    103             $loaded_language = wp_install_download_language_pack( $_REQUEST['language'] );
     109        if ( ! empty( $language ) ) {
     110            $loaded_language = wp_download_language_pack( $language );
    104111            if ( $loaded_language ) {
    105                 wp_install_load_language( $loaded_language );
     112                load_default_textdomain( $loaded_language );
    106113            }
    107114        }
     
    137144
    138145    case 1:
    139         $loaded_language = wp_install_load_language( $_REQUEST['language'] );
     146        load_default_textdomain( $language );
    140147        setup_config_display_header();
    141148    ?>
     
    170177    </table>
    171178    <?php if ( isset( $_GET['noapi'] ) ) { ?><input name="noapi" type="hidden" value="1" /><?php } ?>
    172     <input type="hidden" name="language" value="<?php echo esc_attr( $loaded_language ); ?>" />
     179    <input type="hidden" name="language" value="<?php echo esc_attr( $language ); ?>" />
    173180    <p class="step"><input name="submit" type="submit" value="<?php echo htmlspecialchars( __( 'Submit' ), ENT_QUOTES ); ?>" class="button button-large" /></p>
    174181</form>
     
    177184
    178185    case 2:
    179     $loaded_language = wp_install_load_language( $_REQUEST['language'] );
     186    load_default_textdomain( $language );
    180187    $dbname = trim( wp_unslash( $_POST[ 'dbname' ] ) );
    181188    $uname = trim( wp_unslash( $_POST[ 'uname' ] ) );
     
    190197    }
    191198
    192     if ( $loaded_language ) {
    193         $step_1 .= '&amp;language=' . $loaded_language;
    194         $install .= '?language=' . $loaded_language;
     199    if ( ! empty( $language ) ) {
     200        $step_1 .= '&amp;language=' . $language;
     201        $install .= '?language=' . $language;
    195202    } else {
    196203        $install .= '?language=en_US';
Note: See TracChangeset for help on using the changeset viewer.