Access callback for the translation addition page.
\Drupal\Core\Entity\EntityInterface $entity: The entity being translated.
\Drupal\Core\Language\Language $source: The language of the values being translated.
\Drupal\Core\Language\Language $target: The language of the translated values.
function translation_entity_add_access(EntityInterface $entity, Language $source = NULL, Language $target = NULL) {
$source = !empty($source) ? $source : $entity
->language();
$target = !empty($target) ? $target : language(LANGUAGE_TYPE_CONTENT);
$translations = $entity
->getTranslationLanguages();
$languages = language_list();
return $source->langcode != $target->langcode && isset($languages[$source->langcode]) && isset($languages[$target->langcode]) && !isset($translations[$target->langcode]) && translation_entity_access($entity, $target->langcode);
}