Warning: Trying to access array offset on false in /www/wwwroot/www.wpdongli.com/wp-content/themes/WPdongli/functions/wp.php on line 216
load_child_theme_textdomain() - 加载子主题的翻译字符串 - WordPress函数 - WordPress动力
当前浏览:首页 / WordPress函数 / load_child_theme_textdomain()

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

加载子主题的翻译字符串


Warning: Undefined array key -1 in /www/wwwroot/www.wpdongli.com/wp-content/themes/WPdongli/functions/reference-cat.php on line 185

Warning: Undefined array key 4 in /www/wwwroot/www.wpdongli.com/wp-content/themes/WPdongli/functions/reference-cat.php on line 186

Warning: Undefined variable $searchand in /www/wwwroot/www.wpdongli.com/wp-content/themes/WPdongli/functions/wp.php on line 154

Warning: Undefined array key "f45cdd4cc3da737909174405d73859a6" in /www/wwwroot/www.wpdongli.com/wp-content/themes/WPdongli/functions/wp.php on line 223

Warning: Undefined variable $searchand in /www/wwwroot/www.wpdongli.com/wp-content/themes/WPdongli/functions/wp.php on line 154

Warning: Undefined array key "b6d5614af037b768033983662cb78e6c" in /www/wwwroot/www.wpdongli.com/wp-content/themes/WPdongli/functions/wp.php on line 223

Warning: Undefined variable $searchand in /www/wwwroot/www.wpdongli.com/wp-content/themes/WPdongli/functions/wp.php on line 154

Warning: Undefined array key "48e6bbe2bead26233d322b2c276232a5" in /www/wwwroot/www.wpdongli.com/wp-content/themes/WPdongli/functions/wp.php on line 223

Warning: Undefined variable $searchand in /www/wwwroot/www.wpdongli.com/wp-content/themes/WPdongli/functions/wp.php on line 154

Warning: Undefined array key "3a41fd57de8104db46dad2693d7f2deb" in /www/wwwroot/www.wpdongli.com/wp-content/themes/WPdongli/functions/wp.php on line 223

children

load

textdomain

theme 主题more...


描述

如果当前区域的 .mo 文件存在于子主题的根目录中,它将通过$domain被包含在翻译字符串中。

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


参数

$domain

(string) (必填) Text domain(文本域),用于检索翻译字符串的唯一标识符。

$path

(string|false) (可选) 包含 .mo 文件的路径目录

默认值: false


返回

(bool) 成功加载主题textdomain时为true,否则为false。


说明

国际化和本地化是使计算机软件适应不同语言的手段。



源码

查看源码 官方文档


更新日志

版本描述
2.9.0开始引入

使用示例

  • 示例1

    load_child_theme_textdomain()函数通常应在 after_setup_theme 动作挂钩内调用,与其相关的 load_theme_textdomain() 函数相同。

    /**
     * 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' );
    

    ‘my_parent_theme’ = 主主题的名称

    这个 .mo 文件必须使用纯语言文件名,如子主题目录中的 languages/de_de.mo

    与插件语言文件不同,像 my_child_theme-de_DE.mo 这样的名称将不起作用。虽然插件语言文件允许您在文件名中指定文本域,但这不适用于主题和子主题。主题的语言文件应仅包括语言快捷方式。