You are here

public function LingotekApi::deleteTranslation in Lingotek Translation 3.4.x

Same name and namespace in other branches
  1. 8 src/Remote/LingotekApi.php \Drupal\lingotek\Remote\LingotekApi::deleteTranslation()
  2. 8.2 src/Remote/LingotekApi.php \Drupal\lingotek\Remote\LingotekApi::deleteTranslation()
  3. 4.0.x src/Remote/LingotekApi.php \Drupal\lingotek\Remote\LingotekApi::deleteTranslation()
  4. 3.0.x src/Remote/LingotekApi.php \Drupal\lingotek\Remote\LingotekApi::deleteTranslation()
  5. 3.1.x src/Remote/LingotekApi.php \Drupal\lingotek\Remote\LingotekApi::deleteTranslation()
  6. 3.2.x src/Remote/LingotekApi.php \Drupal\lingotek\Remote\LingotekApi::deleteTranslation()
  7. 3.3.x src/Remote/LingotekApi.php \Drupal\lingotek\Remote\LingotekApi::deleteTranslation()
  8. 3.5.x src/Remote/LingotekApi.php \Drupal\lingotek\Remote\LingotekApi::deleteTranslation()
  9. 3.6.x src/Remote/LingotekApi.php \Drupal\lingotek\Remote\LingotekApi::deleteTranslation()
  10. 3.7.x src/Remote/LingotekApi.php \Drupal\lingotek\Remote\LingotekApi::deleteTranslation()
  11. 3.8.x src/Remote/LingotekApi.php \Drupal\lingotek\Remote\LingotekApi::deleteTranslation()

Deletes a document target translation for a given locale from the Lingotek service.

Parameters

string $id: The document id.

string $locale: The target locale.

Return value

\Psr\Http\Message\ResponseInterface A response.

Overrides LingotekApiInterface::deleteTranslation

File

src/Remote/LingotekApi.php, line 312

Class

LingotekApi
A simple connector to the Lingotek Translation API.

Namespace

Drupal\lingotek\Remote

Code

public function deleteTranslation($id, $locale) {
  try {
    $this->logger
      ->debug('Lingotek::deleteTranslation called with id ' . $id . ' and locale ' . $locale);
    $response = $this->lingotekClient
      ->delete('/api/document/' . $id . '/translation', [
      'locale_code' => $locale,
    ]);
  } catch (\Exception $e) {
    $this->logger
      ->error('Error getting translation (%id, %locale): %message.', [
      '%id' => $id,
      '%locale' => $locale,
      '%message' => $e
        ->getMessage(),
    ]);
    throw new LingotekApiException('Failed to add translation: ' . $e
      ->getMessage());
  }
  $this->logger
    ->debug('deleteTranslation response received, code %code and body %body', [
    '%code' => $response
      ->getStatusCode(),
    '%body' => (string) $response
      ->getBody(TRUE),
  ]);
  return $response;
}