WordPress.org

Make WordPress Core


Ignore:
Timestamp:
10/03/2016 07:03:41 AM (3 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-includes/l10n.php

    r38438 r38705  
    7777
    7878/**
     79 * Retrieves the locale of the current user.
     80 *
     81 * If the user has a locale set to a non-empty string then it will be
     82 * returned. Otherwise it returns the locale of get_locale().
     83 *
     84 * @since 4.7.0
     85 *
     86 * @return string The locale of the current user.
     87 */
     88function get_user_locale() {
     89    $user = wp_get_current_user();
     90
     91    $locale = $user->locale;
     92    return ( '' === $locale ) ? get_locale() : $locale;
     93}
     94
     95/**
    7996 * Retrieve the translation of $text.
    8097 *
     
    634651function load_default_textdomain( $locale = null ) {
    635652    if ( null === $locale ) {
    636         $locale = get_locale();
     653        $locale = is_admin() ? get_user_locale() : get_locale();
    637654    }
    638655
Note: See TracChangeset for help on using the changeset viewer.