You are here

function TestTranslator::checkTranslatable in Translation Management Tool 8

Check whether this service can handle a particular translation job.

Parameters

TranslatorInterface $translator: The Translator entity that should handle the translation.

\Drupal\tmgmt\JobInterface $job: The Job entity that should be translated.

Return value

\Drupal\tmgmt\Translator\TranslatableResult The result of the translatable check.

Overrides TranslatorPluginBase::checkTranslatable

File

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

Class

TestTranslator
Test source plugin implementation.

Namespace

Drupal\tmgmt_test\Plugin\tmgmt\Translator

Code

function checkTranslatable(TranslatorInterface $translator, JobInterface $job) {
  if ($job
    ->getSetting('action') == 'not_translatable') {
    return TranslatableResult::no(t('@translator can not translate from @source to @target.', array(
      '@translator' => $job
        ->getTranslator()
        ->label(),
      '@source' => $job
        ->getSourceLanguage()
        ->getName(),
      '@target' => $job
        ->getTargetLanguage()
        ->getName(),
    )));
  }
  return parent::checkTranslatable($translator, $job);
}