Unverified Commit 36513da3 authored by Alex Pott's avatar Alex Pott
Browse files

fix: #3622503 View entity type's translation context is passed to the wrong...

fix: #3622503 View entity type's translation context is passed to the wrong TranslatableMarkup() argument

By: inascon
By: burcu.sogut@drupart.com.tr
(cherry picked from commit e0ac9d3c)
parent 5910ba0a
Loading
Loading
Loading
Loading
+5 −4
Changes for core/modules/views/src/Entity/View.php: 5 added lines, 4 removed lines.
Original line number Diff line number Diff line
@@ -21,10 +21,10 @@
 */
#[ConfigEntityType(
  id: 'view',
  label: new TranslatableMarkup('View', ['context' => 'View entity type']),
  label_collection: new TranslatableMarkup('Views', ['context' => 'View entity type']),
  label_singular: new TranslatableMarkup('view', ['context' => 'View entity type']),
  label_plural: new TranslatableMarkup('views', ['context' => 'View entity type']),
  label: new TranslatableMarkup('View', [], ['context' => 'View entity type']),
  label_collection: new TranslatableMarkup('Views', [], ['context' => 'View entity type']),
  label_singular: new TranslatableMarkup('view', [], ['context' => 'View entity type']),
  label_plural: new TranslatableMarkup('views', [], ['context' => 'View entity type']),
  entity_keys: [
    'id' => 'id',
    'label' => 'label',
@@ -34,6 +34,7 @@
  label_count: [
    'singular' => '@count view',
    'plural' => '@count views',
    'context' => 'View entity type',
  ],
  config_export: [
    'id',
+19 −0
Changes for core/modules/views/tests/src/Kernel/ViewStorageTest.php: 19 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -340,4 +340,23 @@ public function testCreateDuplicate(): void {
    }
  }

  /**
   * Tests that the view entity type labels use the translation context.
   */
  public function testEntityTypeLabelContext(): void {
    $entity_type = \Drupal::entityTypeManager()->getDefinition('view');
    $labels = [
      'View' => $entity_type->getLabel(),
      'Views' => $entity_type->getCollectionLabel(),
      'view' => $entity_type->getSingularLabel(),
      'views' => $entity_type->getPluralLabel(),
    ];
    foreach ($labels as $string => $label) {
      $this->assertSame($string, $label->getUntranslatedString());
      $this->assertSame('View entity type', $label->getOption('context'));
      $this->assertSame([], $label->getArguments());
    }
    $this->assertSame('View entity type', $entity_type->getCountLabel(1)->getOption('context'));
  }

}