switch_to_locale

Switches the translations according to the given locale.

Description

switch_to_locale( (string) $locale ); 

Parameters (1)

0. $locale (string)
The locale.

Usage

  1. if ( !function_exists( 'switch_to_locale' ) ) { 
  2. require_once ABSPATH . WPINC . '/l10n.php'; 
  3.  
  4. // The locale. 
  5. $locale = ''; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = switch_to_locale($locale); 
  9.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/l10n.php  
  1. function switch_to_locale( $locale ) { 
  2. /** @var WP_Locale_Switcher $wp_locale_switcher */ 
  3. global $wp_locale_switcher; 
  4.  
  5. return $wp_locale_switcher->switch_to_locale( $locale );