diff --git a/core/modules/contact/src/CategoryForm.php b/core/modules/contact/src/CategoryForm.php index 73fce38..7ebfb9d 100644 --- a/core/modules/contact/src/CategoryForm.php +++ b/core/modules/contact/src/CategoryForm.php @@ -66,6 +66,26 @@ public function form(array $form, array &$form_state) { '#default_value' => $default_category === $category->id(), ); + if ($this->moduleHandler->moduleExists('content_translation')) { + $form['language'] = array( + '#type' => 'details', + '#title' => t('Language settings'), + '#group' => 'additional_settings', + ); + + $language_configuration = language_get_default_configuration('contact_message', $category->id()); + $form['language']['language_configuration'] = array( + '#type' => 'language_configuration', + '#entity_information' => array( + 'entity_type' => 'contact_message', + 'bundle' => $category->id(), + ), + '#default_value' => $language_configuration, + ); + + $form['#submit'][] = 'language_configuration_element_submit'; + } + return $form; } diff --git a/core/modules/contact/src/Entity/Message.php b/core/modules/contact/src/Entity/Message.php index 2f5e140..218399a 100644 --- a/core/modules/contact/src/Entity/Message.php +++ b/core/modules/contact/src/Entity/Message.php @@ -23,12 +23,14 @@ * "view_builder" = "Drupal\contact\MessageViewBuilder", * "form" = { * "default" = "Drupal\contact\MessageForm" - * } + * }, + * "translation" = "Drupal\comment\CommentTranslationHandler" * }, * entity_keys = { * "bundle" = "category", * "uuid" = "uuid" * }, + * translatable = TRUE, * bundle_entity_type = "contact_category", * fieldable = TRUE, * links = { diff --git a/core/modules/contact/src/Tests/ContactMessageTranslationUITest.php b/core/modules/contact/src/Tests/ContactMessageTranslationUITest.php new file mode 100644 index 0000000..1f646db --- /dev/null +++ b/core/modules/contact/src/Tests/ContactMessageTranslationUITest.php @@ -0,0 +1,51 @@ +entityTypeId = 'contact_message'; + $this->bundle = 'feedback'; + $this->testLanguageSelector = FALSE; + $this->subject = $this->randomName(); + parent::setUp(); + } + + /** + * {@inheritdoc} + */ + protected function getTranslatorPermissions() { + return array_merge(parent::getTranslatorPermissions(), array( + 'access site-wide contact form', + 'administer contact forms', + )); + } + +}