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
if ( !function_exists( 'load_default_textdomain' ) ) { require_once ABSPATH . WPINC . '/l10n.php'; } // Optional. Locale to load. Default is the value of get_locale(). $locale = null; // NOTICE! Understand what this does before running. $result = load_default_textdomain($locale);
Defined (1)
The function is defined in the following location(s).
- /wp-includes/l10n.php
- function load_default_textdomain( $locale = null ) {
- if ( null === $locale ) {
- }
- // Unload previously loaded strings so we can switch translations.
- unload_textdomain( 'default' );
- $return = load_textdomain( 'default', WP_LANG_DIR . "/$locale.mo" );
- if ( ( is_multisite() || ( defined( 'WP_INSTALLING_NETWORK' ) && WP_INSTALLING_NETWORK ) ) && ! file_exists( WP_LANG_DIR . "/admin-$locale.mo" ) ) {
- load_textdomain( 'default', WP_LANG_DIR . "/ms-$locale.mo" );
- return $return;
- }
- load_textdomain( 'default', WP_LANG_DIR . "/admin-$locale.mo" );
- }
- load_textdomain( 'default', WP_LANG_DIR . "/admin-network-$locale.mo" );
- return $return;
- }