Title: WP_Script_Modules::set_translations
Published: May 20, 2026

---

# WP_Script_Modules::set_translations( string $id, string $domain = 'default', string $path = '' ): bool

## In this article

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

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

Overrides the text domain and path used to load translations for a script module.

## 󠀁[Description](https://developer.wordpress.org/reference/classes/WP_Script_Modules/set_translations/?output_format=md#description)󠁿

This is only needed for modules whose text domain differs from ‘default’ or whose
translation files live outside the standard locations, for example plugin modules
that register their own text domain. Translations for modules that use the default
domain are loaded automatically by [WP_Script_Modules::print_script_module_translations()](https://developer.wordpress.org/reference/classes/WP_Script_Modules/print_script_module_translations/).

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

 `$id`stringrequired

The identifier of the script module.

`$domain`stringoptional

Text domain. Default `'default'`.

Default:`'default'`

`$path`stringoptional

The full file path to the directory containing translation files.

Default:`''`

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

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

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

    ```php
    public function set_translations( string $id, string $domain = 'default', string $path = '' ): bool {
    	if ( ! isset( $this->registered[ $id ] ) ) {
    		return false;
    	}

    	$this->registered[ $id ]['textdomain']        = $domain;
    	$this->registered[ $id ]['translations_path'] = $path;

    	return true;
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/class-wp-script-modules.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.0/src/wp-includes/class-wp-script-modules.php#L358)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.0/src/wp-includes/class-wp-script-modules.php#L358-L367)

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

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

Overrides the text domain and path used to load translations for a script module.

  |

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

| Version | Description | 
| [7.0.0](https://developer.wordpress.org/reference/since/7.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_script_modules%2Fset_translations%2F)
before being able to contribute a note or feedback.