wc_switch_to_site_locale()
Switch WooCommerce to site language.
No Hooks.
Returns
null. Nothing (null).
Usage
wc_switch_to_site_locale();
Changelog
| Since 3.1.0 | Introduced. |
wc_switch_to_site_locale() wc switch to site locale code WC 10.3.6
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();
}
}