Overrides the text domain and path used to load translations for a script module.
Description
This is only needed for modules whose text domain differs from ‘default’ or whose translation files live outside the standard locations, for example plugin modules that register their own text domain. Translations for modules that use the default domain are loaded automatically by WP_Script_Modules::print_script_module_translations().
Parameters
$idstringrequired- The identifier of the script module.
$domainstringoptional- Text domain. Default
'default'.Default:
'default' $pathstringoptional- The full file path to the directory containing translation files.
Default:
''
Source
public function set_translations( string $id, string $domain = 'default', string $path = '' ): bool {
if ( ! isset( $this->registered[ $id ] ) ) {
return false;
}
$this->registered[ $id ]['textdomain'] = $domain;
$this->registered[ $id ]['translations_path'] = $path;
return true;
}
Changelog
| Version | Description |
|---|---|
| 7.0.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.