You are here

protected function GoogleTranslator::googleRequestTranslation in TMGMT Translator Google 8

Helper method to do translation request.

Parameters

Job $job: TMGMT Job to be used for translation.

array|string $q: Text/texts to be translated.

Return value

array Userialized JSON containing translated texts.

1 call to GoogleTranslator::googleRequestTranslation()
GoogleTranslator::requestJobItemsTranslation in src/Plugin/tmgmt/Translator/GoogleTranslator.php
Requests the translation of a JobItem.

File

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

Class

GoogleTranslator
Google translator plugin.

Namespace

Drupal\tmgmt_google\Plugin\tmgmt\Translator

Code

protected function googleRequestTranslation(Job $job, $q) {
  $translator = $job
    ->getTranslator();
  return $this
    ->doRequest($translator, 'translate', array(
    'source' => $job
      ->getRemoteSourceLanguage(),
    'target' => $job
      ->getRemoteTargetLanguage(),
    $this->qParamName => $q,
  ), array(
    'headers' => array(
      'Content-Type' => 'text/plain',
    ),
  ));
}