admin管理员组文章数量:1336091
I have two translatable strings as follows in my 404.php file
esc_html_e( 'I couldn't find the page you were looking for.', 'themename' );
esc_html_e( 'Try a search or one of the links below.', 'themename' );
At its present form, the first string does not get translated. Escaping the single quote with a backslash does not help either.
Any ideas?
I have two translatable strings as follows in my 404.php file
esc_html_e( 'I couldn't find the page you were looking for.', 'themename' );
esc_html_e( 'Try a search or one of the links below.', 'themename' );
At its present form, the first string does not get translated. Escaping the single quote with a backslash does not help either.
Any ideas?
Share Improve this question edited May 28, 2020 at 17:28 user1438038 1761 silver badge12 bronze badges asked Jun 18, 2016 at 9:53 developerdeveloper 1516 bronze badges 2- Easiest way out is simply write 'could not', though there's probably a smarter way. – cjbj Commented Jun 18, 2016 at 10:03
- Right, but that makes it formal. Besides, I prefer to know a solution to this problem in terms of programming and learn something. Thanks anyway. – developer Commented Jun 18, 2016 at 10:09
2 Answers
Reset to default 0You can wrap it inside double quotes:
esc_html_e("I couldn't find the page you are looking for.", "themename");
You can also escape the single quote:
esc_html_e( 'I couldn\'t find the page you were looking for.', 'themename' );
But the PHP Coding Standards of WordPress recommend to not escape any characters:
Single and Double Quotes
Use single and double quotes when appropriate. If you’re not evaluating anything in the string, use single quotes. You should almost never have to escape quotes in a string, because you can just alternate your quoting style.
So you are probably better of, using double quotes as stated by user6454281 already:
esc_html_e( "I couldn't find the page you were looking for.", 'themename' );
本文标签: translationHow to handle single quote in a translatable string in Wordpress
版权声明:本文标题:translation - How to handle single quote in a translatable string in Wordpress 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742392801a2466319.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论