Problem/Motivation

Currently the translate operation link is available only for nodes. See:

function content_translation_entity_operation_alter(array &$operations, \Drupal\Core\Entity\EntityInterface $entity) {
  // @todo Use an access permission.
  if ($entity instanceof NodeInterface && $entity->isTranslatable()) {
    $operations['translate'] = array(
      'title' => t('Translate'),
      'url' => $entity->urlInfo('drupal:content-translation-overview'),
    );
  }
}

Proposed resolution

1. Implement hook_entity_operation() instead.
2. Instead of relying on NodeInterface and $entity->isTranslatable(), use content_translation_translate_access() and look for the link template.
3. Add tests.

Remaining tasks

Commit.

User interface changes

Translate operation will show among entity operations, such as this operation list for blocks:

API changes

None.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

larowlan’s picture

Will need tests

olli’s picture

Issue tags: +D8MI
FileSize
1.35 KB
753 bytes

Rerolled and added the hasLinkTemplate() check.

Jalandhar’s picture

Status: Needs review » Needs work
Issue tags: +Needs reroll

Patch needs to be updated again.

estoyausente’s picture

Status: Needs work » Needs review
FileSize
1.33 KB

Rerolled.

estoyausente’s picture

Issue tags: +Amsterdam2014
star-szr’s picture

Status: Needs review » Needs work
Issue tags: -Needs reroll +Needs tests

Thanks @estoyausente. Tagging for test coverage.

Gábor Hojtsy’s picture

Issue tags: +language-content

This is a great patch. Also a good find! Still needs tests though.

olli’s picture

Status: Needs work » Needs review
Issue tags: -Needs tests
FileSize
684 bytes
2.06 KB
1.53 KB

Added a small test.

The last submitted patch, 8: 2256023-8-test_only.patch, failed testing.

Gábor Hojtsy’s picture

Title: Translate operation is not available for custom blocks » Content translation operation is only available for nodes, not other entity types such as custom blocks
Issue summary: View changes
Status: Needs review » Reviewed & tested by the community

Yay, looks great :) Thanks!

Gábor Hojtsy’s picture

Issue summary: View changes
FileSize
117.32 KB
alexpott’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs reroll

Needs a reroll.

adci_contributor’s picture

Status: Needs work » Needs review
FileSize
2.01 KB

Trying to reroll

Gábor Hojtsy’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: -Needs reroll +sprint

Thanks.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

This issue is a normal bug fix, and doesn't include any disruptive changes, so it is allowed per https://www.drupal.org/core/beta-changes. Committed 39268b1 and pushed to 8.0.x. Thanks!

  • alexpott committed 39268b1 on 8.0.x
    Issue #2256023 by olli, Gábor Hojtsy, estoyausente, adci_contributor:...
Gábor Hojtsy’s picture

Issue tags: -sprint

Thanks all! Superb!

Status: Fixed » Closed (fixed)

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