Make WordPress Core

Opened 12 years ago

Closed 12 years ago

Last modified 12 years ago

#25568 closed defect (bug) (invalid)

Sprintf replacement specifiers for strings are used instead of integers

Reported by: nao's profile Nao Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.6
Component: I18N Keywords: has-patch
Focuses: Cc:

Description

In wp-admin/edit.php, many of the messages for bulk edit include %s as replacement specifiers for decimal strings instead of %d (ref: http://php.net/sprintf)

While this does not affect the displayed message in English, replacing them with correct replacement specifiers will help translators understand the context.

Attachments (1)

25568.diff (2.6 KB) - added by Nao 12 years ago.

Download all attachments as: .zip

Change History (5)

@Nao
12 years ago

#1 follow-up: @johnbillion
12 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Status changed from new to closed

The %s replacement specifier is used for number formatting purposes. The value passed in is not necessarily an integer. This is especially important with localisation, where the translation could be a word, a number with formatting, or a non-Latin numeral.

As an example (albeit an unlikely one), you could delete 1,000 pages and the number would show up as 1000 with your patch rather than 1,000.

#2 in reply to: ↑ 1 @nacin
12 years ago

Replying to johnbillion:

As an example (albeit an unlikely one), you could delete 1,000 pages and the number would show up as 1000 with your patch rather than 1,000.

printf( '%d', '1,000' ) actually truncates to 1, even worse.

#3 @johnbillion
12 years ago

For a bit more context, the numbers passed into these strings are first passed through number_format_i18n() see here, at which point they are localised and may not be integer-like.

#4 @SergeyBiryukov
12 years ago

  • Version changed from trunk to 3.6
Note: See TracTickets for help on using tickets.