I have a multilingual site and I need to know which nodes are the translation of the current one; I use translation_node_get_translations(), but it seems it doesn't work.

I have 2 nodes (node/17 and node/670) where the latter is the translation of the former.

If I call translation_node_get_translations(17), I get an array with 2 elements referring to the nodes with ID equal to 17 and 670; if I call translation_node_get_translations(670), I get an empty array.

Is that a bug, or do I have to differently retry this information?


I found the solution: Calling translation_node_get_translations(), I have to provide the tnid (the node ID of the original node) as parameter, not nid, as nodes are translated by the node ID of the original node.

function _azzurra_get_translations_nids($node){
  $nodes = translation_node_get_translations($node->tnid);  

  $nids = array();
  foreach($nodes as $value){
    $nids[] = $value->nid;

  return $nids;

I wrote this function who return a list of all nids related to the argument node [included the nid of the argument node.. ]

  • Good to know and I missed it glancing on the docs. Have you by any chance found a way to get the whole list if I have one note from a set, but don't know / care if it's source one or not? That would make your answer full, as your question suggest you need it to work both ways, and not only explain why it does not. – Mołot Sep 26 '13 at 10:39
  • @Mołot That would be an interesting question. It is also different from this question, since this question is asking why translation_node_get_translations(670) returns an empty array. – kiamlaluno Sep 26 '13 at 12:23
  • @kiamlaluno in the question OP asks why it returns an empty array, AND "do I have to differently retry this information?". I didn't downvote this answer, as you can see nobody did, I also haven't flagged neither question nor answer. I still feel that question's intent is to retrieve this information, even if literal writing is "do I" and not "how to"... And first revision sounded even more that way to me than yours. – Mołot Sep 26 '13 at 12:28
  • 1
    @Mołot Fair enough. I will write an answer that includes code for getting the list of translations starting for a node ID which could be a tnid o not. This probably would make the question more helpful, since it isn't a question the documentation answers. – kiamlaluno Sep 26 '13 at 12:33
  • @kiamlaluno I thought I can do it on my own, but I fail to remember and don't have time to retry. If you remember how to do it, please share one day. – Mołot Sep 27 '13 at 23:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.