Implements hook_form_FORM_ID_alter() for 'field_ui_field_edit_form'.
function translation_entity_form_field_ui_field_edit_form_alter(array &$form, array &$form_state, $form_id) {
$field = $form['#field'];
$field_name = $field['field_name'];
$translatable = $field['translatable'];
$label = t('Field translation');
if (field_has_data($field)) {
$form['field']['translatable'] = array(
'#type' => 'item',
'#title' => $label,
'#attributes' => array(
'class' => 'translatable',
),
'link' => array(
'#type' => 'link',
'#prefix' => t('This field has data in existing content.') . ' ',
'#title' => !$translatable ? t('Enable translation') : t('Disable translation'),
'#href' => 'admin/config/regional/translation_entity/translatable/' . $field_name,
'#options' => array(
'query' => drupal_get_destination(),
),
'#access' => user_access('administer entity translation'),
),
);
}
else {
$form['field']['translatable'] = array(
'#type' => 'checkbox',
'#title' => t('Users may translate this field.'),
'#default_value' => $translatable,
);
}
$form['field']['translatable']['#weight'] = 20;
}