WordPress.org

Make WordPress Core

Opened 12 months ago

Closed 4 months ago

Last modified 3 months 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 12 months ago.
39660.2.diff (7.6 KB) - added by xkon 5 months ago.
Updates to TwentySixteen

Download all attachments as: .zip

Change History (27)

#1 in reply to: ↑ description @bplv
12 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
12 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
12 months ago

#3 @bplv
12 months ago

  • Keywords has-patch added; needs-patch removed

Hello, @SergeyBiryukov

I have added the patch.

Thank you.

#4 @SergeyBiryukov
12 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.


11 months ago

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


9 months ago

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


9 months ago

#8 @jbpaul17
9 months ago

  • Milestone changed from 4.8 to 4.8.1

Punting to 4.8.1 per today's bug scrub.

#9 @jbpaul17
7 months ago

  • Keywords needs-testing added

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


7 months ago

#11 @SergeyBiryukov
7 months ago

  • Milestone changed from 4.8.1 to 4.9

#12 @SergeyBiryukov
7 months ago

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

#13 @kakshak
6 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
5 months ago

  • Keywords has-unit-tests removed

#15 in reply to: ↑ 2 ; follow-up: @SergeyBiryukov
5 months 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
5 months ago

Updates to TwentySixteen

#16 in reply to: ↑ 15 @xkon
5 months 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 months ago

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


4 months ago

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


4 months ago

#20 @SergeyBiryukov
4 months 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.


4 months ago

#22 @SergeyBiryukov
4 months 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
4 months 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
4 months 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.

#25 @ismail.elkorchi
3 months ago

@SergeyBiryukov I think that, instead of converting 1 to '1', it is best to do the opposite by converting get_comments_number() to an integer using intval().

See: http://php.net/manual/en/function.intval.php

Note: See TracTickets for help on using tickets.