Make WordPress Core

Opened 8 years ago

Closed 7 years ago

Last modified 7 years ago

#39660 closed enhancement (fixed)

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

Reported by: bplv's profile bplv Owned by: sergeybiryukov's profile 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 8 years ago.
39660.2.diff (7.6 KB) - added by xkon 7 years ago.
Updates to TwentySixteen

Download all attachments as: .zip

Change History (27)

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

#3 @bplv
8 years ago

  • Keywords has-patch added; needs-patch removed

Hello, @SergeyBiryukov

I have added the patch.

Thank you.

#4 @SergeyBiryukov
8 years 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 years ago

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


8 years ago

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


8 years ago

#8 @jbpaul17
8 years ago

  • Milestone changed from 4.8 to 4.8.1

Punting to 4.8.1 per today's bug scrub.

#9 @jbpaul17
7 years ago

  • Keywords needs-testing added

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


7 years ago

#11 @SergeyBiryukov
7 years ago

  • Milestone changed from 4.8.1 to 4.9

#12 @SergeyBiryukov
7 years ago

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

#13 @kakshak
7 years 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
7 years ago

  • Keywords has-unit-tests removed

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

Updates to TwentySixteen

#16 in reply to: ↑ 15 @xkon
7 years 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.


7 years ago

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


7 years ago

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


7 years ago

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


7 years ago

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