diff --git a/core/modules/translation_entity/translation_entity.module b/core/modules/translation_entity/translation_entity.module index 745434b..d7bd437 100644 --- a/core/modules/translation_entity/translation_entity.module +++ b/core/modules/translation_entity/translation_entity.module @@ -573,28 +573,59 @@ function translation_entity_field_extra_fields() { /** * Implements hook_form_FORM_ID_alter(). * - * Add a column to manage fields tab for a content type to show which fields are enabled for translation. + * Add a column to manage fields tab to show which fields are translatable. */ function translation_entity_form_field_ui_field_overview_form_alter(array &$form, array &$form_state, $form_id) { + $translatable = translation_entity_enabled($form['#entity_type'], $form['#bundle']); + + // Don't add the translation column of translation is not enabled at entity + // level. + if (!$translatable) { + return; + } + // Move out the operations. We need to have the translatable field in the // column before operations. $operations = array_pop($form['fields']['#header']); $form['fields']['#header'][] = t('Translatable'); $form['fields']['#header'][] = $operations; + $non_translatable_fields = $form['#extra']; + foreach (element_children($form['fields']) as $field => $value) { - if ($value != '_add_new_field') { - $field = field_info_field($value); + $field_row_type = $form['fields'][$value]['#row_type']; + + // Move out the operations. We need to have the translatable field in + // the column before operations. + unset($operations_data); + if (isset($form['fields'][$value]['operations'])) { + $operations_data = array_pop($form['fields'][$value]); + } + + if ($field_row_type == 'field') { + // Only field types are translatable. + $markup_text = $form['fields'][$value] ? t('Yes') . '' . t('Translatable') . '' : '' . t('Not translatable') . ''; - // Move out the operations. We need to have the translatable field in the - // column before operations. - $operations_data = array_pop($form['fields'][$value]); $form['fields'][$value]['translatable'] = array( 'label' => array( - '#markup' => $field['translatable'] ? t('Yes') : '', + '#markup' => $markup_text, )); + } + else { + $markup_text = t('n/a') . '' . t('Translation not supported') . ''; + // Filter out add new and reuse fields. + if (!isset($form['fields'][$value]['field_name']['#type'])) { + $form['fields'][$value]['translatable'] = array( + 'label' => array( + '#markup' => $markup_text, + )); + } + } + + if (isset($operations_data)) { $form['fields'][$value][] = $operations_data; } + } return $form; }