php代码中的文本域

时间:2013-04-30 06:40:52

标签: wordpress translation

我的WordPress主题中有以下代码:

$to_return .= '<th><label for="user_login">Username</label></th>';

如何使用文本域翻译用户名? 我试过了

$to_return .= '<th><label for="user_login"><?php _e("Username", "mytheme"); ?></label></th>';

但没有运气。谢谢!

2 个答案:

答案 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>';