WP_Scripts::set_translations( string $handle, string $domain = 'default', string $path = null ): bool

Sets a translation textdomain.


$handle string Required
Name of the script to register a translation domain to.
$domain string Optional
Text domain. Default 'default'.

Default: 'default'

$path string Optional
The full file path to the directory containing translation files.

Default: null

Top ↑


bool True if the text domain was registered, false if not.

Top ↑


File: wp-includes/class.wp-scripts.php. View all references

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

Top ↑


Version Description
5.1.0 The $domain parameter was made optional.
5.0.0 Introduced.

Top ↑

User Contributed Notes

You must log in before being able to contribute a note or feedback.