我的 WordPress 主题中有以下代码:
$to_return .= '<th><label for="user_login">Username</label></th>';
如何使用文本域来翻译用户名这个词?我试过了
$to_return .= '<th><label for="user_login"><?php _e("Username", "mytheme"); ?></label></th>';
但没有运气。谢谢!
我的 WordPress 主题中有以下代码:
$to_return .= '<th><label for="user_login">Username</label></th>';
如何使用文本域来翻译用户名这个词?我试过了
$to_return .= '<th><label for="user_login"><?php _e("Username", "mytheme"); ?></label></th>';
但没有运气。谢谢!
当您已经在 PHP 中时,<?php无需指定。?>
要在字符串中连接函数的返回值,请使用.运算符。
此外,正如@RRikesh 指出的那样,_e应该读取__,因为回显_e并__返回:
$to_return .= '<th><label for="user_login">' . __("Username", "mytheme") . '</label></th>';
你应该使用__():
$to_return .= '<th><label for="user_login">' . __("Username", "mytheme") . '</label></th>';