WordPress at a glance
function is not described

wp_set_script_translations() WP 5.0.0

Sets translated strings for a script.

Works only if the script has already been added.

  • See: WP_Scripts::set_translations()
  • Global. WP_Scripts. $wp_scripts The WP_Scripts object for printing scripts.

No Hooks.


true/false. True if the textdomain was successfully localized, false otherwise.


wp_set_script_translations( $handle, $domain, $path );
$handle(string) (required)
Script handle the textdomain will be attached to.
$domain(string) (required)
The textdomain.
The full file path to the directory containing translation files.
Default: null

Code of wp set script translations: wp-includes/functions.wp-scripts.php VER 5.0.3

function wp_set_script_translations( $handle, $domain, $path = null ) {
	global $wp_scripts;
	if ( ! ( $wp_scripts instanceof WP_Scripts ) ) {
		_wp_scripts_maybe_doing_it_wrong( __FUNCTION__ );
		return false;

	return $wp_scripts->set_translations( $handle, $domain, $path );