WP_Locale_Switcher::change_locale

Advertisement

Private Access Private Access

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.

Summery Summery

Changes the site’s locale to the given one.

Syntax Syntax

WP_Locale_Switcher::change_locale( string $locale )

Description Description

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

Parameters Parameters

$locale

(Required) The locale to change to.

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

Advertisement

Changelog Changelog

Changelog
Version Description
4.7.0 Introduced.

Advertisement

Leave a Reply