wp_set_script_translations

函式
wp_set_script_translations ( $handle, $domain = 'default', $path = '' )
引數
  • (string) $handle Script handle the textdomain will be attached to.
    Required:
  • (string) $domain Optional. Text domain. Default 'default'.
    Required:
    Default: 'default'
  • (string) $path Optional. The full file path to the directory containing translation files.
    Required:
    Default: (empty)
返回值
  • (bool) True if the text domain was successfully localized, false otherwise.
相關
  • WP_Scripts::set_translations()
定義位置
相關方法
load_script_translationswp_get_installed_translationswp_get_available_translations_get_path_to_translationwp_get_script_tag
引入
5.0.0
棄用
-

wp_set_script_translations: 這個函式為一個給定的指令碼設定翻譯。它接受指令碼控制代碼和一個翻譯陣列,其中每個翻譯是一個關聯陣列,以要翻譯的字串為鍵,以翻譯後的字串為值。

設定指令碼的翻譯字串。

僅當指令碼已註冊時有效。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
function wp_set_script_translations( $handle, $domain = 'default', $path = '' ) {
global $wp_scripts;
if ( ! ( $wp_scripts instanceof WP_Scripts ) ) {
_wp_scripts_maybe_doing_it_wrong( __FUNCTION__, $handle );
return false;
}
return $wp_scripts->set_translations( $handle, $domain, $path );
}
function wp_set_script_translations( $handle, $domain = 'default', $path = '' ) { global $wp_scripts; if ( ! ( $wp_scripts instanceof WP_Scripts ) ) { _wp_scripts_maybe_doing_it_wrong( __FUNCTION__, $handle ); return false; } return $wp_scripts->set_translations( $handle, $domain, $path ); }
function wp_set_script_translations( $handle, $domain = 'default', $path = '' ) {
	global $wp_scripts;

	if ( ! ( $wp_scripts instanceof WP_Scripts ) ) {
		_wp_scripts_maybe_doing_it_wrong( __FUNCTION__, $handle );
		return false;
	}

	return $wp_scripts->set_translations( $handle, $domain, $path );
}

常見問題

FAQs
檢視更多 >