Opened 12 years ago
Last modified 7 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: |
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)
Change History (19)
#4
@
12 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:
↓ 6
@
12 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
@
12 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
@
12 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.
#8
@
12 years ago
Plurals without numbers in 23257.2.diff.
#11
@
11 years ago
- Keywords early added
- Milestone changed from Awaiting Review to Future Release
Once this is in we can remove a huge chunk of code from Twenty Fourteen: see http://core.trac.wordpress.org/browser/trunk/src/wp-content/themes/twentyfourteen/taxonomy-post_format.php?rev=26674#L29
#12
@
9 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
#14
@
9 years ago
- Keywords needs-docs needs-refresh removed
Refreshed the patch due to location of functions changes and added the requisite docs.
Makes good sense. +1