diff --git a/core/modules/aggregator/src/FeedForm.php b/core/modules/aggregator/src/FeedForm.php index 35359ce..aa5069c 100644 --- a/core/modules/aggregator/src/FeedForm.php +++ b/core/modules/aggregator/src/FeedForm.php @@ -19,19 +19,6 @@ class FeedForm extends ContentEntityForm { /** * {@inheritdoc} */ - public function form(array $form, FormStateInterface $form_state) { - $form = parent::form($form, $form_state); - // @todo Allow non translatable entity types having language support to be - // configured in the content language setting. - - // Ensure the language widget is displayed. - $form['langcode']['#access'] = TRUE; - return $form; - } - - /** - * {@inheritdoc} - */ public function save(array $form, FormStateInterface $form_state) { $feed = $this->entity; $insert = (bool) $feed->id(); diff --git a/core/modules/aggregator/src/Tests/FeedLanguageTest.php b/core/modules/aggregator/src/Tests/FeedLanguageTest.php index dfe5e99..d20569e 100644 --- a/core/modules/aggregator/src/Tests/FeedLanguageTest.php +++ b/core/modules/aggregator/src/Tests/FeedLanguageTest.php @@ -49,6 +49,15 @@ protected function setUp() { * Tests creation of feeds with a language. */ public function testFeedLanguage() { + $admin_user = $this->drupalCreateUser(['administer languages', 'access administration pages', 'administer news feeds', 'access news feeds', 'create article content']); + $this->drupalLogin($admin_user); + + // Enable translation for feeds. + $edit['entity_types[aggregator_feed]'] = TRUE; + $edit['settings[aggregator_feed][aggregator_feed][settings][language][language_alterable]'] = TRUE; + + $this->drupalPostForm('admin/config/regional/content-language', $edit, t('Save configuration')); + /** @var \Drupal\aggregator\FeedInterface[] $feeds */ $feeds = array(); // Create feeds. diff --git a/core/modules/content_translation/content_translation.admin.inc b/core/modules/content_translation/content_translation.admin.inc index b65eeea..0d6d496 100644 --- a/core/modules/content_translation/content_translation.admin.inc +++ b/core/modules/content_translation/content_translation.admin.inc @@ -87,11 +87,15 @@ function _content_translation_form_language_content_settings_form_alter(array &$ $entity_type = $entity_manager->getDefinition($entity_type_id); $storage_definitions = $entity_type instanceof ContentEntityTypeInterface ? $entity_manager->getFieldStorageDefinitions($entity_type_id) : array(); + $entity_type_translatable = $entity_type->isTranslatable(); foreach (entity_get_bundles($entity_type_id) as $bundle => $bundle_info) { // Here we do not want the widget to be altered and hold also the "Enable // translation" checkbox, which would be redundant. Hence we add this key // to be able to skip alterations. $form['settings'][$entity_type_id][$bundle]['settings']['language']['#content_translation_skip_alter'] = TRUE; + if (!$entity_type_translatable) { + continue; + } $fields = $entity_manager->getFieldDefinitions($entity_type_id, $bundle); if ($fields) { @@ -167,6 +171,7 @@ function _content_translation_preprocess_language_content_settings_table(&$varia } else { $translatable = array( + 'data' => t('N/A'), 'class' => array('untranslatable'), ); array_unshift($rows[$bundle]['data'], $translatable); diff --git a/core/modules/content_translation/src/Tests/ContentTranslationSettingsTest.php b/core/modules/content_translation/src/Tests/ContentTranslationSettingsTest.php index f5f3c89..1f09a21 100644 --- a/core/modules/content_translation/src/Tests/ContentTranslationSettingsTest.php +++ b/core/modules/content_translation/src/Tests/ContentTranslationSettingsTest.php @@ -257,6 +257,14 @@ function testFieldTranslatableSettingsUI() { } /** + * Tests the translatable settings checkbox for untranslatable entities. + */ + function testNonTranslatableTranslationSettingsUI() { + $this->drupalGet('admin/config/regional/content-language'); + $this->assertNoField('settings[entity_test][entity_test][translatable]'); + } + + /** * Returns the entity manager. * * @return \Drupal\Core\Entity\EntityManagerInterface diff --git a/core/modules/language/src/Form/ContentLanguageSettingsForm.php b/core/modules/language/src/Form/ContentLanguageSettingsForm.php index 13d15e9..fc53554 100644 --- a/core/modules/language/src/Form/ContentLanguageSettingsForm.php +++ b/core/modules/language/src/Form/ContentLanguageSettingsForm.php @@ -7,6 +7,7 @@ namespace Drupal\language\Form; +use Drupal\Core\Entity\ContentEntityTypeInterface; use Drupal\Core\Entity\EntityManagerInterface; use Drupal\Core\Form\FormBase; use Drupal\Core\Form\FormStateInterface; @@ -62,7 +63,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { $bundles = $this->entityManager->getAllBundleInfo(); $language_configuration = array(); foreach ($entity_types as $entity_type_id => $entity_type) { - if (!$entity_type->isTranslatable()) { + if (!$entity_type instanceof ContentEntityTypeInterface || !$entity_type->hasKey('langcode')) { continue; } $labels[$entity_type_id] = $entity_type->getLabel() ?: $entity_type_id;