You are here

public function LingotekConfigTranslationService::getSourceLocale in Lingotek Translation 3.4.x

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

Gets the translation source locale of a given entity.

Parameters

\Drupal\Core\Config\Entity\ConfigEntityInterface $entity: The entity which we want to get the source locale.

Return value

string The locale as expected by the Lingotek service.

Overrides LingotekConfigTranslationServiceInterface::getSourceLocale

3 calls to LingotekConfigTranslationService::getSourceLocale()
LingotekConfigTranslationService::setJobId in src/LingotekConfigTranslationService.php
Sets the job ID of a given entity.
LingotekConfigTranslationService::updateDocument in src/LingotekConfigTranslationService.php
Resends a document to the translation service.
LingotekConfigTranslationService::uploadDocument in src/LingotekConfigTranslationService.php
Uploads a document to the Lingotek service.

File

src/LingotekConfigTranslationService.php, line 345

Class

LingotekConfigTranslationService
Service for managing Lingotek configuration translations.

Namespace

Drupal\lingotek

Code

public function getSourceLocale(ConfigEntityInterface &$entity) {
  $locale = NULL;
  $source_language = $entity
    ->language()
    ->getId();
  if (!in_array($source_language, [
    LanguageInterface::LANGCODE_NOT_SPECIFIED,
    LanguageInterface::LANGCODE_NOT_APPLICABLE,
  ])) {
    $locale = $this->languageLocaleMapper
      ->getLocaleForLangcode($source_language);
  }
  return $locale;
}