diff --git a/core/modules/content_translation/content_translation.module b/core/modules/content_translation/content_translation.module index bff3833..68c0a7e 100644 --- a/core/modules/content_translation/content_translation.module +++ b/core/modules/content_translation/content_translation.module @@ -513,6 +513,22 @@ function content_translation_form_alter(array &$form, array &$form_state) { if ($entity instanceof ContentEntityInterface && $entity->isTranslatable() && count($entity->getTranslationLanguages()) > 1) { $controller = content_translation_controller($entity->getEntityTypeId()); $controller->entityFormAlter($form, $form_state, $entity); + + // @todo Move the following lines to the code generating the property form + // elements once we have an official #multilingual FAPI key. + $translations = $entity->getTranslationLanguages(); + $form_langcode = $form_controller->getFormLangcode($form_state); + + // Handle fields shared between translations when there is at least one + // translation available or a new one is being created. + if (!$entity->isNew() && (!isset($translations[$form_langcode]) || count($translations) > 1)) { + foreach ($entity->getFieldDefinitions() as $property_name => $definition) { + if (isset($form[$property_name])) { + $form[$property_name]['#multilingual'] = $definition->isTranslatable(); + } + } + } + } } diff --git a/core/modules/content_translation/lib/Drupal/content_translation/ContentTranslationController.php b/core/modules/content_translation/lib/Drupal/content_translation/ContentTranslationController.php index 24047d0..ce4b4cc 100644 --- a/core/modules/content_translation/lib/Drupal/content_translation/ContentTranslationController.php +++ b/core/modules/content_translation/lib/Drupal/content_translation/ContentTranslationController.php @@ -276,33 +276,6 @@ public function entityFormAlter(array &$form, array &$form_state, EntityInterfac if (isset($form['actions']['delete'])) { $form['actions']['delete']['#submit'][] = array($this, 'entityFormDelete'); } - - // @todo Move the following lines to the code generating the property form - // elements once we have an official #multilingual FAPI key. - $status_translatable = NULL; - - // Handle fields shared between translations when there is at least one - // translation available or a new one is being created. - if (!$entity->isNew() && (!isset($translations[$form_langcode]) || count($translations) > 1)) { - foreach ($entity->getFieldDefinitions() as $property_name => $definition) { - if ($property_name == 'status') { - $status_translatable = $definition->isTranslatable(); - } - if (isset($form[$property_name])) { - $form[$property_name]['#multilingual'] = $definition->isTranslatable(); - } - } - // Change the submit button labels if there was a status field they affect - // in which case their publishing / unpublishing may or may not apply - // to all translations. - if (isset($status_translatable)) { - foreach (array('publish', 'unpublish', 'submit') as $button) { - if (isset($form['actions'][$button])) { - $form['actions'][$button]['#value'] .= ' ' . ($status_translatable ? t('(this translation)') : t('(all translations)')); - } - } - } - } } /** diff --git a/core/modules/node/lib/Drupal/node/NodeTranslationController.php b/core/modules/node/lib/Drupal/node/NodeTranslationController.php index e1c90d6..bb4d094 100644 --- a/core/modules/node/lib/Drupal/node/NodeTranslationController.php +++ b/core/modules/node/lib/Drupal/node/NodeTranslationController.php @@ -38,6 +38,28 @@ public function entityFormAlter(array &$form, array &$form_state, EntityInterfac $form['content_translation']['name']['#access'] = FALSE; $form['content_translation']['created']['#access'] = FALSE; } + + $form_controller = content_translation_form_controller($form_state); + $form_langcode = $form_controller->getFormLangcode($form_state); + $translations = $entity->getTranslationLanguages(); + $status_translatable = NULL; + // Change the submit button labels if there was a status field they affect + // in which case their publishing / unpublishing may or may not apply + // to all translations. + if (!$entity->isNew() && (!isset($translations[$form_langcode]) || count($translations) > 1)) { + foreach ($entity->getFieldDefinitions() as $property_name => $definition) { + if ($property_name == 'status') { + $status_translatable = $definition->isTranslatable(); + } + } + if (isset($status_translatable)) { + foreach (array('publish', 'unpublish', 'submit') as $button) { + if (isset($form['actions'][$button])) { + $form['actions'][$button]['#value'] .= ' ' . ($status_translatable ? t('(this translation)') : t('(all translations)')); + } + } + } + } } /** diff --git a/core/modules/search/lib/Drupal/search/Tests/SearchMultilingualEntityTest.php b/core/modules/search/lib/Drupal/search/Tests/SearchMultilingualEntityTest.php index 5ca86e3..90cc165 100644 --- a/core/modules/search/lib/Drupal/search/Tests/SearchMultilingualEntityTest.php +++ b/core/modules/search/lib/Drupal/search/Tests/SearchMultilingualEntityTest.php @@ -130,7 +130,8 @@ function testSearchingMultilingualFieldValues() { $plugin->setSearch('English OR Hungarian', array(), array()); $search_result = $plugin->execute(); $this->assertEqual(count($search_result), 2, 'Found two results.'); - + // Nodes are saved directly after each other and have the same created time + // so testing for the order is not possible. $results = array($search_result[0]['title'], $search_result[1]['title']); $this->assertTrue(in_array('Third node this is the Hungarian title', $results), 'The search finds the correct Hungarian title.'); $this->assertTrue(in_array('Second node this is the English title', $results), 'The search finds the correct English title.');