wp_set_script_module_translations()WP 7.0.0

Overrides the text domain and path used to load translations for a script module.

Translations for script modules are loaded automatically from the default text domain and language directory. Use this function only when a module's text domain differs from 'default' or when translation files live outside the standard location, for example plugin modules using their own text domain.

No Hooks.

Returns

true|false. True if the text domain was registered, false if the module is not registered.

Usage

wp_set_script_module_translations( $id, $domain, $path ): bool;
$id(string) (required)
The identifier of the script module.
$domain(string)
Text domain.
Default: 'default'
$path(string)
The full file path to the directory containing translation files.
Default: ''

Notes

Changelog

Since 7.0.0 Introduced.

wp_set_script_module_translations() code WP 7.0

function wp_set_script_module_translations( string $id, string $domain = 'default', string $path = '' ): bool {
	return wp_script_modules()->set_translations( $id, $domain, $path );
}