summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwebchick2014-05-06 21:24:08 (GMT)
committerwebchick2014-05-06 21:24:08 (GMT)
commit0828fa9e6fff854ca93eb4a0461de8a81457b863 (patch)
treeb34e82e982f82b9d0b48f301c156d9bd29c88c5c
parent93d73d567878d81f3f4c324fd20ba1b930124093 (diff)
Issue #1832870 by -enzo-, YesCT, EllaTheHarpy, Pinolo, dlu, seranooo5, ivanchaer, mauzeh, filijonka, robertdbailey | maryedith: Only show source translation column if there are 2 or more source languages (more than n/a and the original language).
-rw-r--r--core/modules/content_translation/content_translation.pages.inc23
-rw-r--r--core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationUITest.php9
2 files changed, 29 insertions, 3 deletions
diff --git a/core/modules/content_translation/content_translation.pages.inc b/core/modules/content_translation/content_translation.pages.inc
index 4d2fefc..d4a7c48 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'));
$rows = array();
+ $show_source_column = FALSE;
if (\Drupal::languageManager()->isMultilingual()) {
-
// Determine whether the current entity is translatable.
$translatable = FALSE;
foreach (\Drupal::entityManager()->getFieldDefinitions($entity->getEntityTypeId(), $entity->bundle()) as $field_definition) {
@@ -44,6 +43,12 @@ function content_translation_overview(EntityInterface $entity) {
}
}
+ // Show source-language column if there are non-original source langcodes.
+ $additional_source_langcodes = array_filter($entity->translation, function ($translation) use ($original) {
+ return !empty($translation['source']) && $translation['source'] != $original;
+ });
+ $show_source_column = !empty($additional_source_langcodes);
+
foreach ($languages as $language) {
$language_name = $language->name;
$langcode = $language->id;
@@ -125,7 +130,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);
+ }
}
}
@@ -135,6 +145,13 @@ function content_translation_overview(EntityInterface $entity) {
// which entity this is.
$build['#entity'] = $entity;
+ if ($show_source_column) {
+ $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 4454176..12caf73 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
@@ -54,6 +54,8 @@ abstract class ContentTranslationUITest extends ContentTranslationTestBase {
$this->assertTrue($entity, 'Entity found in the database.');
$this->drupalGet($entity->getSystemPath());
$this->assertResponse(200, 'Entity URL is valid.');
+ $this->drupalGet($entity->getSystemPath('drupal:content-translation-overview'));
+ $this->assertNoText('Source language', 'Source language column correctly hidden.');
$translation = $this->getTranslation($entity, $default_langcode);
foreach ($values[$default_langcode] as $property => $value) {
@@ -74,20 +76,27 @@ abstract class ContentTranslationUITest extends ContentTranslationTestBase {
$this->assertNoFieldByXPath('//select[@id="edit-langcode"]', NULL, 'Language selector correctly disabled on translations.');
}
$entity = entity_load($this->entityTypeId, $this->entityId, TRUE);
+ $this->drupalGet($entity->getSystemPath('drupal:content-translation-overview'));
+ $this->assertNoText('Source language', 'Source language column correctly hidden.');
// Switch the source language.
$langcode = 'fr';
$source_langcode = 'it';
$edit = array('source_langcode[source]' => $source_langcode);
$path = $langcode . '/' . $content_translation_path . '/add/' . $default_langcode . '/' . $langcode;
+ // This does not save anything, it merely reloads the form and fills in the
+ // fields with the values from the different source language.
$this->drupalPostForm($path, $edit, t('Change'));
$this->assertFieldByXPath("//input[@name=\"{$this->fieldName}[0][value]\"]", $values[$source_langcode][$this->fieldName][0]['value'], 'Source language correctly switched.');
// Add another translation and mark the other ones as outdated.
$values[$langcode] = $this->getNewEntityValues($langcode);
$edit = $this->getEditValues($values, $langcode) + array('content_translation[retranslate]' => TRUE);
+ $path = $langcode . '/' . $content_translation_path . '/add/' . $source_langcode . '/' . $langcode;
$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', 'Source language column correctly shown.');
// Check that the entered values have been correctly stored.
foreach ($values as $langcode => $property_values) {