我创建了一个插件来自定义用户通知电子邮件模板,但是无法正常工作。如果我将WordPress中的语言切换为荷兰语,则电子邮件的语言仍为英语。
我已经设置了文本域:
Plugin Name: WPX Custom New User Email
Author: WPX
Author URI: https://localhost
Description: Changes the copy in the email sent out to new users
Version: 0.1
Text Domain: wpx-new-user-email
Domain Path: /languages
设置插件文本域:
add_action( 'init', 'wpx_load_textdomain' );
/**
* Callback on the `plugins_loaded` hook.
* Loads the plugin text domain via load_plugin_textdomain()
*
* @uses load_plugin_textdomain()
* @since 1.0.0
*
* @access public
* @return void
*/
function wpx_load_textdomain() {
load_plugin_textdomain( 'wpx-new-user-email', false, dirname(
plugin_basename( __FILE__ ) ) . '/languages' );
}
在此需要翻译的一段代码:
$message = sprintf( __( 'Dear %s,' ), $user->first_name ) . '<br><br>';
$message .= sprintf( __( 'Thank you very much for your registration at <a href="https://localhost">Local Host</a>!' ) ) . '<br><br>';
$message .= sprintf( __( 'You are now able to login with your login details.' ) ) . '<br><br>';
.po和.mo文件位于语言目录中,并命名为wpx-new-user-email-nl_NL.mo和wpx-new-user-email-nl_NL.po
有什么建议吗?