function webform_localization_field_attach_prepare_translation_alter in Webform Localization 7.4
Same name and namespace in other branches
- 7 webform_localization.module \webform_localization_field_attach_prepare_translation_alter()
Implements hook_field_attach_prepare_translation_alter().
File
- ./
webform_localization.module, line 845 - Webform localization module.
Code
function webform_localization_field_attach_prepare_translation_alter(&$entity, $context) {
if ($context['entity_type'] == 'node') {
if (isset($context['source_entity']->webform)) {
$webform_localization_options = webform_localization_get_config($context['source_entity']->nid);
// Copy all Webform settings over to translated versions of this node
// if the configuration match.
if ($webform_localization_options['sync_components']) {
if (!module_exists('translation')) {
// Enable the translation module as it is needed for localization sync.
module_enable('translation');
}
// NOTE:
// Perhaps could be interesting to copy only specific properties
// but for now the entire webform make more sense.
$entity->webform = $context['source_entity']->webform;
}
}
}
}