You are here

public function LingotekEntity::setLanguage in Lingotek Translation 7.6

Same name and namespace in other branches
  1. 7.7 lib/Drupal/lingotek/LingotekEntity.php \LingotekEntity::setLanguage()

Set the entity's language to be used by Lingotek, which will sometimes be different from the stated Drupal language.

1 call to LingotekEntity::setLanguage()
LingotekEntity::__construct in lib/Drupal/lingotek/LingotekEntity.php
Constructor.

File

lib/Drupal/lingotek/LingotekEntity.php, line 411
Defines LingotekEntity.

Class

LingotekEntity
A class wrapper for Lingotek-specific behavior on nodes.

Code

public function setLanguage($language = NULL) {
  if (empty($language)) {
    $drupal_locale = Lingotek::convertDrupal2Lingotek($this->entity->language);
    if (!empty($this->entity->lingotek['allow_source_overwriting']) && !empty($this->entity->lingotek['source_language_' . $drupal_locale])) {
      $language = $this->entity->lingotek['source_language_' . $drupal_locale];
    }
    else {
      $language = $this->entity->language;
    }
  }
  $this->language = $language;
  $this->locale = Lingotek::convertDrupal2Lingotek($this->language);
  $this->language_targets = Lingotek::getLanguagesWithoutSource($this->locale);
}