function translation_entity_load_translation_metadata

Loads translation data into the given entities.

Parameters

array $entities: The entities keyed by entity ID.

string $entity_type: The type of the entities.

1 call to translation_entity_load_translation_metadata()
translation_entity_entity_load in drupal/core/modules/translation_entity/translation_entity.module
Implements hook_entity_load().

File

drupal/core/modules/translation_entity/translation_entity.module, line 699
Allows entities to be translated into different languages.

Code

function translation_entity_load_translation_metadata(array $entities, $entity_type) {
  $query = 'SELECT * FROM {translation_entity} te WHERE te.entity_type = :entity_type AND te.entity_id IN (:entity_id)';
  $result = db_query($query, array(
    ':entity_type' => $entity_type,
    ':entity_id' => array_keys($entities),
  ));
  $exclude = array(
    'entity_type',
    'entity_id',
    'langcode',
  );
  foreach ($result as $record) {
    $entity = $entities[$record->entity_id];

    // @todo Declare these as entity (translation?) properties.
    foreach ($record as $field_name => $value) {
      if (!in_array($field_name, $exclude)) {
        $entity->translation[$record->langcode][$field_name] = $value;
      }
    }
  }
}