When there was only one type of entity label, we had to use that in all places and transform it to the appropriate form. For example in our EntityDeriver plugins, we would generate an event called "Before saving @entity_type", and for @entity_type we had to use $entity_type->getLowercaseLabel() which is simply a lowercase version of our entity label.

But now we have label, label_singular, label_plural, label_count, and label_collection (see Entity types can specify plural labels now and Entity types can specify collection labels now)and now that Rules supports these various labels (see #2922889: Update entity label annotations) we can choose which one is best to use in our situation. In the above example, because we really intend for @entity_type to be the indefinite singular label it is better to use $entity_type->getSingularLabel().

In practice, getLowercaseLabel() and getSingularLabel() are identical with very few exceptions. The only difference I have noticed in Drupal core is for the 'node' entity, where the label is 'Content' so getLowercaseLabel() will return 'content' while getSingularLabel() will return 'content item'.

So the visible effect of this patch is that Node entity events such as "Before saving content" will now be "Before saving a content item". Although this is a small change, it should improve the wording for non-core entities as well. For example, with the "SMS Message" entity getLowercaseLabel() is "sms message" which is clearly not what we want - SMS is an acronym and should always be capitalized. Instead if we use getSingularLabel() it returns the correct "SMS message" in this case.

Comments

TR created an issue. See original summary.

tr’s picture

Issue summary: View changes
tr’s picture

StatusFileSize
new9 KB

Forgot to update the test text for the new singular labels. Here's a new patch with the modified tests.

  • TR committed 01cddc7 on 8.x-3.x
    Issue #2993612 by TR: Use proper singular/plural entity labels where...
tr’s picture

Status: Needs review » Fixed

Committed.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.