Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

$output .= '<li class="recentcomments">' . sprintf(_x('%1$s %2$s - %3$s %4$s', 'thst'), get_avatar( $comment, 48 ), (...);

This is my line of code and Wordpress Theme Checker tells me "Text domain problems. You have not included a text domain!" I have included one though, as you can see. What could be the problem here?

share|improve this question

1 Answer 1

up vote 1 down vote accepted

_x() is for string with a context. So your second argument is just the context, and there is no text domain.

Suggestion:

$string = _x( 
'%1$s %2$s - %3$s %4$s',                # string to translate
'recent comments 1 = gravatar, 2 = … ', # context for translators
'thst'                                  # text domain
);

$visible = sprintf( $string, get_avatar( $comment, 48 ), … );

$output .= '<li class="recentcomments">' . $visible . '</li>';

Explain all numbers in your context parameter.

share|improve this answer
    
$output .= '<li class="recentcomments">' . /* translators: comments widget: 1: comment author, 2: post link */ sprintf(_x('%1$s %2$s - %3$s %4$s'), get_avatar( $comment, 48 ), '<div class="text">' . get_comment_author_link() , '<a href="' . esc_url( get_comment_link($comment->comment_ID) ) . '">' . get_the_title($comment->comment_post_ID) . '</a>', '<p class="date">' . get_comment_date('l, j F Y') . '</p></div>', 'thst') . '</li>'; Ok I got it now. the text domain needed to go at the very end since the other things in the middle are numbers. Thanks! –  charlenemasters Feb 14 '13 at 10:48
    
No, use a context parameter and a text domain as explained in my answer. –  toscho Feb 14 '13 at 10:49
    
Ok I'm not sure I understand. All the elements after x_() are the elements that are inserted into '%1$s'... How does the context parameter come into this? What is it, what does it do and where do I put it? –  charlenemasters Feb 14 '13 at 11:01
    
@charlenemasters I made an update to my answer to show better how it works. Is that better? –  toscho Feb 14 '13 at 11:10
    
Got it to work and I understand it now. Thanks a lot! –  charlenemasters Feb 14 '13 at 11:42

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.