Index: modules/translation/translation.module =================================================================== RCS file: /cvs/drupal/drupal/modules/translation/translation.module,v retrieving revision 1.38 diff -u -p -r1.38 translation.module --- modules/translation/translation.module 22 Jan 2009 03:11:54 -0000 1.38 +++ modules/translation/translation.module 30 Jan 2009 15:07:23 -0000 @@ -26,6 +26,58 @@ define('TRANSLATION_ENABLED', 2); /** + * Implementation of hook_fieldable_info(). + */ +function translation_fieldable_info() { + $return = array( + 'translation set' => array( + 'name' => t('Node translation set'), + 'id key' => 'tnid', + 'revision key' => 'vid', + 'bundle key' => 'type', + // Node.module handles its own caching. + // 'cacheable' => FALSE, + // Bundles must provide human readable name so + // we can create help and error messages about them. + 'bundles' => node_get_types('names'), + ), + ); + return $return; +} + +/** + * Implementation of hook_nodeapi_load(). + * + * Allow translation sets to share fields. + */ +function translation_nodeapi_load($nodes, $types) { + + // Build an array of unique translation IDs for this group of nodes. + $tnids = array(); + foreach ($nodes as $node) { + if ($node->tnid) { + $tnids[$tnid] = $node->tnid; + } + } + + // Create an array of empty 'translation set' objects to pass to + // field_attach_load(). + $translation_sets = array(); + foreach ($tnids as $tnid) { + $translation_sets[$tnid] = new stdClass(); + } + field_attach_load('translation_set', $translation_sets); + + // Now populate the nodes with the values added to the translation set. + foreach ($nodes as $node) { + $values = $translation_sets[$node->tnid]; + foreach ($values as $key => $value) { + $node->$key = $value; + } + } +} + +/** * Implementation of hook_help(). */ function translation_help($path, $arg) {