Solution:1
echo sprintf(__("text %s", 'your__text_domain'), $data);
Solution:1
echo sprintf(__("text %s", 'your__text_domain'), $data);
Solution:2
I’m surprised no one mentioned the “translators” comment, that tells the translator what each variable in the sprintf
is. Examples:
sprintf(
/* translators: %s: Name of a city */
__( 'Your city is %s.', 'my-plugin' ),
$city
);
sprintf(
/* translators: 1: Name of a city 2: ZIP code */
__( 'Your city is %1$s, and your zip code is %2$s.', 'my-plugin' ),
$city,
$zipcode
);