WP_Scripts::set_translations()publicWP 5.0.0

Sets a translation textdomain.

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

Хуков нет.

Возвращает

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

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

global $wp_scripts;
$wp_scripts->set_translations( $handle, $domain, $path );
$handle(строка) (обязательный)
Name of the script to register a translation domain to.
$domain(строка)
Text domain.
По умолчанию: 'default'
$path(строка)
The full file path to the directory containing translation files.
По умолчанию: ''

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

С версии 5.0.0 Введена.
С версии 5.1.0 The $domain parameter was made optional.

Код WP_Scripts::set_translations() WP 6.5.2

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