admin管理员组文章数量:1314049
I am creating translation for a custom theme and specifically custom template file of the theme and user Poedit to create the pot template.
After translating the file one line in the template won't translate no matter what I do.
<?php echo __( 'Featured', 'mytextdomain' ); ?>
Possibly helpful additional info:
- this line isn't located within wordpress loop.
- If I remove
echo
part and leave only__()
it wont even output word "Featured" in English - I substitute
echo__()
with_e()
"Featured" outputs.
Similar issue also custom "read more" form functions.php isn't translated.
function new_excerpt_more($more) { global $post; return ' …' . __('<a class="more-link" href="'. get_permalink($post->ID) . '">Read More</a>'); }
There's got to be something I'm doing wrong here since everything else translates and outputs except these two instances.
any ideas what am I doing wrong?
I am creating translation for a custom theme and specifically custom template file of the theme and user Poedit to create the pot template.
After translating the file one line in the template won't translate no matter what I do.
<?php echo __( 'Featured', 'mytextdomain' ); ?>
Possibly helpful additional info:
- this line isn't located within wordpress loop.
- If I remove
echo
part and leave only__()
it wont even output word "Featured" in English - I substitute
echo__()
with_e()
"Featured" outputs.
Similar issue also custom "read more" form functions.php isn't translated.
function new_excerpt_more($more) { global $post; return ' …' . __('<a class="more-link" href="'. get_permalink($post->ID) . '">Read More</a>'); }
There's got to be something I'm doing wrong here since everything else translates and outputs except these two instances.
any ideas what am I doing wrong?
Share Improve this question asked Nov 27, 2020 at 0:34 annksweannkswe 231 silver badge6 bronze badges1 Answer
Reset to default 1Your first line of code looks ok, are you sure you have a translation for the 'Featured'
string in your PO file? Your second issue is an excellent example of how you should not use the gettext functions. You are trying to translate dynamic string '<a class="more-link" href="'. get_permalink($post->ID) . '">Read More</a>'
for which you should have the corresponding translation for every different get_permalink($post->ID)
value. What you should do instead is
return ' …<a class="more-link" href="'. get_permalink( $post->ID ) . '">' . __( 'Read More', 'mytextdomain' ) . '</a>';
or
return sprintf( ' …<a class="more-link" href="%s">%s</a>', get_permalink( $post->ID ), __( 'Read More', 'mytextdomain' ) );
and translate only the 'Read More'
phrase.
本文标签: Translation is not being output in one instance
版权声明:本文标题:Translation is not being output in one instance 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741960032a2407220.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论