diff --git a/core/modules/content_translation/content_translation.admin.inc b/core/modules/content_translation/content_translation.admin.inc index c2c0926..bc9d3ed 100644 --- a/core/modules/content_translation/content_translation.admin.inc +++ b/core/modules/content_translation/content_translation.admin.inc @@ -9,6 +9,7 @@ use Drupal\Core\Language\Language; use Drupal\field\Entity\Field; use Drupal\field\Entity\FieldInstance; +use Drupal\field\Field as FieldService; /** * Returns a form element to configure field synchronization. @@ -100,8 +101,10 @@ function _content_translation_form_language_content_settings_form_alter(array &$ // We special case Field API fields as they always natively support // translation. - if (!empty($definition['configurable']) && ($field = field_info_field($entity_type, $field_name))) { - $instance = field_info_instance($entity_type, $field_name, $bundle); + // @todo Remove this special casing as soon as condfigurable and + // base field definitions are "unified". + if (!empty($definition['configurable']) && ($field = FieldService::fieldInfo()->getField($entity_type, $field_name))) { + $instance = FieldService::fieldInfo()->getInstance($entity_type, $bundle, $field_name); $form['settings'][$entity_type][$bundle]['fields'][$field_name] = array( '#label' => $instance['label'], '#type' => 'checkbox', @@ -118,7 +121,7 @@ function _content_translation_form_language_content_settings_form_alter(array &$ } } // Instead we need to rely on field definitions to determine whether - // they support translation. Whether they are actually enabled is + // fields support translation. Whether they are actually enabled is // determined through our settings. As a consequence only fields // that support translation can be enabled or disabled. elseif (isset($field_settings[$field_name]) || !empty($definition['translatable'])) { @@ -345,7 +348,7 @@ function _content_translation_update_field_translatability($settings) { foreach ($bundle_settings['fields'] as $field_name => $translatable) { // If a field is enabled for translation for at least one instance we // need to mark it as translatable. - if (field_info_field($entity_type, $field_name)) { + if (FieldService::fieldInfo()->getField($entity_type, $field_name)) { $fields[$entity_type][$field_name] = $translatable || !empty($fields[$entity_type][$field_name]); } } diff --git a/core/modules/content_translation/content_translation.pages.inc b/core/modules/content_translation/content_translation.pages.inc index be151b9..ccbfcee 100644 --- a/core/modules/content_translation/content_translation.pages.inc +++ b/core/modules/content_translation/content_translation.pages.inc @@ -76,7 +76,7 @@ function content_translation_overview(EntityInterface $entity) { $source = isset($entity->translation[$langcode]['source']) ? $entity->translation[$langcode]['source'] : ''; $is_original = $langcode == $original; $translation = $translations[$langcode]; - $label = $entity->label($langcode); + $label = $entity->getTranslation($langcode)->label(); $link = isset($links->links[$langcode]['href']) ? $links->links[$langcode] : array('href' => $path, 'language' => $language); $row_title = l($label, $link['href'], $link); diff --git a/core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationSettingsTest.php b/core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationSettingsTest.php index a10ad27..2646ac0 100644 --- a/core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationSettingsTest.php +++ b/core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationSettingsTest.php @@ -20,7 +20,7 @@ class ContentTranslationSettingsTest extends WebTestBase { * * @var array */ - public static $modules = array('language', 'content_translation', 'comment'); + public static $modules = array('language', 'content_translation', 'node', 'comment'); public static function getInfo() { return array( 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 ef579b2..dfec981 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 @@ -35,6 +35,7 @@ */ function testTranslationUI() { $this->assertBasicTranslation(); + $this->assertTranslationOverview(); $this->assertOutdatedStatus(); $this->assertPublishedStatus(); $this->assertAuthoringInfo(); @@ -99,6 +100,21 @@ protected function assertBasicTranslation() { } /** + * Tests that the translation overview shows the correct values. + */ + protected function assertTranslationOverview() { + $entity = entity_load($this->entityType, $this->entityId, TRUE); + $path = $this->controller->getBasePath($entity) . '/translations'; + $this->drupalGet($path); + + foreach ($this->langcodes as $langcode) { + if ($entity->hasTranslation($langcode)) { + $this->assertText($entity->getTranslation($langcode)->label(), format_string('Label correctly shown for %language translation', array('%language' => $langcode))); + } + } + } + + /** * Tests up-to-date status tracking. */ protected function assertOutdatedStatus() { diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeTranslationUITest.php b/core/modules/node/lib/Drupal/node/Tests/NodeTranslationUITest.php index 77c0bbd..1ff5485 100644 --- a/core/modules/node/lib/Drupal/node/Tests/NodeTranslationUITest.php +++ b/core/modules/node/lib/Drupal/node/Tests/NodeTranslationUITest.php @@ -16,11 +16,6 @@ class NodeTranslationUITest extends ContentTranslationUITest { /** - * The title of the test node. - */ - protected $title; - - /** * Modules to enable. * * @var array @@ -38,7 +33,6 @@ public static function getInfo() { function setUp() { $this->entityType = 'node'; $this->bundle = 'article'; - $this->title = $this->randomName(); parent::setUp(); $this->drupalPlaceBlock('system_help_block', array('region' => 'content')); } @@ -63,7 +57,7 @@ protected function getTranslatorPermissions() { */ protected function getNewEntityValues($langcode) { // Node title is not translatable yet, hence we use a fixed value. - return array('title' => $this->title) + parent::getNewEntityValues($langcode); + return array('title' => $this->randomName()) + parent::getNewEntityValues($langcode); } /** diff --git a/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/Entity/EntityTestMul.php b/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/Entity/EntityTestMul.php index 3f7e833..f983d71 100644 --- a/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/Entity/EntityTestMul.php +++ b/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/Entity/EntityTestMul.php @@ -33,7 +33,8 @@ * entity_keys = { * "id" = "id", * "uuid" = "uuid", - * "bundle" = "type" + * "bundle" = "type", + * "label" = "name" * }, * menu_base_path = "entity_test_mul/manage/%entity_test_mul" * ) diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermTranslationUITest.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermTranslationUITest.php index 20becd1..99594ee 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermTranslationUITest.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermTranslationUITest.php @@ -90,9 +90,9 @@ public function testTranslationUI() { // Make sure that no row was inserted for taxonomy vocabularies, which do // not have translations enabled. $rows = db_query('SELECT * FROM {content_translation}')->fetchAll(); - $this->assertEqual(2, count($rows)); - $this->assertEqual('taxonomy_term', $rows[0]->entity_type); - $this->assertEqual('taxonomy_term', $rows[1]->entity_type); + foreach ($rows as $row) { + $this->assertEqual('taxonomy_term', $row->entity_type); + } } /**