1
votes

So, I want to translate a WordPress theme and plugin using POEDIT. There are some strings that use placeholders like %s and %d, can someone tell me what exactly they stand for?

Because, for example I have "%d Adult" and "%s Adult" but I dont know whats the difference between them

2
%d = Integer, %s = String - Read hereAndy Tschiersch

2 Answers

1
votes

Those placeholders are part of the format specification for sprintf.

In short, this function takes a 'format string' and then a series of values and creates a new string with the provided values inserted into format string:

$verse = sprintf('%d bottles of %s on the wall', 99, 'beer');

The %d placeholder indicates that it's a spot for signed decimal integer. The %s placeholder indicates that it's a spot for a string.

0
votes
$wpdb->prepare() supports a small subset of the sprintf() arguments. 
        The %d is a placeholder for an integer (not a decimal, that would be %f).
        Use %d when you want to send a real integer to the database,
        Use %s for strings.