WordPress.org

Make WordPress Core

Opened 9 months ago

Closed 3 weeks ago

#39660 closed enhancement (fixed)

Missing singular placeholder, needed for some languages on comments.php

Reported by: bplv Owned by: SergeyBiryukov
Milestone: 4.9 Priority: normal
Severity: normal Version: 4.7.1
Component: Bundled Theme Keywords: has-patch
Focuses: Cc:

Description

On comments.php of most of the bundled themes the singular form of the string is not available.

Attachments (2)

39660.diff (7.0 KB) - added by bplv 9 months ago.
39660.2.diff (7.6 KB) - added by xkon 6 weeks ago.
Updates to TwentySixteen

Download all attachments as: .zip

Change History (26)

#1 in reply to: ↑ description @bplv
9 months ago

I have found this via code sniffer which shows this report

Line: 31 ERROR Missing singular placeholder, needed for some languages.

See https://codex.wordpress.org/I18n_for_WordPress_Developers#Plurals

According to codex this is the proper placeholder,

<?php
printf( esc_html( _n( 'We deleted %d spam message.', 'We deleted %d spam messages.', $count, 'my-text-domain'  ) ), $count );

Which is not the case in most of the bundled themes.

#2 follow-up: @SergeyBiryukov
9 months ago

  • Keywords needs-patch added
  • Milestone changed from Awaiting Review to Future Release

Hi @bplv, welcome to Trac! Thanks for the ticket.

This is fixed in Twenty Sixteen and Twenty Seventeen, I guess we could update older themes to use proper plural forms here as well.

@bplv
9 months ago

#3 @bplv
9 months ago

  • Keywords has-patch added; needs-patch removed

Hello, @SergeyBiryukov

I have added the patch.

Thank you.

#4 @SergeyBiryukov
9 months ago

  • Milestone changed from Future Release to 4.8

@bplv: Looks good, thank you :)

This ticket was mentioned in Slack in #core by dshanske. View the logs.


8 months ago

This ticket was mentioned in Slack in #core by jeffpaul. View the logs.


6 months ago

This ticket was mentioned in Slack in #core by jeffpaul. View the logs.


5 months ago

#8 @jbpaul17
5 months ago

  • Milestone changed from 4.8 to 4.8.1

Punting to 4.8.1 per today's bug scrub.

#9 @jbpaul17
3 months ago

  • Keywords needs-testing added

This ticket was mentioned in Slack in #core by jeffpaul. View the logs.


3 months ago

#11 @SergeyBiryukov
3 months ago

  • Milestone changed from 4.8.1 to 4.9

#12 @SergeyBiryukov
3 months ago

  • Owner set to SergeyBiryukov
  • Status changed from new to reviewing

#13 @kakshak
3 months ago

  • Keywords has-unit-tests added; needs-testing removed

Hello @SergeyBiryukov,

I have merge 39660.diff to this version and it's working fine in my local environment.

#14 @SergeyBiryukov
8 weeks ago

  • Keywords has-unit-tests removed

#15 in reply to: ↑ 2 ; follow-up: @SergeyBiryukov
8 weeks ago

Replying to SergeyBiryukov:

This is fixed in Twenty Sixteen and Twenty Seventeen

Just noticed get_comments_number() returns a string, and Twenty Sixteen compares it to an integer, which doesn't work as expected. Twenty Seventeen does it correctly.

@xkon
6 weeks ago

Updates to TwentySixteen

#16 in reply to: ↑ 15 @xkon
6 weeks ago

Updated the patch to .2 to address this as well. Tested also all the themes again and it seems fine here.

Replying to SergeyBiryukov:

Just noticed get_comments_number() returns a string, and Twenty Sixteen compares it to an integer, which doesn't work as expected. Twenty Seventeen does it correctly.

This ticket was mentioned in Slack in #core by jeffpaul. View the logs.


4 weeks ago

This ticket was mentioned in Slack in #meta-wordcamp by sergey. View the logs.


3 weeks ago

This ticket was mentioned in Slack in #core by jeffpaul. View the logs.


3 weeks ago

#20 @SergeyBiryukov
3 weeks ago

In 41729:

Twenty Sixteen: Make sure comment number comparison in comments.php works as expected.

get_comments_number() returns a numeric string, not an integer.

See #39660.

This ticket was mentioned in Slack in #core by jeffpaul. View the logs.


3 weeks ago

#22 @SergeyBiryukov
3 weeks ago

In 41761:

Twenty Fifteen: Add missing singular placeholder in comments.php.

Uses the recommended pattern for better compatibility with languages that use the singular form for other numbers. Also adds translator comments.

Props bplv, xkon.
See #39660.

#23 @SergeyBiryukov
3 weeks ago

In 41762:

Twenty Fourteen: Add missing singular placeholder in comments.php.

Uses the recommended pattern for better compatibility with languages that use the singular form for other numbers. Also adds translator comments.

Props bplv, xkon.
See #39660.

#24 @SergeyBiryukov
3 weeks ago

  • Resolution set to fixed
  • Status changed from reviewing to closed

Twenty Fourteen, Fifteen, Sixteen, and Seventeen use the recommended pattern now.

I guess Twenty Thirteen and older themes should be left as is, as they are used with WP versions that don't support language packs, so updating translations is not a trivial task there.

Note: See TracTickets for help on using tickets.