当参数为变量时,如何在php echo调用中进行语言转换
我继承了一个wordpress插件,其中a变量保存要显示的html字符串的值 比如说,当参数为变量时,如何在php echo调用中进行语言转换,php,wordpress,echo,Php,Wordpress,Echo,我继承了一个wordpress插件,其中a变量保存要显示的html字符串的值 比如说, $html=$html."<H1>Enter Your Account Information </h1>"; $html=$html."<h2>Your First Name</h2>"; $html=$html. .... (more strings like above) .... echo $html 整个插件都有这种类型的构造,其中 echo
$html=$html."<H1>Enter Your Account Information </h1>";
$html=$html."<h2>Your First Name</h2>";
$html=$html. .... (more strings like above) ....
echo $html
整个插件都有这种类型的构造,其中
echo '<H1>Enter Your Account Information </h1>';
可轻松更改为:
echo '<h1>' . __('Enter Your Account Information', 'myplugin') . '</h1>';
有没有一种方法可以按照当前的实现方式进行翻译
或者我必须更改它,使其立即响应到屏幕,并跳过构建$html变量
提前感谢。您可以将字符串与翻译一起存储,如
$html .= '<h1>' . __('Enter Your Account Information', 'myplugin') . '</h1>';
$html .= '<h2>' . __('Your First Name', 'myplugin') . '</h2>';
注意:如果要立即回复翻译,请使用:
_e('Enter Your Account Information', 'myplugin');
_e('Enter Your Account Information', 'myplugin');