You are here

function lingotek_get_paragraphs_item_source in Lingotek Translation 7.7

Loads a source language for a paragraphs_item

6 calls to lingotek_get_paragraphs_item_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 3185
Utility functions.

Code

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