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.

what is the last $count in this example?

printf( _n(
    'You have published %s post.', 'You have published %s posts.',
    $count,
    'myplugin' ),
$count );

i guess the first one is to fill each %s, so what is the second $count?

Thanks

share|improve this question

1 Answer 1

up vote 1 down vote accepted

The _n (see Codex) function accepts four arguments. The first two are texts to be translated (the first is singular, the second plural), the third argument is a number (in this case $count). When $count is 1 the first string is used, otherwise the second string is used.

So in fact the first instance of $count is only used to determine whether the single / plural text should be used. _n then translates that string, using the plug-in/theme domain - i.e. the fourth argument) and the language set in the wp-config. This then returns a translated string such as:

Se han publicado %s artículos

The printf then echos this string with the %s replaced by the second argument, $count (which is the second instance of $count`) .

share|improve this answer
    
thanks Stephen Harris ! –  Paul Mar 20 '12 at 3:00

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.