/** * {@inheritdoc} */ protected function getFormSubmitSuffix(EntityInterface $entity, $langcode) { if (!$entity->isNew() && $entity->isTranslatable()) { $translations = $entity->getTranslationLanguages(); if ((count($translations) > 1 || !isset($translations[$langcode])) && ($field = $entity->getFieldDefinition('status'))) { return ' ' . ($field->isTranslatable() ? t('(this translation)') : t('(all translations)')); } } return ''; }
/** * Initializes the translation form state. * * @param \Drupal\Core\Form\FormStateInterface $form_state * @param \Drupal\Core\Entity\EntityInterface $host */ protected function initIsTranslating(FormStateInterface $form_state, EntityInterface $host) { if ($this->isTranslating != NULL) { return; } $this->isTranslating = FALSE; if (!$host->isTranslatable()) { return; } if (!$host->getEntityType()->hasKey('default_langcode')) { return; } $default_langcode_key = $host->getEntityType()->getKey('default_langcode'); if (!$host->hasField($default_langcode_key)) { return; } if (!empty($form_state->get('content_translation'))) { // Adding a language through the ContentTranslationController. $this->isTranslating = TRUE; } if ($host->hasTranslation($form_state->get('langcode')) && $host->getTranslation($form_state->get('langcode'))->get($default_langcode_key)->value == 0) { // Editing a translation. $this->isTranslating = TRUE; } }