WP_Scripts::set_translations
Sets a translation textdomain.
Method of the class: WP_Scripts{}
No Hooks.
Returns
true|false. True if the text domain was registered, false if not.
Usage
global $wp_scripts; $wp_scripts->set_translations( $handle, $domain, $path );
- $handle(string) (required)
- Name of the script to register a translation domain to.
- $domain(string)
- Text domain.
Default:'default' - $path(string)
- The full file path to the directory containing translation files.
Default:''
Changelog
| Since 5.0.0 | Introduced. |
| Since 5.1.0 | The $domain parameter was made optional. |
WP_Scripts::set_translations() WP Scripts::set translations code WP 6.9.1
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 );
}