public function TranslatorPluginBase::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 TranslatorPluginInterface::checkTranslatable
1 call to TranslatorPluginBase::checkTranslatable()
- TestTranslator::checkTranslatable in tmgmt_test/
src/ Plugin/ tmgmt/ Translator/ TestTranslator.php - Check whether this service can handle a particular translation job.
2 methods override TranslatorPluginBase::checkTranslatable()
- FileTranslator::checkTranslatable in translators/
tmgmt_file/ src/ Plugin/ tmgmt/ Translator/ FileTranslator.php - Check whether this service can handle a particular translation job.
- TestTranslator::checkTranslatable in tmgmt_test/
src/ Plugin/ tmgmt/ Translator/ TestTranslator.php - Check whether this service can handle a particular translation job.
File
- src/
TranslatorPluginBase.php, line 41
Class
- TranslatorPluginBase
- Default controller class for service plugins.
Namespace
Drupal\tmgmtCode
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(),
)));
}