You are here

public function LingotekApi::removeTranslationTarget in Lingotek Translation 7.2

Same name and namespace in other branches
  1. 7.7 lib/Drupal/lingotek/LingotekApi.php \LingotekApi::removeTranslationTarget()
  2. 7.3 lib/Drupal/lingotek/LingotekApi.php \LingotekApi::removeTranslationTarget()
  3. 7.4 lib/Drupal/lingotek/LingotekApi.php \LingotekApi::removeTranslationTarget()
  4. 7.5 lib/Drupal/lingotek/LingotekApi.php \LingotekApi::removeTranslationTarget()
  5. 7.6 lib/Drupal/lingotek/LingotekApi.php \LingotekApi::removeTranslationTarget()

Removes a target language to an existing Lingotek Document or Project.

Parameters

int $lingotek_document_id: The document to which the new translation target should be added. Or null if the target will be added to the project.

int $lingotek_project_id: The project to which the new translation target should be added. Or null if the target will be added to a document instead.

string $lingotek_locale: The two letter code representing the language which should be added as a translation target.

string $workflow_id: The optional workflow to associate with this target. If omitted, the project's default workflow will be applied.

Return value

bool TRUE on success, or FALSE on error.

File

lib/Drupal/lingotek/LingotekApi.php, line 275
Defines Drupal\lingotek\LingotekApi

Class

LingotekApi
@file Defines Drupal\lingotek\LingotekApi

Code

public function removeTranslationTarget($lingotek_document_id, $lingotek_project_id, $lingotek_locale, $workflow_id = '') {
  $parameters = array(
    'applyWorkflow' => 'true',
    // Ensure that as translation targets are added, the associated project's Workflow template is applied.
    'targetLanguage' => $lingotek_locale,
  );
  if (isset($lingotek_document_id) && !isset($lingotek_project_id)) {
    $parameters['documentId'] = $lingotek_document_id;
  }
  else {
    if (isset($lingotek_project_id) && !isset($lingotek_document_id)) {
      $parameters['projectId'] = $lingotek_project_id;
    }
  }
  if ($workflow_id) {
    $parameters['workflowId'] = $workflow_id;
  }
  if ($old_translation_target = $this
    ->request('removeTranslationTarget', $parameters)) {
    return $old_translation_target->results == 'success' ? TRUE : FALSE;
  }
  else {
    return FALSE;
  }
}