admin管理员组文章数量:1322170
I am trying to add a custom string to translate in wpml, but when I use the _e(...) the content jumps outside of container
if I use like this:
echo '<h1>' . $month . ' ' . $day . '</h1>';
the html is ok:
<h1>September 29</h1>
but if I use with translation like this:
echo '<h1>' . _e($month, 'simultan') . ' ' . $day . '</h1>';
the translated string jumps out of h1:
Septembrie<h1>29</h1>
I am trying to add a custom string to translate in wpml, but when I use the _e(...) the content jumps outside of container
if I use like this:
echo '<h1>' . $month . ' ' . $day . '</h1>';
the html is ok:
<h1>September 29</h1>
but if I use with translation like this:
echo '<h1>' . _e($month, 'simultan') . ' ' . $day . '</h1>';
the translated string jumps out of h1:
Septembrie<h1>29</h1>
Share
Improve this question
asked Sep 16, 2020 at 10:37
Botond VajnaBotond Vajna
4714 silver badges11 bronze badges
1 Answer
Reset to default 1When you use _e
your echoing the translated string. But you already have an echo
so just use __(
.
This is the correct code for your example
echo '<h1>' . __('September', 'simultan') . ' ' . $day . '</h1>';
If you want to add variables in your translations you should use sprintf
like this:
$date = sprintf ( __('%s %d', 'simultan'), $month, $day );
echo '<h1>' . $date . '</h1>';
You might want to also have a look at date_i18n function since you are translating dates.
Reference:
Wordpress I18N
sprintf manual
本文标签: WPML custom string translation get outside of container
版权声明:本文标题:WPML custom string translation get outside of container 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742116889a2421509.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论