On this page
wp_set_script_translations( string $handle, string $domain = 'default', string $path = '' ): bool
Sets translated strings for a script.
Description
Works only if the script has already been registered.
See also
Parameters
$handlestring Required-
Script handle the textdomain will be attached to.
$domainstring Optional-
Text domain. Default
'default'.Default:
'default' $pathstring Optional-
The full file path to the directory containing translation files.
Default:
''
Return
bool True if the text domain was successfully localized, false otherwise.
Source
File: wp-includes/functions.wp-scripts.php. View all references
function wp_set_script_translations( $handle, $domain = 'default', $path = '' ) {
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 );
}
Related
Uses
| Uses | Description |
|---|---|
| WP_Scripts::set_translations() wp-includes/class-wp-scripts.php | Sets a translation textdomain. |
Used By
| Used By | Description |
|---|---|
| register_block_script_handle() wp-includes/blocks.php | Finds a script handle for the selected block metadata field. It detects when a path to file was provided and finds a corresponding asset file with details necessary to register the script under automatically generated handle name. It returns unprocessed script handle otherwise. |
Changelog
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/wp_set_script_translations