WordPress.org

Make WordPress Core

Opened 7 years ago

Last modified 2 years ago

#23257 new enhancement

Add plural versions of Post Format strings

Reported by: obenland Owned by:
Milestone: Future Release Priority: normal
Severity: normal Version: 3.5
Component: Post Formats Keywords:
Focuses: Cc:
PR Number:

Description

To make it easier for theme authors to create meaningful titles for post format archive pages, we could extend get_post_format_strings() to also provide a standardized set of plurals.

I'm not entirely sure whether the plurals I used in the diff are the ones we actually want to go with (apparently there is no plural of 'Audio'?), but the change is fairly simple and is backwards compatible.

See this discussion for additional context.

Attachments (3)

23257.diff (2.3 KB) - added by obenland 7 years ago.
23257.2.diff (2.0 KB) - added by kovshenin 7 years ago.
23257.3.diff (2.6 KB) - added by iamfriendly 4 years ago.
Refreshed the patch and added docs

Download all attachments as: .zip

Change History (19)

@obenland
7 years ago

#1 @DrewAPicture
7 years ago

Makes good sense. +1

#2 @mfields
7 years ago

  • Cc mfields removed

#3 @mfields
7 years ago

  • Cc michael@… added

#4 @kovshenin
7 years ago

  • Cc kovshenin added

I agree that it makes sense, but I disagree with the proposed patch. In languages with more than one plural form, some of the forms make no sense without the number context: for example in Russian, "comments", "2 comments", "5 comments" will all have different translations.

It's probably why _n is mostly used with printf. So to generate a title for the archives in a theme, what are you going to pass as the $number argument? The number of found posts, the number of posts on the page, or perhaps a random plural number? :)

Again, due to plural forms in Russian, if you pass, say 21 to that function, it will actually return the singular form of the post format. The plurals 21, 101, 151, 1000001, etc are plural, but they use the singular form words and in order to be differentiated from the real singular (1) they need the number to be in context. Sorry this is so confusing, maybe SergeyBiryukov can clarify :)

I don't know about other languages, but I think than changing $number to be a boolean $plural could work, then we'd just provide plural translations of post formats without the number context and without _n:

'gallery' => ( $plural ) ? _x( 'Galleries', 'Plural post format' ) : _x( 'Gallery', 'Post format' ),

It'll work for the post format archives title, but will fail if you put a number in context, like "this blog has 5 galleries". What are the other use cases for post formats plural forms, a except post format archives title? Can we make a function that would fit all use cases?

Also, I think "standards" is pretty weird, and "audio" is uncountable, so the plural would remain "audio" not "audios" :)

#5 follow-up: @dd32
7 years ago

Pretty sure this is why wer have _n_noop() - To register a plural translation, but not actually translate until later (when we have the $count)

#6 in reply to: ↑ 5 @kovshenin
7 years ago

Replying to dd32: I thought of that, but it doesn't solve the problem since the number is not removed from the context, it's just added at a later stage when translate_nooped_plural is called. The wording for a post format archives title is different than the wording used with post formats with a number in context.

#7 @nacin
7 years ago

As kovshenin hints, gettext plural handling is only for when there is a specific number. Otherwise, this should be be general plurals, and translators will pick a construct in their language that works.

In core, that means:

__( 'Gallery' )
__( 'Galleries' )
_x( 'Audio', 'singular' )
_x( 'Audio', 'plural' )

We do this with post types too.

@kovshenin
7 years ago

#8 @kovshenin
7 years ago

Plurals without numbers in 23257.2.diff.

#9 @iseulde
6 years ago

  • Component changed from General to Post Formats

#10 @lancewillett
6 years ago

In 26674:

Twenty Fourteen: add future TODO for post format string plurals, see #23257.

#11 @lancewillett
6 years ago

  • Keywords early added
  • Milestone changed from Awaiting Review to Future Release

#12 @chriscct7
4 years ago

  • Keywords needs-docs added; early removed

Docbloc I believe (and Drew might correct me on this) has to have a line for since that explains the updates to the filter

#13 @chriscct7
4 years ago

  • Keywords needs-refresh added; has-patch removed

@iamfriendly
4 years ago

Refreshed the patch and added docs

#14 @iamfriendly
4 years ago

  • Keywords needs-docs needs-refresh removed

Refreshed the patch due to location of functions changes and added the requisite docs.

This ticket was mentioned in Slack in #design by karmatosed. View the logs.


2 years ago

#16 @melchoyce
2 years ago

  • Keywords ux-feedback removed

This makes sense to me. The ticket's a bit old — is it still an issue?

Note: See TracTickets for help on using tickets.