Title: wp_set_script_module_translations
Published: May 20, 2026

---

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

## In this article

 * [Description](https://developer.wordpress.org/reference/functions/wp_set_script_module_translations/?output_format=md#description)
    - [See also](https://developer.wordpress.org/reference/functions/wp_set_script_module_translations/?output_format=md#see-also)
 * [Parameters](https://developer.wordpress.org/reference/functions/wp_set_script_module_translations/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/functions/wp_set_script_module_translations/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/functions/wp_set_script_module_translations/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/functions/wp_set_script_module_translations/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/wp_set_script_module_translations/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/functions/wp_set_script_module_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/functions/wp_set_script_module_translations/?output_format=md#description)󠁿

Translations for script modules are loaded automatically from the default text domain
and language directory. Use this function only when a module’s text domain differs
from `'default'` or when translation files live outside the standard location, for
example plugin modules using their own text domain.

### 󠀁[See also](https://developer.wordpress.org/reference/functions/wp_set_script_module_translations/?output_format=md#see-also)󠁿

 * [WP_Script_Modules::set_translations()](https://developer.wordpress.org/reference/classes/WP_Script_Modules/set_translations/)

## 󠀁[Parameters](https://developer.wordpress.org/reference/functions/wp_set_script_module_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/functions/wp_set_script_module_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/functions/wp_set_script_module_translations/?output_format=md#source)󠁿

    ```php
    function wp_set_script_module_translations( string $id, string $domain = 'default', string $path = '' ): bool {
    	return wp_script_modules()->set_translations( $id, $domain, $path );
    }
    ```

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

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

| Uses | Description | 
| [WP_Script_Modules::set_translations()](https://developer.wordpress.org/reference/classes/wp_script_modules/set_translations/)`wp-includes/class-wp-script-modules.php` |

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

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

Retrieves the main [WP_Script_Modules](https://developer.wordpress.org/reference/classes/wp_script_modules/) instance.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/wp_set_script_module_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%2Ffunctions%2Fwp_set_script_module_translations%2F)
before being able to contribute a note or feedback.