We are upgrading our site from D7 to D8 and a part of this includes sending data out to another resource, specifically, Nodes. When we send data to the 3rd party resource, it's expecting something like

    "drupalId": 1,
    "title": "English Node",
    "tnid": 1
    "drupalId": 2,
    "title": "Translated Node",
    "tnid": 1


This allows the 3rd party resource to store 2 separate nodes and then links them together using the tnid, and in this 3rd party resource, the Drupal Id is suppose to be unique. However, in D8, it appears that a node and it's translation has the same Drupal Node Id and there does not exist a 'tnid' value, like it was in D7. I assume this is just the change in how translations work in Drupal 8 now, which brings me to my issue:

What can I use as a unique identifier between a node and its translation now?

In D7, the Node Id was a unique identifier and the tnid was a "link" between a node and its translation. In D8, the Node Id is the "link" between a node and its translation, but what could I use to distinguish a Node from its Translation?

  • It depends a little bit what for and how exactly you are using the translation in the end. But nowadays you only need to have a $node and then can get its translation depending on the currently selected interface language as easy as $node = \Drupal::service('entity.repository')->getTranslationFromContext($node); and can continue from there. – leymannx Jan 7 at 17:51
  • I mainly just need a way to upload a node and it's translation to the third party such that 1) there is a unique identifier that distinguishes a Node and its translation (nid in D7) and 2) there is a shared identifier that "links" a node to its translation (tnid in D7) – BlondeSwan Jan 7 at 17:58
  • In Drupal 8 this is just a langcode, and the node ID. Like drupal.stackexchange.com/a/203570/15055. You could just foreach through all available langcodes, too. – leymannx Jan 7 at 18:00
  • I'll check that out, thanks! – BlondeSwan Jan 7 at 18:03

Your Answer

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

Browse other questions tagged or ask your own question.