[英]How to do language translation in php echo call when parameter is a variable
我繼承了一個wordpress插件,其中一個變量保存要顯示的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 '<H1>Enter Your Account Information </h1>';
可以輕松更改為:
echo '<h1>' . __('Enter Your Account Information', 'myplugin') . '</h1>';
有沒有辦法按照當前實施的方式進行翻譯?
還是我必須更改它以便它立即回顯到屏幕並跳過構建$ html變量?
提前致謝。
您可以將String與翻譯一起存儲
$html .= '<h1>' . __('Enter Your Account Information', 'myplugin') . '</h1>';
$html .= '<h2>' . __('Your First Name', 'myplugin') . '</h2>';
以后您可以像這樣echo
顯$html
變量
echo $html;
注意:如果要立即回顯翻譯,請使用:
_e('Enter Your Account Information', 'myplugin');
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.