Make WordPress Core

Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#52800 closed enhancement (wontfix)

Make most default post type labels use "name" and "singular_name" variables instead of defaulting to Post/Page

Reported by: jaspercreel's profile jaspercreel Owned by:
Milestone: Priority: normal
Severity: minor Version: 5.7
Component: Posts, Post Types Keywords:
Focuses: Cc:

Description

It's always bothered me that, when the only thing I want to change about labels for custom post types are name and singular name, I have to pull up the list of allowed labels and change out Post/Page for each one if I want to be comprehensive. I think it makes much more sense to let the name or singular name, if provided, be the default in almost every label.

I actually coded out a way to do this, but I want to write some good unit tests before I say it officially works. It involves splitting up the default labels into ones which can use string templates to add in the name/singular name, and keeping the original default labels array with the hierarchical and non-hierarchical defaults.

Change History (3)

#1 @TimothyBlynJacobs
4 years ago

Hi @jaspercreel,

Welcome to trac!

The reason that separate strings are used is because in many languages you can't simply substitute the noun in a sentence without changing other parts of the sentence the way you often can in English. So, for instance, something like this wouldn't work.

sprintf( __( 'Add New %s' ), $label )

#2 @SergeyBiryukov
4 years ago

  • Keywords dev-feedback needs-unit-tests removed
  • Milestone Awaiting Review deleted
  • Resolution set to wontfix
  • Status changed from new to closed

Hi there, welcome to WordPress Trac! Thanks for the ticket.

Unfortunately, as noted above, just inserting a post type name into a generic string like %s updated is not translatable, hence the need for a full array of various labels.

A general best practice in WordPress is to avoid post type and taxonomy names in generic strings due to i18n concerns and structural differences in languages. See the previous discussions for reference:

To clarify a bit more, while both the post type name and the %s updated string itself are translatable, this or any other generic string like that is not correctly translatable. It does not account for different word order or declensions in other languages, so no matter how you translate it, the result is still incorrect.

For example, in Russian, "Post" is feminine and "Product" is masculine, so "New post" and "New product" would require a different translation and there is simply no way to translate New %s to account for both. We also don't use capital letters for multiple words in a row, so "New Post" or "New Product" is not quite correct, it should be "New post" or "New product".

That is the case for many other languages too, and is the reason why WordPress core does not use generic strings for post type or taxonomy names, and offers an array of labels to be used instead.

#3 @jaspercreel
4 years ago

That makes a lot of sense. Thanks for the feedback!

Note: See TracTickets for help on using tickets.