function i18nsync_node_translation_filefield_field in Internationalization 6
Translating an filefield (cck).
1 call to i18nsync_node_translation_filefield_field()
- i18nsync_node_translation in i18nsync/
i18nsync.module - Synchronizes fields for node translation.
File
- i18nsync/
i18nsync.module, line 387 - Internationalization (i18n) package. Synchronization of translations
Code
function i18nsync_node_translation_filefield_field(&$node, &$translation, $field) {
if (is_array($node->{$field})) {
$translated_images = array();
foreach ($node->{$field} as $file) {
$found = false;
// Try to find existing translations of the filefield items and reference them.
foreach ($translation->{$field} as $translation_image) {
if ($file['fid'] == $translation_image['fid']) {
$translated_images[] = $translation_image;
$found = true;
}
}
// If there was no translation found for the filefield item, just copy it.
if (!$found) {
$translated_images[] = $file;
}
}
$translation->{$field} = $translated_images;
}
}