wc_switch_to_site_locale()WC 3.1.0

Switch WooCommerce to site language.

No Hooks.

Return

null. Nothing (null).

Usage

wc_switch_to_site_locale();

Changelog

Since 3.1.0 Introduced.

wc_switch_to_site_locale() code WC 8.7.0

function wc_switch_to_site_locale() {
	global $wp_locale_switcher;

	if ( function_exists( 'switch_to_locale' ) && isset( $wp_locale_switcher ) ) {
		switch_to_locale( get_locale() );

		// Filter on plugin_locale so load_plugin_textdomain loads the correct locale.
		add_filter( 'plugin_locale', 'get_locale' );

		// Init WC locale.
		WC()->load_plugin_textdomain();
	}
}