WordPress.org

Make WordPress Core

Changeset 39122


Ignore:
Timestamp:
11/03/2016 05:54:42 PM (4 years ago)
Author:
ocean90
Message:

I18N: Show "Settings saved." in the correct language after switching the site language.

This simplifies the logic by comparing get_user_locale() before and after an settings update.

Props swissspidy, ocean90.
See #29783, #29281.
Fixes #38482.

File:
1 edited

Legend:

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

    r38705 r39122  
    195195
    196196    if ( $options ) {
     197        $user_language_old = get_user_locale();
     198
    197199        foreach ( $options as $option ) {
    198200            if ( $unregistered ) {
     
    218220        }
    219221
    220         // Switch translation in case WPLANG was changed.
    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             }
     222        /*
     223         * Switch translation in case WPLANG was changed.
     224         * The global $locale is used in get_locale() which is
     225         * used as a fallback in get_user_locale().
     226         */
     227        unset( $GLOBALS['locale'] );
     228        $user_language_new = get_user_locale();
     229        if ( $user_language_old !== $user_language_new  ) {
     230            load_default_textdomain( $user_language_new );
    229231        }
    230232    }
Note: See TracChangeset for help on using the changeset viewer.