Title: WP_Scripts::set_translations
Published: December 6, 2018
Last modified: February 24, 2026

---

# WP_Scripts::set_translations( string $handle, string $domain, string $path ): bool

## In this article

 * [Parameters](https://developer.wordpress.org/reference/classes/wp_scripts/set_translations/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/classes/wp_scripts/set_translations/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/classes/wp_scripts/set_translations/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/classes/wp_scripts/set_translations/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/classes/wp_scripts/set_translations/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/classes/wp_scripts/set_translations/?output_format=md#wp--skip-link--target)

Sets a translation textdomain.

## 󠀁[Parameters](https://developer.wordpress.org/reference/classes/wp_scripts/set_translations/?output_format=md#parameters)󠁿

 `$handle`stringrequired

Name of the script to register a translation domain to.

`$domain`stringoptional

Text domain. Default `'default'`.

`$path`stringoptional

The full file path to the directory containing translation files.

## 󠀁[Return](https://developer.wordpress.org/reference/classes/wp_scripts/set_translations/?output_format=md#return)󠁿

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

## 󠀁[Source](https://developer.wordpress.org/reference/classes/wp_scripts/set_translations/?output_format=md#source)󠁿

    ```php
    public function set_translations( $handle, $domain = 'default', $path = '' ) {
    	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 );
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes_class-wp-scripts-php-2/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-includes/class-wp-scripts.php#L690)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-includes/class-wp-scripts.php#L690-L703)

## 󠀁[Related](https://developer.wordpress.org/reference/classes/wp_scripts/set_translations/?output_format=md#related)󠁿

| Used by | Description | 
| [wp_set_script_translations()](https://developer.wordpress.org/reference/functions/wp_set_script_translations/)`wp-includes/functions.wp-scripts.php` |

Sets translated strings for a script.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/classes/wp_scripts/set_translations/?output_format=md#changelog)󠁿

| Version | Description | 
| [5.1.0](https://developer.wordpress.org/reference/since/5.1.0/) | The `$domain` parameter was made optional. | 
| [5.0.0](https://developer.wordpress.org/reference/since/5.0.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fclasses%2Fwp_scripts%2Fset_translations%2F)
before being able to contribute a note or feedback.