load_default_textdomain

Load default translated strings based on locale.

Description

load_default_textdomain( (null) $locale = null ); 

Loads the .mo file in WP_LANG_DIR constant path from WordPress root. The translated (.mo) file is named based on the locale.

Parameters (1)

0. $locale — Optional. (null) => null
Locale to load. Default is the value of get_locale().

Usage

  1. if ( !function_exists( 'load_default_textdomain' ) ) { 
  2. require_once ABSPATH . WPINC . '/l10n.php'; 
  3.  
  4. // Optional. Locale to load. Default is the value of get_locale(). 
  5. $locale = null; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = load_default_textdomain($locale); 
  9.  

Defined (1)

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

/wp-includes/l10n.php  
  1. function load_default_textdomain( $locale = null ) { 
  2. if ( null === $locale ) { 
  3. $locale = is_admin() ? get_user_locale() : get_locale(); 
  4.  
  5. // Unload previously loaded strings so we can switch translations. 
  6. unload_textdomain( 'default' ); 
  7.  
  8. $return = load_textdomain( 'default', WP_LANG_DIR . "/$locale.mo" ); 
  9.  
  10. if ( ( is_multisite() || ( defined( 'WP_INSTALLING_NETWORK' ) && WP_INSTALLING_NETWORK ) ) && ! file_exists( WP_LANG_DIR . "/admin-$locale.mo" ) ) { 
  11. load_textdomain( 'default', WP_LANG_DIR . "/ms-$locale.mo" ); 
  12. return $return; 
  13.  
  14. if ( is_admin() || wp_installing() || ( defined( 'WP_REPAIRING' ) && WP_REPAIRING ) ) { 
  15. load_textdomain( 'default', WP_LANG_DIR . "/admin-$locale.mo" ); 
  16.  
  17. load_textdomain( 'default', WP_LANG_DIR . "/admin-network-$locale.mo" ); 
  18.  
  19. return $return;