最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Translation Issue with Wordpress Theme Check in comment_form function

programmeradmin3浏览0评论

I ended my wordpress theme, which called the_mdttheme.

I tried to check it and get two errors with translation in comment_form().

Can't understand what did wrong, can someone help me? Here is two warnings:

WARNING: Found a translation function that is missing a text-domain. Function _x, with the arguments 'Comment', 'the_mdttheme'

WARNING: Found a translation function that is missing a text-domain. Function _x, with the arguments 'Comment *', 'the_mdttheme'

Here is my code, warnings are inside 'comment_field':

$args = array(
    'comment_field' => '<p class="comment-form-comment"><label class="hidden" for="comment">' . _x( 'Comment', 'the_mdttheme' ) . '</label><textarea id="comment" name="comment" cols="45" rows="8" aria-required="true" required="required" placeholder="' . _x( 'Comment *', 'the_mdttheme' ) . '"></textarea></p>',
    'submit_button' => '<div class="form-submit-wrapper"><input name="%1$s" type="submit" id="%2$s" class="%3$s" value="%4$s" /></div>',
    'label_submit'  => __( 'comment', 'the_mdttheme' ),
);
comment_form($args);

Thanks in advance!

I ended my wordpress theme, which called the_mdttheme.

I tried to check it and get two errors with translation in comment_form().

Can't understand what did wrong, can someone help me? Here is two warnings:

WARNING: Found a translation function that is missing a text-domain. Function _x, with the arguments 'Comment', 'the_mdttheme'

WARNING: Found a translation function that is missing a text-domain. Function _x, with the arguments 'Comment *', 'the_mdttheme'

Here is my code, warnings are inside 'comment_field':

$args = array(
    'comment_field' => '<p class="comment-form-comment"><label class="hidden" for="comment">' . _x( 'Comment', 'the_mdttheme' ) . '</label><textarea id="comment" name="comment" cols="45" rows="8" aria-required="true" required="required" placeholder="' . _x( 'Comment *', 'the_mdttheme' ) . '"></textarea></p>',
    'submit_button' => '<div class="form-submit-wrapper"><input name="%1$s" type="submit" id="%2$s" class="%3$s" value="%4$s" /></div>',
    'label_submit'  => __( 'comment', 'the_mdttheme' ),
);
comment_form($args);

Thanks in advance!

Share Improve this question asked Apr 1, 2020 at 19:24 AslanAslan 557 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

The _x() function is meant to be used with the same string/text which has two or more different meanings/contexts, e.g. "read" can be a verb (I can read music.) or noun (It's a good read.).

And when you use _x(), the context is the second parameter and the text domain is the third parameter, but in your code, you incorrectly used _x(), where these are missing the context:

_x( 'Comment', 'the_mdttheme' )
_x( 'Comment *', 'the_mdttheme' )

But that would actually be seen as missing the text domain since it's supposed to be the third parameter.

So either provide the context (and also do so with your POT file) or perhaps you meant to use __()? :)

发布评论

评论列表(0)

  1. 暂无评论