Whenever I write plugins or themes, there is one thing that needs a little extra attention and is quite frankly hard to get right: Translatable text. This list should helps me to find the right way fast.
Props to Alex Kirk, there list it inside a quiz.
Assume that the $username
has been escaped using esc_html()
.
<?php
// Translators: %s is a username.
printf(
__( 'Howdy, %s!' ),
$username
);
<?php
printf(
__( 'Publish something using our <a href="%s">Post by Email</a> feature.'),
'http://support.wordpress.com/post-by-email/'
);
printf(
_n(
'%d person has seen this post.',
'%d people have seen this post.',
$view_count
),
$view_count
);
printf(
__( 'Hello %s' ),
esc_html( $world )
);
printf(
_n(
'Today you already got %s view.',
'Today you already got %s views.',
$view_count
),
number_format_i18n( $view_count )
);
// Translators: %1$s is a date, %2$s is a username.
printf(
__( 'Posted on %1$s by %2$s.' ),
$date,
$username
);
Developers should to give translators full sentences/phrases.