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