diff --git a/core/modules/content_translation/content_translation.pages.inc b/core/modules/content_translation/content_translation.pages.inc index ac36ff7..f2bb96f 100644 --- a/core/modules/content_translation/content_translation.pages.inc +++ b/core/modules/content_translation/content_translation.pages.inc @@ -30,11 +30,10 @@ function content_translation_overview(EntityInterface $entity) { $rel[$name] = $entity->getSystemPath($name); } - $header = array(t('Language'), t('Translation'), t('Source language'), t('Status'), t('Operations')); + $header = array(t('Language'), t('Translation'), t('Status'), t('Operations')); $rows = array(); if (\Drupal::languageManager()->isMultilingual()) { - // Determine whether the current entity is translatable. $translatable = FALSE; foreach (field_info_instances($entity->getEntityTypeId(), $entity->bundle()) as $instance) { @@ -44,6 +43,23 @@ function content_translation_overview(EntityInterface $entity) { } } + // Collect source languages for translations (non-originals). + $language_as_source = array(); + foreach ($languages as $language) { + $is_original = $language->id == $original; + if (!$is_original && isset($translations[$langcode])) { + $source = isset($entity->translation[$langcode]['source']) ? $entity->translation[$langcode]['source'] : ''; + $language_as_source[$source] = TRUE; + } + } + + // Add the source-translation column if there are more than one source value. + $show_source_column = count($language_as_source) > 1; + + if ($show_source_column) { + $header = array(t('Language'), t('Translation'), t('Source language'), t('Status'), t('Operations')); + } + foreach ($languages as $language) { $language_name = $language->name; $langcode = $language->id; @@ -125,7 +141,12 @@ function content_translation_overview(EntityInterface $entity) { $status = t('Not translated'); } - $rows[] = array($language_name, $row_title, $source_name, $status, $operations); + if ($show_source_column) { + $rows[] = array($language_name, $row_title, $source_name, $status, $operations); + } + else { + $rows[] = array($language_name, $row_title, $status, $operations); + } } }