diff --git a/core/lib/Drupal/Core/Entity/ContentEntityDeleteForm.php b/core/lib/Drupal/Core/Entity/ContentEntityDeleteForm.php index 5ef20387e8ea..4f9aff5d4698 100644 --- a/core/lib/Drupal/Core/Entity/ContentEntityDeleteForm.php +++ b/core/lib/Drupal/Core/Entity/ContentEntityDeleteForm.php @@ -39,7 +39,7 @@ class ContentEntityDeleteForm extends ContentEntityConfirmFormBase { $form['deleted_translations'] = [ '#theme' => 'item_list', '#title' => $this->t('The following @entity-type translations will be deleted:', [ - '@entity-type' => $entity->getEntityType()->getLowercaseLabel(), + '@entity-type' => $entity->getEntityType()->getSingularLabel(), ]), '#items' => $languages, ]; @@ -96,7 +96,7 @@ class ContentEntityDeleteForm extends ContentEntityConfirmFormBase { if (!$entity->isDefaultTranslation()) { return $this->t('The @entity-type %label @language translation has been deleted.', [ - '@entity-type' => $entity->getEntityType()->getLowercaseLabel(), + '@entity-type' => $entity->getEntityType()->getSingularLabel(), '%label' => $entity->label(), '@language' => $entity->language()->getName(), ]); @@ -114,7 +114,7 @@ class ContentEntityDeleteForm extends ContentEntityConfirmFormBase { if (!$entity->isDefaultTranslation()) { $this->logger($entity->getEntityType()->getProvider())->notice('The @entity-type %label @language translation has been deleted.', [ - '@entity-type' => $entity->getEntityType()->getLowercaseLabel(), + '@entity-type' => $entity->getEntityType()->getSingularLabel(), '%label' => $entity->label(), '@language' => $entity->language()->getName(), ]); @@ -134,7 +134,7 @@ class ContentEntityDeleteForm extends ContentEntityConfirmFormBase { if (!$entity->isDefaultTranslation()) { return $this->t('Are you sure you want to delete the @language translation of the @entity-type %label?', [ '@language' => $entity->language()->getName(), - '@entity-type' => $this->getEntity()->getEntityType()->getLowercaseLabel(), + '@entity-type' => $this->getEntity()->getEntityType()->getSingularLabel(), '%label' => $this->getEntity()->label(), ]); } diff --git a/core/lib/Drupal/Core/Entity/Controller/EntityController.php b/core/lib/Drupal/Core/Entity/Controller/EntityController.php index c7f1a69f2d33..8636f1d44243 100644 --- a/core/lib/Drupal/Core/Entity/Controller/EntityController.php +++ b/core/lib/Drupal/Core/Entity/Controller/EntityController.php @@ -148,7 +148,7 @@ class EntityController implements ContainerInjectionInterface { if ($bundle_entity_type_id) { $bundle_argument = $bundle_entity_type_id; $bundle_entity_type = $this->entityTypeManager->getDefinition($bundle_entity_type_id); - $bundle_entity_type_label = $bundle_entity_type->getLowercaseLabel(); + $bundle_entity_type_label = $bundle_entity_type->getSingularLabel(); $build['#cache']['tags'] = $bundle_entity_type->getListCacheTags(); // Build the message shown when there are no bundles. @@ -204,7 +204,7 @@ class EntityController implements ContainerInjectionInterface { */ public function addTitle($entity_type_id) { $entity_type = $this->entityTypeManager->getDefinition($entity_type_id); - return $this->t('Add @entity-type', ['@entity-type' => $entity_type->getLowercaseLabel()]); + return $this->t('Add @entity-type', ['@entity-type' => $entity_type->getSingularLabel()]); } /** diff --git a/core/lib/Drupal/Core/Entity/EntityDeleteFormTrait.php b/core/lib/Drupal/Core/Entity/EntityDeleteFormTrait.php index 4800f70cb365..7832a2590e54 100644 --- a/core/lib/Drupal/Core/Entity/EntityDeleteFormTrait.php +++ b/core/lib/Drupal/Core/Entity/EntityDeleteFormTrait.php @@ -45,7 +45,7 @@ trait EntityDeleteFormTrait { */ public function getQuestion() { return $this->t('Are you sure you want to delete the @entity-type %label?', [ - '@entity-type' => $this->getEntity()->getEntityType()->getLowercaseLabel(), + '@entity-type' => $this->getEntity()->getEntityType()->getSingularLabel(), '%label' => $this->getEntity()->label(), ]); } @@ -66,7 +66,7 @@ trait EntityDeleteFormTrait { protected function getDeletionMessage() { $entity = $this->getEntity(); return $this->t('The @entity-type %label has been deleted.', [ - '@entity-type' => $entity->getEntityType()->getLowercaseLabel(), + '@entity-type' => $entity->getEntityType()->getSingularLabel(), '%label' => $entity->label(), ]); } @@ -110,7 +110,7 @@ trait EntityDeleteFormTrait { protected function logDeletionMessage() { $entity = $this->getEntity(); $this->logger($entity->getEntityType()->getProvider())->notice('The @entity-type %label has been deleted.', [ - '@entity-type' => $entity->getEntityType()->getLowercaseLabel(), + '@entity-type' => $entity->getEntityType()->getSingularLabel(), '%label' => $entity->label(), ]); } diff --git a/core/lib/Drupal/Core/Entity/EntityType.php b/core/lib/Drupal/Core/Entity/EntityType.php index 388ea31a5467..f4c6d991d26f 100644 --- a/core/lib/Drupal/Core/Entity/EntityType.php +++ b/core/lib/Drupal/Core/Entity/EntityType.php @@ -775,6 +775,7 @@ class EntityType extends PluginDefinition implements EntityTypeInterface { * {@inheritdoc} */ public function getLowercaseLabel() { + @trigger_error('EntityType::getLowercaseLabel() is deprecated in drupal:8.8.0 and is removed from drupal:9.0.0. Instead, you should call getSingularLabel(). See https://www.drupal.org/node/3075567', E_USER_DEPRECATED); return mb_strtolower($this->getLabel()); } @@ -794,7 +795,7 @@ class EntityType extends PluginDefinition implements EntityTypeInterface { */ public function getSingularLabel() { if (empty($this->label_singular)) { - $lowercase_label = $this->getLowercaseLabel(); + $lowercase_label = mb_strtolower($this->getLabel()); $this->label_singular = $lowercase_label; } return $this->label_singular; @@ -805,7 +806,7 @@ class EntityType extends PluginDefinition implements EntityTypeInterface { */ public function getPluralLabel() { if (empty($this->label_plural)) { - $lowercase_label = $this->getLowercaseLabel(); + $lowercase_label = $this->getSingularLabel(); $this->label_plural = new TranslatableMarkup('@label entities', ['@label' => $lowercase_label], [], $this->getStringTranslation()); } return $this->label_plural; @@ -816,7 +817,7 @@ class EntityType extends PluginDefinition implements EntityTypeInterface { */ public function getCountLabel($count) { if (empty($this->label_count)) { - return $this->formatPlural($count, '@count @label', '@count @label entities', ['@label' => $this->getLowercaseLabel()], ['context' => 'Entity type label']); + return $this->formatPlural($count, '@count @label', '@count @label entities', ['@label' => $this->getSingularLabel()], ['context' => 'Entity type label']); } $context = isset($this->label_count['context']) ? $this->label_count['context'] : 'Entity type label'; return $this->formatPlural($count, $this->label_count['singular'], $this->label_count['plural'], ['context' => $context]); diff --git a/core/lib/Drupal/Core/Entity/EntityTypeInterface.php b/core/lib/Drupal/Core/Entity/EntityTypeInterface.php index 3a6702281da4..dafaf3cdc5ee 100644 --- a/core/lib/Drupal/Core/Entity/EntityTypeInterface.php +++ b/core/lib/Drupal/Core/Entity/EntityTypeInterface.php @@ -659,6 +659,10 @@ interface EntityTypeInterface extends PluginDefinitionInterface { * @return string * The lowercase form of the human-readable entity type name. * + * @deprecated deprecated in drupal:8.8.0 and is removed from drupal:9.0.0. + * Instead, you should call getSingularLabel(). + * See https://www.drupal.org/node/3075567 + * * @see \Drupal\Core\Entity\EntityTypeInterface::getLabel() */ public function getLowercaseLabel(); @@ -684,6 +688,9 @@ interface EntityTypeInterface extends PluginDefinitionInterface { * "opportunities"), "child" (with the plural as "children"), or "content * item" (with the plural as "content items"). * + * Think of it as an "in a full sentence, this is what we call this" label. As + * a consequence, the English version is lowercase. + * * @return string|\Drupal\Core\StringTranslation\TranslatableMarkup * The singular label. */ diff --git a/core/lib/Drupal/Core/Entity/Form/DeleteMultipleForm.php b/core/lib/Drupal/Core/Entity/Form/DeleteMultipleForm.php index aea3291bd430..2ff504cef15c 100644 --- a/core/lib/Drupal/Core/Entity/Form/DeleteMultipleForm.php +++ b/core/lib/Drupal/Core/Entity/Form/DeleteMultipleForm.php @@ -259,7 +259,7 @@ class DeleteMultipleForm extends ConfirmFormBase implements BaseFormIdInterface $storage->delete($delete_entities); foreach ($delete_entities as $entity) { $this->logger($entity->getEntityType()->getProvider())->notice('The @entity-type %label has been deleted.', [ - '@entity-type' => $entity->getEntityType()->getLowercaseLabel(), + '@entity-type' => $entity->getEntityType()->getSingularLabel(), '%label' => $entity->label(), ]); } @@ -275,7 +275,7 @@ class DeleteMultipleForm extends ConfirmFormBase implements BaseFormIdInterface $entity->save(); foreach ($translations as $translation) { $this->logger($entity->getEntityType()->getProvider())->notice('The @entity-type %label @language translation has been deleted.', [ - '@entity-type' => $entity->getEntityType()->getLowercaseLabel(), + '@entity-type' => $entity->getEntityType()->getSingularLabel(), '%label' => $entity->label(), '@language' => $translation->language()->getName(), ]); diff --git a/core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/UniqueFieldValueValidator.php b/core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/UniqueFieldValueValidator.php index 3c34ec9665e2..d2b1741a3a08 100644 --- a/core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/UniqueFieldValueValidator.php +++ b/core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/UniqueFieldValueValidator.php @@ -41,7 +41,7 @@ class UniqueFieldValueValidator extends ConstraintValidator { if ($value_taken) { $this->context->addViolation($constraint->message, [ '%value' => $item->value, - '@entity_type' => $entity->getEntityType()->getLowercaseLabel(), + '@entity_type' => $entity->getEntityType()->getSingularLabel(), '@field_name' => mb_strtolower($items->getFieldDefinition()->getLabel()), ]); } diff --git a/core/modules/block/src/Form/BlockDeleteForm.php b/core/modules/block/src/Form/BlockDeleteForm.php index e128ea7e7ec2..69322062a0dc 100644 --- a/core/modules/block/src/Form/BlockDeleteForm.php +++ b/core/modules/block/src/Form/BlockDeleteForm.php @@ -31,7 +31,7 @@ class BlockDeleteForm extends EntityDeleteForm { */ public function getQuestion() { return $this->t('Are you sure you want to remove the @entity-type %label?', [ - '@entity-type' => $this->getEntity()->getEntityType()->getLowercaseLabel(), + '@entity-type' => $this->getEntity()->getEntityType()->getSingularLabel(), '%label' => $this->getEntity()->label(), ]); } @@ -42,7 +42,7 @@ class BlockDeleteForm extends EntityDeleteForm { protected function getDeletionMessage() { $entity = $this->getEntity(); return $this->t('The @entity-type %label has been removed.', [ - '@entity-type' => $entity->getEntityType()->getLowercaseLabel(), + '@entity-type' => $entity->getEntityType()->getSingularLabel(), '%label' => $entity->label(), ]); } diff --git a/core/modules/config/src/Form/ConfigSingleImportForm.php b/core/modules/config/src/Form/ConfigSingleImportForm.php index 3072999149dc..8d80f1fb595d 100644 --- a/core/modules/config/src/Form/ConfigSingleImportForm.php +++ b/core/modules/config/src/Form/ConfigSingleImportForm.php @@ -219,7 +219,7 @@ class ConfigSingleImportForm extends ConfirmFormBase { else { $definition = $this->entityTypeManager->getDefinition($this->data['config_type']); $name = $this->data['import'][$definition->getKey('id')]; - $type = $definition->getLowercaseLabel(); + $type = $definition->getSingularLabel(); } $args = [ diff --git a/core/modules/config_translation/config_translation.module b/core/modules/config_translation/config_translation.module index 5ca9313f717c..e22ecd82702f 100644 --- a/core/modules/config_translation/config_translation.module +++ b/core/modules/config_translation/config_translation.module @@ -142,7 +142,7 @@ function config_translation_config_translation_info(&$info) { $info[$entity_type_id] = [ 'class' => '\Drupal\config_translation\ConfigEntityMapper', 'base_route_name' => $base_route_name, - 'title' => $entity_type->getLowercaseLabel(), + 'title' => $entity_type->getSingularLabel(), 'names' => [], 'entity_type' => $entity_type_id, 'weight' => 10, diff --git a/core/modules/config_translation/tests/src/Functional/ConfigTranslationOverviewTest.php b/core/modules/config_translation/tests/src/Functional/ConfigTranslationOverviewTest.php index ec90074d7101..45f6636b37cd 100644 --- a/core/modules/config_translation/tests/src/Functional/ConfigTranslationOverviewTest.php +++ b/core/modules/config_translation/tests/src/Functional/ConfigTranslationOverviewTest.php @@ -110,13 +110,13 @@ class ConfigTranslationOverviewTest extends BrowserTestBase { $entity_type = \Drupal::entityTypeManager()->getDefinition($test_entity->getEntityTypeId()); $this->drupalGet($base_url . '/translate'); - $title = $test_entity->label() . ' ' . $entity_type->getLowercaseLabel(); + $title = $test_entity->label() . ' ' . $entity_type->getSingularLabel(); $title = 'Translations for ' . Html::escape($title) . ''; $this->assertRaw($title); $this->assertRaw('