You are here

function i18nsync_node_translation_attached_node in Internationalization 5

Same name and namespace in other branches
  1. 5.3 experimental/i18nsync.module \i18nsync_node_translation_attached_node()
  2. 5.2 experimental/i18nsync.module \i18nsync_node_translation_attached_node()
  3. 6 i18nsync/i18nsync.module \i18nsync_node_translation_attached_node()

Node attachments that may have translation

1 call to i18nsync_node_translation_attached_node()
i18nsync_node_translation in experimental/i18nsync.module

File

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

Code

function i18nsync_node_translation_attached_node(&$node, &$translation, $field) {
  if (isset($node->{$field}) && ($attached = node_load($node->{$field}))) {
    if (variable_get("i18n_node_{$attached->type}", 0)) {

      // This content type has translations, find the one
      if ($attached->translations && isset($attached->translation[$translation->language])) {
        $translation->{$field} = $attached->translation[$translation->language]->nid;
      }
    }
    else {

      // Content type without language, just copy the nid
      $translation->{$field} = $node->{$field};
    }
  }
}