On this page
load_default_textdomain( string $locale = null ): bool
Loads default translated strings based on locale.
Description
Loads the .mo file in WP_LANG_DIR constant path from WordPress root.
The translated (.mo) file is named based on the locale.
See also
Parameters
$localestring Optional-
Locale to load. Default is the value of get_locale() .
Default:
null
Return
bool Whether the textdomain was loaded.
Source
File: wp-includes/l10n.php. View all references
function load_default_textdomain( $locale = null ) {
if ( null === $locale ) {
$locale = determine_locale();
}
// Unload previously loaded strings so we can switch translations.
unload_textdomain( 'default' );
$return = load_textdomain( 'default', WP_LANG_DIR . "/$locale.mo", $locale );
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", $locale );
return $return;
}
if ( is_admin() || wp_installing() || ( defined( 'WP_REPAIRING' ) && WP_REPAIRING ) ) {
load_textdomain( 'default', WP_LANG_DIR . "/admin-$locale.mo", $locale );
}
if ( is_network_admin() || ( defined( 'WP_INSTALLING_NETWORK' ) && WP_INSTALLING_NETWORK ) ) {
load_textdomain( 'default', WP_LANG_DIR . "/admin-network-$locale.mo", $locale );
}
return $return;
}
Related
Uses
| Uses | Description |
|---|---|
| determine_locale() wp-includes/l10n.php | Determines the current locale desired for the request. |
| wp_installing() wp-includes/load.php | Check or set whether WordPress is in “installation” mode. |
| unload_textdomain() wp-includes/l10n.php | Unloads translations for a text domain. |
| load_textdomain() wp-includes/l10n.php | Loads a .mo file into the text domain $domain. |
| is_network_admin() wp-includes/load.php | Determines whether the current request is for the network administrative interface. |
| is_multisite() wp-includes/load.php | If Multisite is enabled. |
| is_admin() wp-includes/load.php | Determines whether the current request is for an administrative interface page. |
Used By
| Used By | Description |
|---|---|
| WP_Fatal_Error_Handler::handle() wp-includes/class-wp-fatal-error-handler.php | Runs the shutdown handler. |
| WP_Locale_Switcher::load_translations() wp-includes/class-wp-locale-switcher.php | Load translations for a given locale. |
| _redirect_to_about_wordpress() wp-admin/includes/update-core.php | Redirect to the About WordPress page after a successful upgrade. |
Changelog
| Version | Description |
|---|---|
| 1.5.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/load_default_textdomain