You are here

public function TMGMTDefaultTranslatorPluginController::canTranslate in Translation Management Tool 7

Check whether this service can handle a particular translation job.

Parameters

TMGMTTranslator $translator: The TMGMTTranslator entity that should handle the translation.

TMGMTJob $job: The TMGMTJob entity that should be translated.

Return value

boolean TRUE if the job can be processed and translated, FALSE otherwise.

Overrides TMGMTTranslatorPluginControllerInterface::canTranslate

1 call to TMGMTDefaultTranslatorPluginController::canTranslate()
TMGMTTestTranslatorPluginController::canTranslate in tests/tmgmt_test.plugin.translator.inc
Check whether this service can handle a particular translation job.
2 methods override TMGMTDefaultTranslatorPluginController::canTranslate()
TMGMTFileTranslatorPluginController::canTranslate in translators/file/tmgmt_file.plugin.inc
Check whether this service can handle a particular translation job.
TMGMTTestTranslatorPluginController::canTranslate in tests/tmgmt_test.plugin.translator.inc
Check whether this service can handle a particular translation job.

File

plugin/tmgmt.plugin.translator.inc, line 43
Contains the abstract translator base plugin class.

Class

TMGMTDefaultTranslatorPluginController
Default controller class for service plugins.

Code

public function canTranslate(TMGMTTranslator $translator, TMGMTJob $job) {

  // The job is only translatable if the translator is available too.
  if ($this
    ->isAvailable($translator) && array_key_exists($job->target_language, $translator
    ->getSupportedTargetLanguages($job->source_language))) {

    // We can only translate this job if the target language of the job is in
    // one of the supported languages.
    return TRUE;
  }
  return FALSE;
}