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
This commit is contained in:
Dominik Schilling 2016-11-04 17:09:31 +00:00
parent 60db5df85f
commit 89cab4e197
2 changed files with 12 additions and 10 deletions

View File

@ -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 );
}
}

View File

@ -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.