You are here

protected function TMGMTGoogleTranslatorPluginController::googleRequestTranslation in TMGMT Translator Google 7

Helper method to do translation request.

Parameters

TMGMTJob $job:

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

Return value

array Userialized JSON containing translated texts.

1 call to TMGMTGoogleTranslatorPluginController::googleRequestTranslation()
TMGMTGoogleTranslatorPluginController::requestTranslation in ./tmgmt_google.plugin.inc
Implements TMGMTTranslatorPluginControllerInterface::requestTranslation().

File

./tmgmt_google.plugin.inc, line 140
Provides Google Translator plugin controller.

Class

TMGMTGoogleTranslatorPluginController
Google translator plugin controller.

Code

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