On this page
WP_Scripts::set_translations( string $handle, string $domain = 'default', string $path = '' ): bool
Sets a translation textdomain.
Parameters
$handlestring Required-
Name of the script to register a translation domain 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 registered, false if not.
Source
File: wp-includes/class-wp-scripts.php. View all references
public function set_translations( $handle, $domain = 'default', $path = '' ) {
if ( ! isset( $this->registered[ $handle ] ) ) {
return false;
}
/** @var \_WP_Dependency $obj */
$obj = $this->registered[ $handle ];
if ( ! in_array( 'wp-i18n', $obj->deps, true ) ) {
$obj->deps[] = 'wp-i18n';
}
return $obj->set_translations( $domain, $path );
}
Related
Used By
| Used By | Description |
|---|---|
| wp_set_script_translations() wp-includes/functions.wp-scripts.php | Sets translated strings for a script. |
Changelog
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/classes/WP_Scripts/set_translations