load_plugin_textdomain

Advertisement

Summery Summery

Loads a plugin’s translated strings.

Syntax Syntax

load_plugin_textdomain( string $domain, string|false $deprecated = false, string|false $plugin_rel_path = false )

Description Description

If the path is not given then it will be the root of the plugin directory.

The .mo file should be named based on the text domain with a dash, and then the locale exactly.

Parameters Parameters

$domain

(Required) Unique identifier for retrieving translated strings

$deprecated

(Optional) Deprecated. Use the $plugin_rel_path parameter instead.

Default value: false

$plugin_rel_path

(Optional) Relative path to WP_PLUGIN_DIR where the .mo file resides.

Default value: false

Return Return

(bool) True when textdomain is successfully loaded, false otherwise.

Source Source

File: wp-includes/l10n.php

	 *
	 * @param string $domain Text domain. Unique identifier for retrieving translated strings.
	 */
	do_action( 'unload_textdomain', $domain );

	if ( isset( $l10n[ $domain ] ) ) {
		unset( $l10n[ $domain ] );

		$l10n_unloaded[ $domain ] = true;

		return true;
	}

	return false;
}

/**
 * Load default translated strings based on locale.
 *
 * Loads the .mo file in WP_LANG_DIR constant path from WordPress root.
 * The translated (.mo) file is named based on the locale.
 *
 * @see load_textdomain()
 *
 * @since 1.5.0
 *
 * @param string $locale Optional. Locale to load. Default is the value of get_locale().
 * @return bool Whether the textdomain was loaded.
 */

Advertisement

Changelog Changelog

Changelog
Version Description
4.6.0 The function now tries to load the .mo file from the languages directory first.
1.5.0 Introduced.

Advertisement

Leave a Reply