我正在制作小插件以在我的 word-press 中分享帖子
一切正常,但我无法获得可翻译的字符串 throw wpml。
请耐心等待,这不是关于 wpml 的问题, 我的问题是我不知道如何以正确的方式将 Get 文本添加到我的代码中。
这是我的代码:
function add_social_share_icons($content)
{
$html = "<div class='social-share-wrapper'><div class='share-on'>Share on: </div>";
global $post;
$url = get_permalink($post->ID);
$url = esc_url($url);
if(get_option("social-share-facebook") == 1)
{
$html = $html . "<div class='facebook'><a target='_blank' href='http://www.facebook.com/sharer.php?u=" . $url . "'>Facebook</a></div>";
}
我想翻译这个"Share on:" wpml 使用 Gettext 来检测字符串。
像这样<th><?php echo __('Due date:', 'themedomain'); ?></th>
我尝试过这样的事情:
$html = "<div class='social-share-wrapper'><div class='share-on'><?php _e('Share on:'); ?></div>";
但它不起作用!
有人可以帮我吗?
答案 0 :(得分:0)
您不能将这样的函数嵌入到字符串中,只能通过这种方式完成简单的事情。相反,您想要连接可以通过几种方式完成,但这可能是最简单的。另外,我没有使用 _e()
来回显文本,而是使用 __()
来翻译
$html = "<div class='social-share-wrapper'><div class='share-on'>" . __('Share on:') . "</div>";
__()
的第二个参数是文本域,同_e()