Alert: This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.

WP_Locale_Switcher::change_locale() WordPress Method

The WP_Locale_Switcher::change_locale() method is used to change the current Wordpress locale. This is useful for changing the language of the Wordpress administration interface or for creating a multilingual Wordpress site.

WP_Locale_Switcher::change_locale( string $locale ) #

Changes the site’s locale to the given one.


Description

Loads the translations, changes the global $wp_locale object and updates all post type labels.


Top ↑

Parameters

$locale

(string)(Required)The locale to change to.


Top ↑

Source

File: wp-includes/class-wp-locale-switcher.php

	private function change_locale( $locale ) {
		// Reset translation availability information.
		_get_path_to_translation( null, true );

		$this->load_translations( $locale );

		$GLOBALS['wp_locale'] = new WP_Locale();

		/**
		 * Fires when the locale is switched to or restored.
		 *
		 * @since 4.7.0
		 *
		 * @param string $locale The new locale.
		 */
		do_action( 'change_locale', $locale );
	}


Top ↑

Changelog

Changelog
VersionDescription
4.7.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.