Changes the site’s locale to the given one.
Loads the translations, changes the global $wp_locale object and updates all post type labels.
$localestringrequired
private function change_locale( $locale ) {
global $wp_locale;
$this->load_translations( $locale );
$wp_locale = new WP_Locale();
WP_Translation_Controller::get_instance()->set_locale( $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 );
}
Fires when the locale is switched to or restored.
| Version | Description |
|---|---|
| 4.7.0 | Introduced. |
© 2003–2024 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/classes/wp_locale_switcher/change_locale