WordPress.org

Make WordPress Core


Ignore:
Timestamp:
10/03/2016 07:03:41 AM (4 years ago)
Author:
swissspidy
Message:

I18N: Introduce a user-specific language setting.

By enabling the user to select their preferred locale when editing the profile, we allow for greater personalization of the WordPress admin and therefore a better user experience.

The back end will be displayed in the user's individual locale while the locale used on the front end equals the one set for the whole site. If the user didn't specify a locale, the site's locale will be used as a fallback. The new locale property of the WP_User class can be used to retrieve the user's locale setting.

Props ocean90, ipm-frommen, swissspidy.
Fixes #29783.

File:
1 edited

Legend:

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

    r38032 r38705  
    210210            if ( isset( $_POST[ $option ] ) ) {
    211211                $value = $_POST[ $option ];
    212                 if ( ! is_array( $value ) )
     212                if ( ! is_array( $value ) ) {
    213213                    $value = trim( $value );
     214                }
    214215                $value = wp_unslash( $value );
    215216            }
     
    218219
    219220        // Switch translation in case WPLANG was changed.
    220         $language = get_option( 'WPLANG' );
    221         if ( $language ) {
    222             load_default_textdomain( $language );
    223         } else {
    224             unload_textdomain( 'default' );
     221        $language      = get_option( 'WPLANG' );
     222        $user_language = get_user_locale();
     223        if ( $language === $user_language ) {
     224            if ( $language ) {
     225                load_default_textdomain( $language );
     226            } else {
     227                unload_textdomain( 'default' );
     228            }
    225229        }
    226230    }
Note: See TracChangeset for help on using the changeset viewer.