From c1f7d89592087574574238db79a3b62cdd722873 Mon Sep 17 00:00:00 2001 From: "Dominik Schilling (ocean90)" Date: Thu, 3 Nov 2016 17:54:42 +0000 Subject: [PATCH] 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. git-svn-id: https://develop.svn.wordpress.org/trunk@39122 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/options.php | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/wp-admin/options.php b/src/wp-admin/options.php index 93c69bc1e4..933830b940 100644 --- a/src/wp-admin/options.php +++ b/src/wp-admin/options.php @@ -194,6 +194,8 @@ if ( 'update' == $action ) { } if ( $options ) { + $user_language_old = get_user_locale(); + foreach ( $options as $option ) { if ( $unregistered ) { _deprecated_argument( 'options.php', '2.7.0', @@ -217,15 +219,15 @@ if ( 'update' == $action ) { update_option( $option, $value ); } - // Switch translation in case WPLANG was changed. - $language = get_option( 'WPLANG' ); - $user_language = get_user_locale(); - if ( $language === $user_language ) { - if ( $language ) { - load_default_textdomain( $language ); - } else { - unload_textdomain( 'default' ); - } + /* + * Switch translation in case WPLANG was changed. + * The global $locale is used in get_locale() which is + * used as a fallback in get_user_locale(). + */ + unset( $GLOBALS['locale'] ); + $user_language_new = get_user_locale(); + if ( $user_language_old !== $user_language_new ) { + load_default_textdomain( $user_language_new ); } }