From 89cab4e197d3c07dfc0b89aee31c1ae80d49a9a5 Mon Sep 17 00:00:00 2001 From: Dominik Schilling Date: Fri, 4 Nov 2016 17:09:31 +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. Built from https://develop.svn.wordpress.org/trunk@39122 git-svn-id: http://core.svn.wordpress.org/trunk@39062 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/options.php | 20 +++++++++++--------- wp-includes/version.php | 2 +- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/wp-admin/options.php b/wp-admin/options.php index 93c69bc1e4..933830b940 100644 --- a/wp-admin/options.php +++ b/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 ); } } diff --git a/wp-includes/version.php b/wp-includes/version.php index a94997c9aa..6281ad421e 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.7-beta1-39121'; +$wp_version = '4.7-beta1-39122'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.