コード例 #1
0
 /**
  * {@inheritdoc}
  */
 public function buildConfigurationForm(array $form, FormStateInterface $form_state)
 {
     $form = parent::buildConfigurationForm($form, $form_state);
     /** @var \Drupal\tmgmt\TranslatorInterface $test_translator */
     $test_translator = $form_state->getFormObject()->getEntity();
     $form['expose_settings'] = array('#type' => 'checkbox', '#title' => t('Display settings'), '#default_value' => $test_translator->getSetting('expose_settings'));
     $form['action'] = array('#type' => 'select', '#title' => t('Default action'), '#options' => array('translate' => t('Translate'), 'submit' => t('Submit'), 'reject' => t('Reject'), 'fail' => t('Fail'), 'not_available' => t('Not available'), 'not_translatable' => t('Not translatable')), '#default_value' => $test_translator->getSetting('action'));
     return $form;
 }
コード例 #2
0
 /**
  * {@inheritdoc}
  */
 public function validateConfigurationForm(array &$form, FormStateInterface $form_state)
 {
     parent::validateConfigurationForm($form, $form_state);
     /** @var \Drupal\tmgmt\TranslatorInterface $translator */
     $translator = $form_state->getFormObject()->getEntity();
     $supported_remote_languages = $translator->getPlugin()->getSupportedRemoteLanguages($translator);
     if (empty($supported_remote_languages)) {
         $form_state->setErrorByName('settings][api_key', t('The "Google API key" is not correct.'));
     }
 }
コード例 #3
0
 /**
  * {@inheritdoc}
  */
 public function checkoutInfo(JobInterface $job)
 {
     // If the job is finished, it's not possible to import translations anymore.
     if ($job->isFinished()) {
         return parent::checkoutInfo($job);
     }
     $form = array('#type' => 'fieldset', '#title' => t('Import translated file'));
     $supported_formats = array_keys(\Drupal::service('plugin.manager.tmgmt_file.format')->getDefinitions());
     $form['file'] = array('#type' => 'file', '#title' => t('File'), '#size' => 50, '#description' => t('Supported formats: @formats.', array('@formats' => implode(', ', $supported_formats))));
     $form['submit'] = array('#type' => 'submit', '#value' => t('Import'), '#submit' => array('tmgmt_file_import_form_submit'));
     return $this->checkoutInfoWrapper($job, $form);
 }