Make WordPress Core

Opened 13 years ago

Closed 13 years ago

Last modified 13 years ago

#25568 closed defect (bug) (invalid)

Sprintf replacement specifiers for strings are used instead of integers

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

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 13 years ago.

Download all attachments as: .zip

Change History (5)

@Nao
13 years ago

#1 follow-up: @johnbillion
13 years ago

  • Milestone Awaiting Review
  • Resolution → invalid
  • Status new → 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
13 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
13 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
13 years ago

  • Version trunk → 3.6
Note: See TracTickets for help on using tickets.