Check whether this service can handle a particular translation job.
TranslatorInterface $translator: The Translator entity that should handle the translation.
\Drupal\tmgmt\JobInterface $job: The Job entity that should be translated.
\Drupal\tmgmt\Translator\TranslatableResult The result of the translatable check.
Overrides TranslatorPluginInterface::checkTranslatable
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(),
)));
}