Esempio n. 1
0
 /**
  * {@inheritdoc}
  */
 public function checkoutSettingsForm(array $form, FormStateInterface $form_state, JobInterface $job)
 {
     if ($translators = tmgmt_local_assignees($job->getSourceLangcode(), array($job->getTargetLangcode()))) {
         $form['translator'] = array('#title' => t('Assign job to'), '#type' => 'select', '#options' => array('' => t('- Select user -')) + $translators, '#default_value' => $job->getSetting('translator'));
     } else {
         $form['message'] = array('#markup' => t('There are no users available to assign.'));
     }
     $form['job_comment'] = array('#type' => 'textarea', '#title' => t('Comment for the translation'), '#description' => t('You can provide a comment so that the assigned user will better understand your requirements.'), '#default_value' => $job->getSetting('job_comment'));
     return $form;
 }
 /**
  * {@inheritdoc}
  */
 public function checkTranslatable(TranslatorInterface $translator, JobInterface $job)
 {
     // The job is only translatable if the translator is available too.
     if ($this->checkAvailable($translator)->getSuccess() && array_key_exists($job->getTargetLangcode(), $translator->getSupportedTargetLanguages($job->getSourceLangcode()))) {
         // We can only translate this job if the target language of the job is in
         // one of the supported languages.
         return TranslatableResult::yes();
     }
     return TranslatableResult::no(t('@translator can not translate from @source to @target.', array('@translator' => $translator->label(), '@source' => $job->getSourceLanguage()->getName(), '@target' => $job->getTargetLanguage()->getName())));
 }
Esempio n. 3
0
 /**
  * {@inheritdoc}
  */
 public function requestTranslation(JobInterface $job)
 {
     $name = "JobID" . $job->id() . '_' . $job->getSourceLangcode() . '_' . $job->getTargetLangcode();
     $export = \Drupal::service('plugin.manager.tmgmt_file.format')->createInstance($job->getSetting('export_format'));
     $path = $job->getSetting('scheme') . '://tmgmt_file/' . $name . '.' . $job->getSetting('export_format');
     $dirname = dirname($path);
     if (file_prepare_directory($dirname, FILE_CREATE_DIRECTORY)) {
         $file = file_save_data($export->export($job), $path);
         \Drupal::service('file.usage')->add($file, 'tmgmt_file', 'tmgmt_job', $job->id());
         $job->submitted('Exported file can be downloaded <a href="@link">here</a>.', array('@link' => file_create_url($path)));
     }
 }