diff --git a/core/modules/content_translation/content_translation.pages.inc b/core/modules/content_translation/content_translation.pages.inc index 26beb45..017da96 100644 --- a/core/modules/content_translation/content_translation.pages.inc +++ b/core/modules/content_translation/content_translation.pages.inc @@ -30,7 +30,6 @@ function content_translation_overview(EntityInterface $entity) { $rel[$name] = $entity->getSystemPath($name); } - $header = array(t('Language'), t('Translation'), t('Status'), t('Operations')); $rows = array(); if (\Drupal::languageManager()->isMultilingual()) { @@ -43,23 +42,11 @@ function content_translation_overview(EntityInterface $entity) { } } - // Collect source languages for translations (non-originals). - $language_as_source = array(); - foreach ($languages as $language) { - $langcode = $language->id; - $is_original = $langcode == $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 is 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')); - } + // Show source-language column if there are non-original source langcodes. + $additional_source_langcodes = array_filter($entity->translation, function ($a) use ($original) { + return isset($a['source']) && $a['source'] && $a['source'] != $original; + }); + $show_source_column = count($additional_source_langcodes) > 0; foreach ($languages as $language) { $language_name = $language->name; @@ -157,6 +144,13 @@ function content_translation_overview(EntityInterface $entity) { // which entity this is. $build['#entity'] = $entity; + if (isset($show_source_column) && $show_source_column == TRUE) { + $header = array(t('Language'), t('Translation'), t('Source language'), t('Status'), t('Operations')); + } + else { + $header = array(t('Language'), t('Translation'), t('Status'), t('Operations')); + } + $build['content_translation_overview'] = array( '#type' => 'table', '#header' => $header, diff --git a/core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationUITest.php b/core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationUITest.php index 2ebc178..699509c 100644 --- a/core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationUITest.php +++ b/core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationUITest.php @@ -55,7 +55,7 @@ protected function doTestBasicTranslation() { $this->drupalGet($entity->getSystemPath()); $this->assertResponse(200, 'Entity URL is valid.'); $this->drupalGet($entity->getSystemPath('drupal:content-translation-overview')); - $this->assertNoText('Source language', format_string('Source language column correctly hidden.')); + $this->assertNoText('Source language', 'Source language column correctly hidden.'); $translation = $this->getTranslation($entity, $default_langcode); foreach ($values[$default_langcode] as $property => $value) { @@ -77,7 +77,7 @@ protected function doTestBasicTranslation() { } $entity = entity_load($this->entityTypeId, $this->entityId, TRUE); $this->drupalGet($entity->getSystemPath('drupal:content-translation-overview')); - $this->assertNoText('Source language', format_string('Source language column correctly hidden.')); + $this->assertNoText('Source language', 'Source language column correctly hidden.'); // Switch the source language. $langcode = 'fr'; @@ -96,7 +96,7 @@ protected function doTestBasicTranslation() { $this->drupalPostForm($path, $edit, $this->getFormSubmitActionForNewTranslation($entity, $langcode)); $entity = entity_load($this->entityTypeId, $this->entityId, TRUE); $this->drupalGet($entity->getSystemPath('drupal:content-translation-overview')); - $this->assertText('Source language', format_string('Source language column correctly shown.')); + $this->assertText('Source language', 'Source language column correctly shown.'); // Check that the entered values have been correctly stored. foreach ($values as $langcode => $property_values) {