WordPress at Your Fingertips

wp_set_script_translations() WP 1.0

Sets translated strings for a script.

Works only if the script has already been added.

No Hooks.

Return

true|false. True if the text domain was successfully localized, false otherwise.

Usage

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

Notes

Changelog

Since 5.0.0 Introduced.
Since 5.1.0 The $domain parameter was made optional.

Code of wp_set_script_translations() WP 5.8.1

function wp_set_script_translations( $handle, $domain = 'default', $path = null ) {
	global $wp_scripts;

	if ( ! ( $wp_scripts instanceof WP_Scripts ) ) {
		_wp_scripts_maybe_doing_it_wrong( __FUNCTION__, $handle );
		return false;
	}

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

textdomain (mo po files)

Localization

No comments
    Log In