You are here

public function GoogleTranslator::checkTranslatable in TMGMT Translator Google 8

Overrides TMGMTDefaultTranslatorPluginController::checkTranslatable().

Overrides TranslatorPluginBase::checkTranslatable

File

src/Plugin/tmgmt/Translator/GoogleTranslator.php, line 127
Contains \Drupal\tmgmt_microsoft\Plugin\tmgmt\Translator\MicrosoftTranslator.

Class

GoogleTranslator
Google translator plugin.

Namespace

Drupal\tmgmt_google\Plugin\tmgmt\Translator

Code

public function checkTranslatable(TranslatorInterface $translator, JobInterface $job) {
  foreach (\Drupal::service('tmgmt.data')
    ->filterTranslatable($job
    ->getData()) as $value) {

    // If one of the texts in this job exceeds the max character count
    // the job can't be translated.
    if (mb_strlen($value['#text']) > $this->maxCharacters) {
      return TranslatableResult::no(t('The length of the job exceeds tha max character count (@count).', [
        '@count' => $this->maxCharacters,
      ]));
    }
  }
  return parent::checkTranslatable($translator, $job);
}