0

我创建了一个主题。

所有单词和短语都使用:

__('Word Here','mythemelocalpath') 

或者

_e('Word Here','mythemelocalpath')

我在我的新主题文件夹中创建了一个名为语言的文件夹。

我用 poedit 创建了一个 .mo 和 .po 和 .pot 文件,并将它们放在我的新主题文件夹中的语言文件夹中。

.mo、.po、.pot 文件在本地化之后,例如:de_DE.mo

然后我在functions.php中编写了这段代码:

function mycustom_load_localization() {

    // Retrieve the directory for the localization files
    load_theme_textdomain( 'mythemelocalpath', TEMPPATH.'/languages' );

} // end custom_theme_setup
add_action('after_setup_theme', 'mycustom_load_localization');

然后我输入 wp-config.php 文件并将 WP_LANG 更改为 de_DE

但由于某种原因它不起作用?

有人可以对此有所了解。

谢谢 :)

4

1 回答 1

1

尝试这个

load_theme_textdomain( 'mythemelocalpath', get_stylesheet_directory() . '/languages/' );

代替

load_theme_textdomain( 'mythemelocalpath', TEMPPATH.'/languages' );

哪里get_stylesheet_directory()应该给你样式表目录路径,它应该是子主题保存;-)

参考:

http://codex.wordpress.org/Function_Reference/get_stylesheet_directory

于 2013-06-13T21:29:47.977 回答