You are here

function i18n_sync_node_translation_reference_field in Internationalization 7

Helper function to which translates reference field. We try to use translations for reference, otherwise fallback. Example: English A references English B and English C. English A and B are translated to German A and B, but English C is not. The synchronization from English A to German A would it German B and English C.

2 calls to i18n_sync_node_translation_reference_field()
i18n_sync_node_translation_attached_node in i18n_sync/i18n_sync.node.inc
Node attachments (CCK) that may have translation.
i18n_sync_node_translation_nodereference_field in i18n_sync/i18n_sync.node.inc
Translating a nodereference field (cck).

File

i18n_sync/i18n_sync.node.inc, line 103
Internationalization (i18n) package. Synchronization of translations

Code

function i18n_sync_node_translation_reference_field(&$reference_node, $default_value, $langcode) {
  if (isset($reference_node->tnid) && translation_supported_type($reference_node->type)) {

    // This content type has translations, find the one.
    if (($reference_trans = translation_node_get_translations($reference_node->tnid)) && isset($reference_trans[$langcode])) {
      return $reference_trans[$langcode]->nid;
    }
    else {

      // No requested language found, just copy the field.
      return $default_value;
    }
  }
  else {

    // Content type without language, just copy the field.
    return $default_value;
  }
}