WordPress.org

Making WordPress.org

Opened 5 months ago

Closed 5 months ago

#2979 closed defect (fixed)

fix for multiple placeholders should be ordered

Reported by: afzalmultani Owned by: coffee2code
Milestone: Priority: normal
Component: Developer Hub Keywords: has-patch
Cc:

Description

Multiple placeholders should be ordered. Expected '%1$s, %2$d', but got %s, %d.

Attachments (3)

2979.diff (1.2 KB) - added by afzalmultani 5 months ago.
fix for multiple placeholders should be ordered
2979.2.diff (1.2 KB) - added by afzalmultani 5 months ago.
UPdated
2979.3.diff (1.4 KB) - added by SergeyBiryukov 5 months ago.

Download all attachments as: .zip

Change History (7)

@afzalmultani
5 months ago

fix for multiple placeholders should be ordered

@afzalmultani
5 months ago

UPdated

#1 @SergeyBiryukov
5 months ago

  • Component changed from General to Developer Hub

#2 follow-up: @SergeyBiryukov
5 months ago

  • Keywords has-patch added

Hi @afzalmultani, thanks for the patch.

'Used by <a href="%s">1 function</a>' and 'Used by <a href="%s">%d functions</a>' are separate strings, the placeholders are not really interchangeable here and don't necessarily have to be numbered.

2979.2.diff appears to treat them as a single string, making the result invalid:

  • 'Used by <a href="%1$s"> function</a>' is missing the %2$d placeholder with the number of functions.
  • 'Used by <a href="%2$d"> functions</a>' is missing the %1$s placeholder with the permalink.

That said, this block needs a few other adjustments:

Addressed in 2979.3.diff.

Last edited 5 months ago by SergeyBiryukov (previous) (diff)

#3 in reply to: ↑ 2 @afzalmultani
5 months ago

Hi @SergeyBiryukov,

Thanks for the patch and explanation. Definitely, it will help me a lot.

#4 @coffee2code
5 months ago

  • Owner set to coffee2code
  • Resolution set to fixed
  • Status changed from new to closed

In 5721:

developer.wordpress.org: Improve translatability of "Used By"/ "Uses" string.

  • Use placeholder instead of hardcoding 1 in string.
  • Use numbered placeholders, with comments for translators.
  • Update link anchor targets to #used-by/#uses, respectively.

Props SergeyBiryukov.
Fixes #2979.

Note: See TracTickets for help on using tickets.