getSourceLangcode($form_state)) { $entity = $form_state->getFormObject()->getEntity(); // We need a redirect here, otherwise we would get an access denied page, // since the current URL would be preserved and we would try to add a // translation for a language that already has a translation. $form_state->setRedirectUrl($entity->toUrl('edit-form')); } } /** * {@inheritdoc} */ public function entityFormEntityBuild($entity_type, EntityInterface $entity, array $form, FormStateInterface $form_state) { if ($form_state->hasValue('content_translation')) { $translation = &$form_state->getValue('content_translation'); $translation['status'] = $entity->isPublished(); } parent::entityFormEntityBuild($entity_type, $entity, $form, $form_state); } }