printf and _n in this example?

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?

Read More

Thanks

Related posts

Leave a Reply

1 comment

  1. 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`) .