You are here

public function LingotekEntity::getSourceLocale in Lingotek Translation 7.7

Same name and namespace in other branches
  1. 7.5 lib/Drupal/lingotek/LingotekEntity.php \LingotekEntity::getSourceLocale()
  2. 7.6 lib/Drupal/lingotek/LingotekEntity.php \LingotekEntity::getSourceLocale()

Overrides LingotekTranslatableEntity::getSourceLocale

File

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

Class

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

Code

public function getSourceLocale() {
  if ($this->entity_type == 'taxonomy_term') {
    $vocabulary = taxonomy_vocabulary_machine_name_load($this->vocabulary_machine_name);

    // If vocab uses 'Localize', change language from undefined to English.
    if ($vocabulary->i18n_mode == LINGOTEK_TAXONOMY_LOCALIZE_VALUE) {
      return 'en_US';
    }
  }
  if ($this->entity_type == 'bean') {
    $bean_language = lingotek_get_bean_source($this->entity->bid);
    return Lingotek::convertDrupal2Lingotek($bean_language);
  }
  if ($this->entity_type == 'group') {
    $group_language = lingotek_get_group_source($this->entity->gid);
    return Lingotek::convertDrupal2Lingotek($group_language);
  }
  if ($this->entity_type == 'paragraphs_item') {
    $paragraphs_language = lingotek_get_paragraphs_item_source($this->entity->item_id);
    return Lingotek::convertDrupal2Lingotek($paragraphs_language);
  }
  if ($this->entity_type == 'file') {
    $file_language = lingotek_get_file_source($this->entity->fid);
    return Lingotek::convertDrupal2Lingotek($file_language);
  }
  return Lingotek::convertDrupal2Lingotek($this->language);
}