diff --git a/core/lib/Drupal/Core/Entity/EntityManager.php b/core/lib/Drupal/Core/Entity/EntityManager.php index 685c35e..0b4372e 100644 --- a/core/lib/Drupal/Core/Entity/EntityManager.php +++ b/core/lib/Drupal/Core/Entity/EntityManager.php @@ -43,6 +43,8 @@ * multiple entity forms when the forms are similar. Defaults to * Drupal\Core\Entity\EntityFormController. * - label: The human-readable name of the type. + * - bundle_label: The human-readable name of the entity bundles, e.g. + * Vocabulary. * - label_callback: (optional) A function taking an entity and optional * langcode argument, and returning the label of the entity. If langcode is * omitted, the entity's default language is used. @@ -106,7 +108,6 @@ * Elements: * - bundle: The name of the property that contains the name of the bundle * object. - * - label: The human-readable name of the entity bundles, e.g. Vocabulary. * - bundles: An array describing all bundles for this object type. Keys are * bundle machine names, as found in the objects' 'bundle' property * (defined in the 'entity_keys' entry for the entity type in the diff --git a/core/modules/comment/lib/Drupal/comment/Plugin/Core/Entity/Comment.php b/core/modules/comment/lib/Drupal/comment/Plugin/Core/Entity/Comment.php index 4e5cb50..96b436e 100644 --- a/core/modules/comment/lib/Drupal/comment/Plugin/Core/Entity/Comment.php +++ b/core/modules/comment/lib/Drupal/comment/Plugin/Core/Entity/Comment.php @@ -18,6 +18,7 @@ * @Plugin( * id = "comment", * label = @Translation("Comment"), + * bundle_label = @Translation("Content type"), * module = "comment", * controller_class = "Drupal\comment\CommentStorageController", * render_controller_class = "Drupal\comment\CommentRenderController", @@ -35,9 +36,6 @@ * "label" = "subject", * "uuid" = "uuid" * }, - * bundle_keys = { - * "label" = "Content type" - * }, * view_modes = { * "full" = { * "label" = "Full comment", diff --git a/core/modules/node/lib/Drupal/node/Plugin/Core/Entity/Node.php b/core/modules/node/lib/Drupal/node/Plugin/Core/Entity/Node.php index a7b7ff0..2aef56c 100644 --- a/core/modules/node/lib/Drupal/node/Plugin/Core/Entity/Node.php +++ b/core/modules/node/lib/Drupal/node/Plugin/Core/Entity/Node.php @@ -18,6 +18,7 @@ * @Plugin( * id = "node", * label = @Translation("Node"), + * bundle_label = @Translation("Content type"), * module = "node", * controller_class = "Drupal\node\NodeStorageController", * render_controller_class = "Drupal\node\NodeRenderController", @@ -37,8 +38,7 @@ * "uuid" = "uuid" * }, * bundle_keys = { - * "bundle" = "type", - * "label" = "Content type" + * "bundle" = "type" * }, * view_modes = { * "full" = { diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/Core/Entity/Term.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/Core/Entity/Term.php index c5932b0..e129e87 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/Core/Entity/Term.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/Core/Entity/Term.php @@ -18,6 +18,7 @@ * @Plugin( * id = "taxonomy_term", * label = @Translation("Taxonomy term"), + * bundle_label = @Translation("Vocabulary"), * module = "taxonomy", * controller_class = "Drupal\taxonomy\TermStorageController", * render_controller_class = "Drupal\taxonomy\TermRenderController", @@ -35,8 +36,7 @@ * "uuid" = "uuid" * }, * bundle_keys = { - * "bundle" = "machine_name", - * "label" = "Vocabulary" + * "bundle" = "machine_name" * }, * view_modes = { * "full" = { diff --git a/core/modules/translation_entity/lib/Drupal/translation_entity/Tests/EntityTranslationSettingsTest.php b/core/modules/translation_entity/lib/Drupal/translation_entity/Tests/EntityTranslationSettingsTest.php index 6f19cf1..3dbae43 100644 --- a/core/modules/translation_entity/lib/Drupal/translation_entity/Tests/EntityTranslationSettingsTest.php +++ b/core/modules/translation_entity/lib/Drupal/translation_entity/Tests/EntityTranslationSettingsTest.php @@ -19,7 +19,7 @@ class EntityTranslationSettingsTest extends WebTestBase { * * @var array */ - public static $modules = array('language', 'translation_entity'); + public static $modules = array('language', 'translation_entity', 'comment'); public static function getInfo() { return array( @@ -33,8 +33,12 @@ public static function getInfo() { * Overrides \Drupal\simpletest\WebTestBase::setUp(). */ function setUp() { - $this->profile = 'standard'; parent::setUp(); + + // Setup two content types to test instances shared among different bundles. + $this->drupalCreateContentType(array('type' => 'article')); + $this->drupalCreateContentType(array('type' => 'page')); + $admin_user = $this->drupalCreateUser(array('administer entity translation')); $this->drupalLogin($admin_user); } diff --git a/core/modules/translation_entity/translation_entity.admin.css b/core/modules/translation_entity/translation_entity.admin.css index c3bf85e..db1df56 100644 --- a/core/modules/translation_entity/translation_entity.admin.css +++ b/core/modules/translation_entity/translation_entity.admin.css @@ -4,17 +4,17 @@ */ .translation-entity-admin-settings-form table .bundle { - width: 25% + width: 25%; } .translation-entity-admin-settings-form table .field { - width: 25% + width: 25%; } .translation-entity-admin-settings-form table .translatable { - width: 10% + width: 10%; } .translation-entity-admin-settings-form table .operations { - width: 40% + width: 40%; } diff --git a/core/modules/translation_entity/translation_entity.admin.inc b/core/modules/translation_entity/translation_entity.admin.inc index 72866f5..ccca415 100644 --- a/core/modules/translation_entity/translation_entity.admin.inc +++ b/core/modules/translation_entity/translation_entity.admin.inc @@ -27,16 +27,20 @@ function translation_entity_admin_settings_form(array $form, array $form_state, $default[$entity_type] = translation_entity_enabled($entity_type) ? $entity_type : FALSE; } + $path = drupal_get_path('module', 'translation_entity'); + $form = array( + '#attached' => array( + 'css' => array($path . '/translation_entity.admin.css'), + 'js' => array($path . '/translation_entity.admin.js'), + ), + ); + $translatable = t('Translatable'); $form['entity_types'] = array( '#title' => $translatable, '#type' => 'checkboxes', '#options' => $labels, '#default_value' => $default, - '#attached' => array( - 'css' => array(drupal_get_path('module', 'translation_entity') . '/translation_entity.admin.css'), - 'js' => array(drupal_get_path('module', 'translation_entity') . '/translation_entity.admin.js'), - ), ); $form['settings'] = array('#tree' => TRUE); @@ -78,7 +82,10 @@ function translation_entity_admin_settings_form(array $form, array $form_state, 'bundle' => $bundle, ), '#default_value' => $language_configuration, - '#translation_entity_skip' => TRUE, + // Here we do not want the widget to be altered and hold also the + // "Enable translation" checkbox, which would be redundant. Hence we + // add this key to be able to skip alterations. + '#translation_entity_skip_alter' => TRUE, ), ); @@ -128,8 +135,8 @@ function translation_entity_admin_settings_form_submit(array $form, array &$form $entity_types = $form_state['values']['entity_types']; $settings = &$form_state['values']['settings']; - // If an entity type is non translatable all its bundles and fields must be - // marked as non translatable. Similarly if a bundle is made non translatable + // If an entity type is not translatable all its bundles and fields must be + // marked as not translatable. Similarly, if a bundle is made non translatable // all of its fields will be non translatable. foreach ($settings as $entity_type => &$entity_settings) { foreach ($entity_settings as $bundle => &$bundle_settings) { @@ -175,7 +182,7 @@ function theme_translation_entity_admin_settings_table(array $variables) { ); foreach ($field_names as $field_name) { - $field = $element[$bundle]['fields'][$field_name]; + $field = &$element[$bundle]['fields'][$field_name]; $rows[] = array( 'data' => array( array('data' => '', 'class' => array('bundle')), @@ -188,13 +195,9 @@ function theme_translation_entity_admin_settings_table(array $variables) { } } - $element['#children'] = theme('table', array('header' => $header, 'rows' => $rows)); - - // We now need to render the parent element to ensure states are properly - // processed. - unset($element['#theme']); - unset($element['#theme_wrappers']); - return drupal_render($element); + $output = theme('table', array('header' => $header, 'rows' => $rows)); + $output .= drupal_render_children($element); + return $output; } /** diff --git a/core/modules/translation_entity/translation_entity.install b/core/modules/translation_entity/translation_entity.install index e66e544..abaaaaa 100644 --- a/core/modules/translation_entity/translation_entity.install +++ b/core/modules/translation_entity/translation_entity.install @@ -66,7 +66,8 @@ function translation_entity_install() { function translation_entity_enable() { $t_args = array( '!language_url' => url('admin/config/regional/language'), + '!settings_url' => url('admin/config/regional/translation_entity'), ); - $message = t('You just added content translation capabilities to your site. To exploit them be sure to enable at least two languages and enable translation for content types, taxonomy vocabularies, accounts and any other element whose content you wish to translate.', $t_args); + $message = t('You just added content translation capabilities to your site. To exploit them be sure to enable at least two languages and enable translation for content types, taxonomy vocabularies, accounts and any other element whose content you wish to translate.', $t_args); drupal_set_message($message, 'warning'); } diff --git a/core/modules/translation_entity/translation_entity.module b/core/modules/translation_entity/translation_entity.module index 7fd7e75..0efc21d 100644 --- a/core/modules/translation_entity/translation_entity.module +++ b/core/modules/translation_entity/translation_entity.module @@ -41,7 +41,7 @@ function translation_entity_help($path, $arg) { return $output; case 'admin/config/regional/translation_entity': - return '

' . t('Setup your translation settings for all the different types on your website, this allows you to enable/disable and configure it at once. Newly created content types, vocabularies, etc will be added here.') . '

'; + return '

' . t('Setup your content translation settings for all the translatable elements on your website. This allows you to enable/disable and configure them at once. As soon as new content types, vocabularies and other translatable elements are available, you will be able to configure them here.') . '

'; } } @@ -629,7 +629,7 @@ function translation_entity_form_field_ui_field_edit_form_alter(array &$form, ar '#title' => $link_title, '#href' => $path, '#options' => array('query' => drupal_get_destination()), - '#access' => user_access('toggle field translatability'), + '#access' => user_access('administer entity translation'), ), ); } @@ -689,7 +689,7 @@ function translation_entity_enable_widget($entity_type, $bundle, array &$form, a * Processed language configuration element. */ function translation_entity_language_configuration_element_process(array $element, array &$form_state, array &$form) { - if (empty($element['#translation_entity_skip'])) { + if (empty($element['#translation_entity_skip_alter'])) { $form_state['translation_entity']['key'] = $element['#name']; $context = $form_state['language'][$element['#name']]; @@ -799,7 +799,7 @@ function translation_entity_save_settings($settings) { /** * Implemements hook_theme(). */ -function translation_entity_theme($existing, $type, $theme, $path) { +function translation_entity_theme() { return array( 'translation_entity_admin_settings_table' => array( 'render element' => 'element',