You are here

function lingotek_get_file_source in Lingotek Translation 7.7

Loads a source language for a file entity

6 calls to lingotek_get_file_source()
LingotekEntity::getSourceLocale in lib/Drupal/lingotek/LingotekEntity.php
LingotekEntity::setLanguage in lib/Drupal/lingotek/LingotekEntity.php
Set the entity's language to be used by Lingotek, which will sometimes be different from the stated Drupal language.
lingotek_entity_langcode in ./lingotek.util.inc
lingotek_entity_load_single in ./lingotek.module
lingotek_entity_xml_body in ./lingotek.util.inc
Return the xml representation of the source content for an entity.

... See full list

File

./lingotek.util.inc, line 3211
Utility functions.

Code

function lingotek_get_file_source($entity_id) {
  if (!module_exists('entity_translation')) {
    if (variable_get('lingotek_translate_files', FALSE)) {
      drupal_set_message(t('The Entity Translation module is required for translation of File Entity module types.'), 'warning', FALSE);
    }
    return language_default()->language;
  }
  $source = db_select('entity_translation', 'et')
    ->fields('et', array(
    'language',
  ))
    ->condition('entity_type', 'file')
    ->condition('entity_id', $entity_id)
    ->condition('source', '')
    ->execute()
    ->fetchField();
  if (!$source) {
    return language_default()->language;
  }
  return $source;
}