![](/img/trans.png)
[英]How to resolve Strings should have translatable content in Wordpress?
[英]How to transform hardcoded strings to polylang suitable translatable stings in WordPress private theme?
我在多语言网站上使用了“ Polylang”插件。 因此,有些点不适合翻译字符串。 我可以更改一些适合的主题。 但是,对于其他一些人,我做不到。
这是下面的代码。
模板contacts.php
原始码
if ( $message_btn ) : ?>
<div id="contacts-modal" class="reveal-modal">
<h1 class="entry-header"><?php _e( 'Send message', 'fluxus' ); ?></h1>
<div class="modal-contents"></div>
<a class="close-reveal-modal">×</a>
</div><?php
endif;
我将代码更改为
if ( $message_btn ) : ?>
<div id="contacts-modal" class="reveal-modal">
<h1 class="entry-header"><?php pll_e( 'Send message' ); ?></h1>
<div class="modal-contents"></div>
<a class="close-reveal-modal">×</a>
</div><?php
endif;
这对于部分工作。 但是,页脚中有“发送消息”和“查看地图”按钮,以及“使用箭头%s键进行导航”文本。 我不会成功地改变,解决这部分。 这是代码:
if ( $has_map ) {
$view_btn = '<a id="view-map" href="#" class="button icon-location">' . __( 'View map', 'fluxus' ) . '</a>';
} else {
$view_btn = '';
}
/**
* Show Send Message button only if there is a [contact-form-7] short tag
* in the content.
*/
if ( preg_match('/\[contact\-form\-7.+?\]/is', $post->post_content) ) {
$message_btn = '<a id="send-message" href="#" class="button icon-paper-plane">' . __( 'Send message', 'fluxus' ) . '</a>';
} else {
$message_btn = '';
}
?>
我该如何对以上部分进行更改?
尝试将__( 'View map', 'fluxus' )
更改为pll__( 'View map' )
和__( 'Send message', 'fluxus' )
to pll__( 'Send message' )
当然,“视图地图”和“发送消息”需要预先注册
pll_e(
或_e(
回显字符串, __(
或pll_(
返回字符串。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.