WordPress at Your Fingertips
function is not described

WP_Scripts::set_translations() public WP 5.0.0

Sets a translation textdomain.

{} It's a method of the class: WP_Scripts{}

No Hooks.

Return

true|false. True if the text domain was registered, false if not.

Usage

global $wp_scripts;
$wp_scripts->set_translations( $handle, $domain, $path );
$handle(string) (required)
Name of the script to register a translation domain to.
$domain(string)
Text domain.
Default: 'default'
$path(string)
The full file path to the directory containing translation files.
Default: null

Changelog

Since 5.0.0 Introduced.
Since 5.1.0 The $domain parameter was made optional.

Code of WP_Scripts::set_translations() WP 5.8.1

public function set_translations( $handle, $domain = 'default', $path = null ) {
	if ( ! isset( $this->registered[ $handle ] ) ) {
		return false;
	}

	/** @var \_WP_Dependency $obj */
	$obj = $this->registered[ $handle ];

	if ( ! in_array( 'wp-i18n', $obj->deps, true ) ) {
		$obj->deps[] = 'wp-i18n';
	}

	return $obj->set_translations( $domain, $path );
}