diff --git a/core/modules/content_translation/content_translation.pages.inc b/core/modules/content_translation/content_translation.pages.inc index ac36ff7..a46702e 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,31 @@ function content_translation_overview(EntityInterface $entity) { } } + // Determine which languages have been used as a source for other + // translations. + $language_as_source = array(); + foreach ($languages as $language) { + $langcode = $language->id; + + $is_original = $langcode == $original; + // Original has no source. + if (!$is_original && isset($translations[$langcode])) { + // Non-original existing translation in the translation set: keep track + // of the source language. + $source = isset($entity->translation[$langcode]['source']) ? $entity->translation[$langcode]['source'] : ''; + // Note the source language has been used as a source. + $language_as_source[$source] = TRUE; + } + } + + // Only show the translations column if there is more than one source value. + $show_source_column = count($language_as_source) > 1; + + // Set up the translations table. + 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 +149,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); + } } }