Opened 4 months ago

Last modified 4 months ago

#23257 new enhancement

Add plural versions of Post Format strings

Reported by: obenland Owned by:
Priority: normal Milestone: Awaiting Review
Component: General Version: 3.5
Severity: normal Keywords: has-patch ux-feedback
Cc: helen, PeteMall, michael@…, kovshenin

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 (2)

23257.diff (2.3 KB) - added by obenland 4 months ago.
23257.2.diff (2.0 KB) - added by kovshenin 4 months ago.

Download all attachments as: .zip

Change History (10)

Makes good sense. +1

  • Cc mfields removed
  • Cc michael@… added
  • 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" :)

comment:5 follow-up: ↓ 6   dd324 months 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)

comment:6 in reply to: ↑ 5   kovshenin4 months 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.

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.

Plurals without numbers in 23257.2.diff.

Note: See TracTickets for help on using tickets.