Error message

  • Warning: count(): Parameter must be an array or an object that implements Countable in _api_make_match_member_link() (line 1230 of /home/projects/api/www/sites/all/modules/api/api.formatting.inc).
  • Warning: count(): Parameter must be an array or an object that implements Countable in _api_make_match_member_link() (line 1230 of /home/projects/api/www/sites/all/modules/api/api.formatting.inc).

function TestTranslator::requestTranslation

@abstract

Submits the translation request and sends it to the translation provider.

During the translation process, Job::getItems() will only return job items that are not already fully translated.

Parameters

\Drupal\tmgmt\JobInterface $job: The job that should be submitted.

Overrides TranslatorPluginInterface::requestTranslation

See also

hook_tmgmt_job_before_request_translation()

hook_tmgmt_job_after_request_translation()

File

tmgmt_test/src/Plugin/tmgmt/Translator/TestTranslator.php, line 62

Class

TestTranslator
Test source plugin implementation.

Namespace

Drupal\tmgmt_test\Plugin\tmgmt\Translator

Code

function requestTranslation(JobInterface $job) {

  // Add a debug message.
  $job
    ->addMessage('Test translator called.', array(), 'debug');

  // Do something different based on the action, if defined.
  $action = $job
    ->getSetting('action') ?: '';
  switch ($action) {
    case 'submit':
      $job
        ->submitted('Test submit.');
      break;
    case 'reject':
      $job
        ->rejected('This is not supported.');
      break;
    case 'fail':

      // Target not reachable.
      $job
        ->addMessage('Service not reachable.', array(), 'error');
      break;
    case 'translate':
    default:
      $job
        ->submitted('Test translation created.');
      $this
        ->requestJobItemsTranslation($job
        ->getItems());
      break;
  }
}