You are here

function i18nsync_node_translation_reference_field in Internationalization 6

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 syncronization from English A to German A would it German B and English C.

2 calls to i18nsync_node_translation_reference_field()
i18nsync_node_translation_attached_node in i18nsync/i18nsync.module
Node attachments (CCK) that may have translation.
i18nsync_node_translation_nodereference_field in i18nsync/i18nsync.module
Translating a nodereference field (cck).

File

i18nsync/i18nsync.module, line 417
Internationalization (i18n) package. Synchronization of translations

Code

function i18nsync_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;
  }
}