You are here

public function LingotekInterfaceTranslationService::cancelDocumentTarget in Lingotek Translation 3.2.x

Same name and namespace in other branches
  1. 4.0.x src/LingotekInterfaceTranslationService.php \Drupal\lingotek\LingotekInterfaceTranslationService::cancelDocumentTarget()
  2. 3.3.x src/LingotekInterfaceTranslationService.php \Drupal\lingotek\LingotekInterfaceTranslationService::cancelDocumentTarget()
  3. 3.4.x src/LingotekInterfaceTranslationService.php \Drupal\lingotek\LingotekInterfaceTranslationService::cancelDocumentTarget()
  4. 3.5.x src/LingotekInterfaceTranslationService.php \Drupal\lingotek\LingotekInterfaceTranslationService::cancelDocumentTarget()
  5. 3.6.x src/LingotekInterfaceTranslationService.php \Drupal\lingotek\LingotekInterfaceTranslationService::cancelDocumentTarget()
  6. 3.7.x src/LingotekInterfaceTranslationService.php \Drupal\lingotek\LingotekInterfaceTranslationService::cancelDocumentTarget()
  7. 3.8.x src/LingotekInterfaceTranslationService.php \Drupal\lingotek\LingotekInterfaceTranslationService::cancelDocumentTarget()

Cancels a translation for a given component in the given locale.

Parameters

string $component: The component which target we want to cancel.

string $locale: Lingotek translation language which we want to modify.

Overrides LingotekInterfaceTranslationServiceInterface::cancelDocumentTarget

File

src/LingotekInterfaceTranslationService.php, line 801

Class

LingotekInterfaceTranslationService
Service for managing Lingotek interface translations.

Namespace

Drupal\lingotek

Code

public function cancelDocumentTarget($component, $locale) {
  $source_langcode = 'en';
  $source_locale = $this->languageLocaleMapper
    ->getLocaleForLangcode($source_langcode);
  if ($locale == $source_locale) {

    // This is not a target, but the source language itself.
    return FALSE;
  }
  if ($document_id = $this
    ->getDocumentId($component)) {
    $drupal_language = $this->languageLocaleMapper
      ->getConfigurableLanguageForLocale($locale);
    if ($this->lingotek
      ->cancelDocumentTarget($document_id, $locale)) {
      $this
        ->setTargetStatus($component, $drupal_language
        ->id(), Lingotek::STATUS_CANCELLED);
      return TRUE;
    }
  }
  return FALSE;
}