load_default_textdomain() WordPress Function

The load_default_textdomain() function is used to load the default translated strings for a Wordpress theme or plugin. This function should be called before any other translated strings are loaded to ensure that the default translations take precedence.

load_default_textdomain( string $locale = null ) #

Load 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.

Top ↑

See also


Top ↑

Parameters

$locale

(string)(Optional) Locale to load. Default is the value of get_locale().

Default value: null


Top ↑

Return

(bool) Whether the textdomain was loaded.


Top ↑

Source

File: wp-includes/l10n.php

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" );

	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;
	}

	if ( is_admin() || wp_installing() || ( defined( 'WP_REPAIRING' ) && WP_REPAIRING ) ) {
		load_textdomain( 'default', WP_LANG_DIR . "/admin-$locale.mo" );
	}

	if ( is_network_admin() || ( defined( 'WP_INSTALLING_NETWORK' ) && WP_INSTALLING_NETWORK ) ) {
		load_textdomain( 'default', WP_LANG_DIR . "/admin-network-$locale.mo" );
	}

	return $return;
}


Top ↑

Changelog

Changelog
VersionDescription
1.5.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.