WP_Locale_Switcher::change_locale()
Changes the site's locale to the given one.
Loads the translations, changes the global $wp_locale object and updates all post type labels.
{} It's a method of the class: WP_Locale_Switcher{}
Hooks from the method
Return
null
. Nothing.
Usage
// private - for code of main (parent) class only $result = $this->change_locale( $locale );
- $locale(string) (required)
- The locale to change to.
Notes
- Global. WP_Locale. $wp_locale WordPress date and time locale object.
Changelog
Since 4.7.0 | Introduced. |
Code of WP_Locale_Switcher::change_locale() WP Locale Switcher::change locale WP 6.0
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 ); }