1 translation.module translation_node_get_translations($tnid)

Gets all nodes in a given translation set.

Parameters

$tnid: The translation source nid of the translation set, the identifier of the node used to derive all translations in the set.

Return value

Array of partial node objects (nid, title, language) representing all: nodes in the translation set, in effect all translations of node $tnid, including node $tnid itself. Because these are partial nodes, you need to node_load() the full node, if you need more properties. The array is indexed by language code.

File

core/modules/translation/translation.module, line 534
Manages content translations.

Code

function translation_node_get_translations($tnid) {
  if (is_numeric($tnid) && $tnid) {
    $translations = &backdrop_static(__FUNCTION__, array());

    if (!isset($translations[$tnid])) {
      $translations[$tnid] = array();
      $result = db_select('node', 'n')
        ->fields('n', array('nid', 'type', 'uid', 'status', 'title', 'langcode'))
        ->condition('n.tnid', $tnid)
        ->addTag('node_access')
        ->execute();

      foreach ($result as $node) {
        $translations[$tnid][$node->langcode] = $node;
      }
    }
    return $translations[$tnid];
  }
}