getLanguageName example


      ];
      $this->messenger()->addWarning($this->renderer->renderPlain($message));

      $original_langcode = LanguageInterface::LANGCODE_NOT_SPECIFIED;
      $operations_access = FALSE;
    }

    if (!isset($languages[$original_langcode])) {
      // If the language is not configured on the site, create a dummy language       // object for this listing only to ensure the user gets useful info.       $language_name = $this->languageManager->getLanguageName($original_langcode);
      $languages[$original_langcode] = new Language(['id' => $original_langcode, 'name' => $language_name]);
    }

    // We create a fake request object to pass into     // ConfigMapperInterface::populateFromRouteMatch() for the different languages.     // Creating a separate request for each language and route is neither easily     // possible nor performant.     $fake_request = $request->duplicate();

    $page['languages'] = [
      '#type' => 'table',
      
'#url' => $entity->toUrl(),
    ];
    $row['type'] = $entity->bundle->entity->label();
    $row['author']['data'] = [
      '#theme' => 'username',
      '#account' => $entity->getOwner(),
    ];
    $row['status'] = $entity->isPublished() ? $this->t('Published') : $this->t('Unpublished');
    $row['changed'] = $this->dateFormatter->format($entity->getChangedTime(), 'short');

    if ($this->languageManager->isMultilingual()) {
      $row['language'] = $this->languageManager->getLanguageName($entity->language()->getId());
    }
    return $row + parent::buildRow($entity);
  }

  /** * {@inheritdoc} */
  protected function getEntityIds() {
    $query = $this->getStorage()->getQuery()
      ->accessCheck(TRUE)
      ->sort('changed', 'DESC');

    
'#title' => $alias,
      '#url' => $url,
    ];

    $row['data']['path']['data'] = [
      '#type' => 'link',
      '#title' => $path,
      '#url' => $url,
    ];

    if ($this->languageManager->isMultilingual()) {
      $row['data']['language_name'] = $this->languageManager->getLanguageName($langcode);
    }

    $row['data']['operations']['data'] = $this->buildOperations($entity);

    // If the system path maps to a different URL alias, highlight this table     // row to let the user know of old aliases.     if ($alias != $this->aliasManager->getAliasByPath($path$langcode)) {
      $row['class'] = ['warning'];
    }

    return $row;
  }
/** * {@inheritdoc} */
  public function getFormId() {
    return 'node_revision_revert_translation_confirm';
  }

  /** * {@inheritdoc} */
  public function getQuestion() {
    return $this->t('Are you sure you want to revert @language translation to the revision from %revision-date?', ['@language' => $this->languageManager->getLanguageName($this->langcode), '%revision-date' => $this->dateFormatter->format($this->revision->getRevisionCreationTime())]);
  }

  /** * {@inheritdoc} */
  public function getDescription() {
    return '';
  }

  /** * {@inheritdoc} */
'#url' => $entity->toUrl(),
    ];
    $row['type'] = node_get_type_label($entity);
    $row['author']['data'] = [
      '#theme' => 'username',
      '#account' => $entity->getOwner(),
    ];
    $row['status'] = $entity->isPublished() ? $this->t('published') : $this->t('not published');
    $row['changed'] = $this->dateFormatter->format($entity->getChangedTime(), 'short');
    $language_manager = \Drupal::languageManager();
    if ($language_manager->isMultilingual()) {
      $row['language_name'] = $language_manager->getLanguageName($entity->language()->getId());
    }
    $row['operations']['data'] = $this->buildOperations($entity);
    return $row + parent::buildRow($entity);
  }

}
Home | Imprint | This part of the site doesn't use cookies.