WordPress函数:load_child_theme_textdomain 加载子主题翻译字符串

江河/ 03月29日/ WordPress/ 浏览 177

函数原型:


load_child_theme_textdomain( string $domain, string|false $path = false ): bool


加载子主题翻译字符串


如果当前区域设置作为.mo文件存在于子主题的根目录中,则$domain会将其包含在已翻译的字符串中。


.mo文件的命名必须完全基于区域设置。


参数说明:


$domain,翻译字符串的唯一标识


$path .mo 文件的路径


国际化和本地化(其他常见拼写为国际化和本地化)是使计算机软件适应不同语言的手段。i10n 是本地化的缩写。i18n 18代表国际化中第一个i和最后一个n之间的字母数。


函数源码:


function load_child_theme_textdomain( $domain, $path = false ) {
	if ( ! $path ) {
		$path = get_stylesheet_directory();
	}
	return load_theme_textdomain( $domain, $path );
}


使用举例:


/**
 * Loads the child theme textdomain.
 */
function wpdocs_child_theme_setup() {
    load_child_theme_textdomain( 'my_parent_theme', get_stylesheet_directory() . '/languages' );
}
add_action( 'after_setup_theme', 'wpdocs_child_theme_setup' );


发表评论

暂无评论,抢个沙发...

客服 工单