WP_Script_Modules::set_translationspublicWP 7.0.0

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

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().

Метод класса: WP_Script_Modules{}

Хуков нет.

Возвращает

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

Использование

$WP_Script_Modules = new WP_Script_Modules();
$WP_Script_Modules->set_translations( $id, $domain, $path ): bool;
$id(строка) (обязательный)
The identifier of the script module.
$domain(строка)
Text domain.
По умолчанию: 'default'
$path(строка)
The full file path to the directory containing translation files.
По умолчанию: ''

Список изменений

С версии 7.0.0 Введена.

Код WP_Script_Modules::set_translations() WP 7.1

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;
}