diff --git a/core/lib/Drupal/Core/Entity/Annotation/EntityType.php b/core/lib/Drupal/Core/Entity/Annotation/EntityType.php index beaa4e3..b8e4061 100644 --- a/core/lib/Drupal/Core/Entity/Annotation/EntityType.php +++ b/core/lib/Drupal/Core/Entity/Annotation/EntityType.php @@ -63,7 +63,7 @@ class EntityType extends Plugin { * Defaults to \Drupal\Core\Entity\EntityAccessController. * - translation: The name of the controller class that should be used to * handle the translation process. The class must implement - * \Drupal\translation_entity\EntityTranslationControllerInterface. + * \Drupal\content_translation\ContentTranslationControllerInterface. * * @todo Interfaces from outside \Drupal\Core or \Drupal\Component should not * be used here. @@ -148,7 +148,7 @@ class EntityType extends Plugin { public $translatable = FALSE; /** - * @todo translation_entity_entity_info_alter() uses this but it is undocumented. + * @todo content_translation_entity_info_alter() uses this but it is undocumented. * * @var array */ diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockTranslationController.php b/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockTranslationController.php index a8848c7..851ac69 100644 --- a/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockTranslationController.php +++ b/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockTranslationController.php @@ -8,22 +8,22 @@ namespace Drupal\custom_block; use Drupal\Core\Entity\EntityInterface; -use Drupal\translation_entity\EntityTranslationControllerNG; +use Drupal\content_translation\ContentTranslationControllerNG; /** * Defines the translation controller class for custom blocks. */ -class CustomBlockTranslationController extends EntityTranslationControllerNG { +class CustomBlockTranslationController extends ContentTranslationControllerNG { /** - * Overrides EntityTranslationController::getAccess(). + * Overrides ContentTranslationController::getAccess(). */ public function getAccess(EntityInterface $entity, $op) { return user_access('administer blocks'); } /** - * Overrides EntityTranslationController::entityFormAlter(). + * Overrides ContentTranslationController::entityFormAlter(). */ public function entityFormAlter(array &$form, array &$form_state, EntityInterface $entity) { parent::entityFormAlter($form, $form_state, $entity); @@ -40,7 +40,7 @@ public function entityFormAlter(array &$form, array &$form_state, EntityInterfac } /** - * Overrides EntityTranslationController::entityFormTitle(). + * Overrides ContentTranslationController::entityFormTitle(). */ protected function entityFormTitle(EntityInterface $entity) { $block_type = entity_load('custom_block_type', $entity->type->value); diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockTypeFormController.php b/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockTypeFormController.php index 6e5de33..cf88f5d 100644 --- a/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockTypeFormController.php +++ b/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockTypeFormController.php @@ -52,7 +52,7 @@ public function form(array $form, array &$form_state) { '#description' => t('Create a new revision by default for this block type.') ); - if (module_exists('translation_entity')) { + if (module_exists('content_translation')) { $form['language'] = array( '#type' => 'details', '#title' => t('Language settings'), diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockTranslationUITest.php b/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockTranslationUITest.php index 3ccac91..dbb9aba 100644 --- a/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockTranslationUITest.php +++ b/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockTranslationUITest.php @@ -7,13 +7,13 @@ namespace Drupal\custom_block\Tests; -use Drupal\translation_entity\Tests\EntityTranslationUITest; +use Drupal\content_translation\Tests\ContentTranslationUITest; use Drupal\custom_block\Plugin\Core\Entity\CustomBlock; /** * Tests the Custom Block Translation UI. */ -class CustomBlockTranslationUITest extends EntityTranslationUITest { +class CustomBlockTranslationUITest extends ContentTranslationUITest { /** * The name of the test block. @@ -27,7 +27,7 @@ class CustomBlockTranslationUITest extends EntityTranslationUITest { */ public static $modules = array( 'language', - 'translation_entity', + 'content_translation', 'block', 'field_ui', 'custom_block' @@ -56,7 +56,7 @@ public function setUp() { } /** - * Overrides \Drupal\translation_entity\Tests\EntityTranslationUITest::getTranslatorPermission(). + * Overrides \Drupal\content_translation\Tests\ContentTranslationUITest::getTranslatorPermission(). */ public function getTranslatorPermissions() { return array_merge(parent::getTranslatorPermissions(), array( @@ -93,7 +93,7 @@ protected function createCustomBlock($title = FALSE, $bundle = FALSE) { } /** - * Overrides \Drupal\translation_entity\Tests\EntityTranslationUITest::getNewEntityValues(). + * Overrides \Drupal\content_translation\Tests\ContentTranslationUITest::getNewEntityValues(). */ protected function getNewEntityValues($langcode) { return array('info' => $this->name) + parent::getNewEntityValues($langcode); @@ -117,8 +117,8 @@ public function testDisabledBundle() { $disabled_custom_block = $this->createCustomBlock(FALSE, $bundle->id()); // Make sure that only a single row was inserted into the - // {translation_entity} table. - $rows = db_query('SELECT * FROM {translation_entity}')->fetchAll(); + // {content_translation} table. + $rows = db_query('SELECT * FROM {content_translation}')->fetchAll(); $this->assertEqual(1, count($rows)); $this->assertEqual($enabled_custom_block->id(), reset($rows)->entity_id); } diff --git a/core/modules/comment/comment.admin.inc b/core/modules/comment/comment.admin.inc index 2bff10b..1ca6a52 100644 --- a/core/modules/comment/comment.admin.inc +++ b/core/modules/comment/comment.admin.inc @@ -139,7 +139,7 @@ function comment_admin_overview($form, &$form_state, $arg) { 'href' => 'comment/' . $comment->id() . '/edit', 'query' => $destination, ); - if (module_invoke('translation_entity', 'translate_access', $comment)) { + if (module_invoke('content_translation', 'translate_access', $comment)) { $links['translate'] = array( 'title' => t('translate'), 'href' => 'comment/' . $comment->id() . '/translations', diff --git a/core/modules/comment/comment.module b/core/modules/comment/comment.module index 7285c8e..2466ce7 100644 --- a/core/modules/comment/comment.module +++ b/core/modules/comment/comment.module @@ -954,7 +954,7 @@ function comment_links(Comment $comment, EntityInterface $node) { } // Add translations link for translation-enabled comment bundles. - if (module_exists('translation_entity') && translation_entity_translate_access($comment)) { + if (module_exists('content_translation') && content_translation_translate_access($comment)) { $links['comment-translations'] = array( 'title' => t('translate'), 'href' => 'comment/' . $comment->id() . '/translations', @@ -1059,10 +1059,10 @@ function comment_form_node_type_form_alter(&$form, $form_state) { ), ); // @todo Remove this check once language settings are generalized. - if (module_exists('translation_entity')) { + if (module_exists('content_translation')) { $comment_form = $form; - $comment_form_state['translation_entity']['key'] = 'language_configuration'; - $form['comment'] += translation_entity_enable_widget('comment', 'comment_node_' . $form['#node_type']->type, $comment_form, $comment_form_state); + $comment_form_state['content_translation']['key'] = 'language_configuration'; + $form['comment'] += content_translation_enable_widget('comment', 'comment_node_' . $form['#node_type']->type, $comment_form, $comment_form_state); array_unshift($form['#submit'], 'comment_translation_configuration_element_submit'); } } @@ -1083,11 +1083,11 @@ function comment_translation_configuration_element_submit($form, &$form_state) { // settings. $key = 'language_configuration'; $comment_form_state = array( - 'translation_entity' => array('key' => $key), + 'content_translation' => array('key' => $key), 'language' => array($key => array('entity_type' => 'comment', 'bundle' => 'comment_node_' . $form['#node_type']->type)), - 'values' => array($key => array('translation_entity' => $form_state['values']['translation_entity'])), + 'values' => array($key => array('content_translation' => $form_state['values']['content_translation'])), ); - translation_entity_language_configuration_element_submit($form, $comment_form_state); + content_translation_language_configuration_element_submit($form, $comment_form_state); } /** diff --git a/core/modules/comment/comment.views.inc b/core/modules/comment/comment.views.inc index 7783334..66e2083 100644 --- a/core/modules/comment/comment.views.inc +++ b/core/modules/comment/comment.views.inc @@ -360,12 +360,12 @@ function comment_views_data() { ), ); - if (Drupal::moduleHandler()->moduleExists('translation_entity')) { + if (Drupal::moduleHandler()->moduleExists('content_translation')) { $data['comment']['translation_link'] = array( 'title' => t('Translation link'), 'help' => t('Provide a link to the translations overview for comments.'), 'field' => array( - 'id' => 'translation_entity_link', + 'id' => 'content_translation_link', ), ); } diff --git a/core/modules/comment/lib/Drupal/comment/CommentTranslationController.php b/core/modules/comment/lib/Drupal/comment/CommentTranslationController.php index 656af99..df70b15 100644 --- a/core/modules/comment/lib/Drupal/comment/CommentTranslationController.php +++ b/core/modules/comment/lib/Drupal/comment/CommentTranslationController.php @@ -9,15 +9,15 @@ namespace Drupal\comment; use Drupal\Core\Entity\EntityInterface; -use Drupal\translation_entity\EntityTranslationControllerNG; +use Drupal\content_translation\ContentTranslationControllerNG; /** * Defines the translation controller class for comments. */ -class CommentTranslationController extends EntityTranslationControllerNG { +class CommentTranslationController extends ContentTranslationControllerNG { /** - * Overrides EntityTranslationController::entityFormTitle(). + * Overrides ContentTranslationController::entityFormTitle(). */ protected function entityFormTitle(EntityInterface $entity) { return t('Edit comment @subject', array('@subject' => $entity->label())); diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentTranslationUITest.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentTranslationUITest.php index 2a14791..49d6814 100644 --- a/core/modules/comment/lib/Drupal/comment/Tests/CommentTranslationUITest.php +++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentTranslationUITest.php @@ -7,12 +7,12 @@ namespace Drupal\comment\Tests; -use Drupal\translation_entity\Tests\EntityTranslationUITest; +use Drupal\content_translation\Tests\ContentTranslationUITest; /** * Tests the Comment Translation UI. */ -class CommentTranslationUITest extends EntityTranslationUITest { +class CommentTranslationUITest extends ContentTranslationUITest { /** * The subject of the test comment. @@ -24,7 +24,7 @@ class CommentTranslationUITest extends EntityTranslationUITest { * * @var array */ - public static $modules = array('language', 'translation_entity', 'node', 'comment'); + public static $modules = array('language', 'content_translation', 'node', 'comment'); public static function getInfo() { return array( @@ -44,7 +44,7 @@ function setUp() { } /** - * Overrides \Drupal\translation_entity\Tests\EntityTranslationUITest::setupBundle(). + * Overrides \Drupal\content_translation\Tests\ContentTranslationUITest::setupBundle(). */ function setupBundle() { parent::setupBundle(); @@ -52,14 +52,14 @@ function setupBundle() { } /** - * Overrides \Drupal\translation_entity\Tests\EntityTranslationUITest::getTranslatorPermission(). + * Overrides \Drupal\content_translation\Tests\ContentTranslationUITest::getTranslatorPermission(). */ protected function getTranslatorPermissions() { return array_merge(parent::getTranslatorPermissions(), array('post comments', 'administer comments')); } /** - * Overrides \Drupal\translation_entity\Tests\EntityTranslationUITest::setupTestFields(). + * Overrides \Drupal\content_translation\Tests\ContentTranslationUITest::setupTestFields(). */ function setupTestFields() { parent::setupTestFields(); @@ -69,7 +69,7 @@ function setupTestFields() { } /** - * Overrides \Drupal\translation_entity\Tests\EntityTranslationUITest::createEntity(). + * Overrides \Drupal\content_translation\Tests\ContentTranslationUITest::createEntity(). */ protected function createEntity($values, $langcode, $node_bundle = NULL) { if (!isset($node_bundle)) { @@ -82,7 +82,7 @@ protected function createEntity($values, $langcode, $node_bundle = NULL) { } /** - * Overrides \Drupal\translation_entity\Tests\EntityTranslationUITest::getNewEntityValues(). + * Overrides \Drupal\content_translation\Tests\ContentTranslationUITest::getNewEntityValues(). */ protected function getNewEntityValues($langcode) { // Comment subject is not translatable hence we use a fixed value. @@ -93,7 +93,7 @@ protected function getNewEntityValues($langcode) { } /** - * Overrides \Drupal\translation_entity\Tests\EntityTranslationUITest::assertPublishedStatus(). + * Overrides \Drupal\content_translation\Tests\ContentTranslationUITest::assertPublishedStatus(). */ protected function assertPublishedStatus() { parent::assertPublishedStatus(); diff --git a/core/modules/translation_entity/translation_entity.admin.inc b/core/modules/content_translation/content_translation.admin.inc similarity index 84% rename from core/modules/translation_entity/translation_entity.admin.inc rename to core/modules/content_translation/content_translation.admin.inc index 26dec07..9755c86 100644 --- a/core/modules/translation_entity/translation_entity.admin.inc +++ b/core/modules/content_translation/content_translation.admin.inc @@ -2,7 +2,7 @@ /** * @file - * The entity translation administration forms. + * The content translation administration forms. */ use Drupal\Core\Entity\EntityInterface; @@ -21,7 +21,7 @@ * @return array * A form element to configure field synchronization. */ -function translation_entity_field_sync_widget(Field $field, FieldInstance $instance) { +function content_translation_field_sync_widget(Field $field, FieldInstance $instance) { $element = array(); if (!empty($field['settings']['column_groups']) && count($field['settings']['column_groups']) > 1) { @@ -42,10 +42,10 @@ function translation_entity_field_sync_widget(Field $field, FieldInstance $insta '#default_value' => !empty($instance['settings']['translation_sync']) ? $instance['settings']['translation_sync'] : $default, '#attached' => array( 'library' => array( - array('translation_entity', 'drupal.translation_entity.admin'), + array('content_translation', 'drupal.content_translation.admin'), ), 'js' => array( - array('data' => array('translationEntityDependentOptions' => $settings), 'type' => 'setting'), + array('data' => array('contentTranslationDependentOptions' => $settings), 'type' => 'setting'), ), ), ); @@ -57,21 +57,21 @@ function translation_entity_field_sync_widget(Field $field, FieldInstance $insta /** * (proxied) Implements hook_form_FORM_ID_alter(). */ -function _translation_entity_form_language_content_settings_form_alter(array &$form, array &$form_state) { +function _content_translation_form_language_content_settings_form_alter(array &$form, array &$form_state) { // Inject into the content language settings the translation settings if the // user has the required permission. - if (!user_access('administer entity translation')) { + if (!user_access('administer content translation')) { return; } $default = $form['entity_types']['#default_value']; foreach ($default as $entity_type => $enabled) { - $default[$entity_type] = $enabled || translation_entity_enabled($entity_type) ? $entity_type : FALSE; + $default[$entity_type] = $enabled || content_translation_enabled($entity_type) ? $entity_type : FALSE; } $form['entity_types']['#default_value'] = $default; - $form['#attached']['library'][] = array('translation_entity', 'drupal.translation_entity.admin'); - $form['#attached']['js'][] = array('data' => drupal_get_path('module', 'translation_entity') . '/translation_entity.admin.js', 'type' => 'file'); + $form['#attached']['library'][] = array('content_translation', 'drupal.content_translation.admin'); + $form['#attached']['js'][] = array('data' => drupal_get_path('module', 'content_translation') . '/content_translation.admin.js', 'type' => 'file'); $dependent_options_settings = array(); foreach ($form['#labels'] as $entity_type => $label) { @@ -80,7 +80,7 @@ function _translation_entity_form_language_content_settings_form_alter(array &$f // 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. - $form['settings'][$entity_type][$bundle]['settings']['language']['#translation_entity_skip_alter'] = TRUE; + $form['settings'][$entity_type][$bundle]['settings']['language']['#content_translation_skip_alter'] = TRUE; // Only show the checkbox to enable translation if the bundles in the // entity might have fields and if there are fields to translate. @@ -89,7 +89,7 @@ function _translation_entity_form_language_content_settings_form_alter(array &$f if ($fields) { $form['settings'][$entity_type][$bundle]['translatable'] = array( '#type' => 'checkbox', - '#default_value' => translation_entity_enabled($entity_type, $bundle), + '#default_value' => content_translation_enabled($entity_type, $bundle), ); // @todo Exploit field definitions once all core entities and field @@ -101,7 +101,7 @@ function _translation_entity_form_language_content_settings_form_alter(array &$f '#type' => 'checkbox', '#default_value' => $field['translatable'], ); - $column_element = translation_entity_field_sync_widget($field, $instance); + $column_element = content_translation_field_sync_widget($field, $instance); if ($column_element) { $form['settings'][$entity_type][$bundle]['columns'][$field_name] = $column_element; @@ -115,18 +115,18 @@ function _translation_entity_form_language_content_settings_form_alter(array &$f } } $settings = array('dependent_selectors' => $dependent_options_settings); - $form['#attached']['js'][] = array('data' => array('translationEntityDependentOptions' => $settings), 'type' => 'setting'); - $form['#validate'][] = 'translation_entity_form_language_content_settings_validate'; - $form['#submit'][] = 'translation_entity_form_language_content_settings_submit'; + $form['#attached']['js'][] = array('data' => array('contentTranslationDependentOptions' => $settings), 'type' => 'setting'); + $form['#validate'][] = 'content_translation_form_language_content_settings_validate'; + $form['#submit'][] = 'content_translation_form_language_content_settings_submit'; } /** * (proxied) Implements hook_preprocess_HOOK(); */ -function _translation_entity_preprocess_language_content_settings_table(&$variables) { +function _content_translation_preprocess_language_content_settings_table(&$variables) { // Alter the 'build' variable injecting the translation settings if the user // has the required permission. - if (!user_access('administer entity translation')) { + if (!user_access('administer content translation')) { return; } @@ -237,11 +237,11 @@ function _translation_entity_preprocess_language_content_settings_table(&$variab } /** - * Form validation handler for translation_entity_admin_settings_form(). + * Form validation handler for content_translation_admin_settings_form(). * - * @see translation_entity_admin_settings_form_submit() + * @see content_translation_admin_settings_form_submit() */ -function translation_entity_form_language_content_settings_validate(array $form, array &$form_state) { +function content_translation_form_language_content_settings_validate(array $form, array &$form_state) { $settings = &$form_state['values']['settings']; foreach ($settings as $entity_type => $entity_settings) { foreach ($entity_settings as $bundle => $bundle_settings) { @@ -267,11 +267,11 @@ function translation_entity_form_language_content_settings_validate(array $form, } /** - * Form submission handler for translation_entity_admin_settings_form(). + * Form submission handler for content_translation_admin_settings_form(). * - * @see translation_entity_admin_settings_form_validate() + * @see content_translation_admin_settings_form_validate() */ -function translation_entity_form_language_content_settings_submit(array $form, array &$form_state) { +function content_translation_form_language_content_settings_submit(array $form, array &$form_state) { $entity_types = $form_state['values']['entity_types']; $settings = &$form_state['values']['settings']; @@ -296,12 +296,12 @@ function translation_entity_form_language_content_settings_submit(array $form, a } } - _translation_entity_update_field_translatability($settings); + _content_translation_update_field_translatability($settings); drupal_set_message(t('Settings successfully updated.')); } /** - * Stores entity translation settings. + * Stores content translation settings. * * @param array $settings * An associative array of settings keyed by entity type and bundle. At bundle @@ -315,7 +315,7 @@ function translation_entity_form_language_content_settings_submit(array $form, a * @todo Remove this migration entirely once the Field API is converted to the * Entity Field API. */ -function _translation_entity_update_field_translatability($settings) { +function _content_translation_update_field_translatability($settings) { $fields = array(); foreach ($settings as $entity_type => $entity_settings) { foreach ($entity_settings as $bundle => $bundle_settings) { @@ -344,10 +344,10 @@ function _translation_entity_update_field_translatability($settings) { // data back to Language::LANGCODE_NOT_SPECIFIED before making a field // untranslatable lest we lose information. $field_operations = array( - array('translation_entity_translatable_switch', array($translatable, $field_name)), + array('content_translation_translatable_switch', array($translatable, $field_name)), ); if ($field->hasData()) { - $field_operations[] = array('translation_entity_translatable_batch', array($translatable, $field_name)); + $field_operations[] = array('content_translation_translatable_batch', array($translatable, $field_name)); $field_operations = $translatable ? $field_operations : array_reverse($field_operations); } $operations = array_merge($operations, $field_operations); @@ -355,13 +355,13 @@ function _translation_entity_update_field_translatability($settings) { } // As last operation store the submitted settings. - $operations[] = array('translation_entity_save_settings', array($settings)); + $operations[] = array('content_translation_save_settings', array($settings)); $batch = array( 'title' => t('Updating translatability for the selected fields'), 'operations' => $operations, - 'finished' => 'translation_entity_translatable_batch_done', - 'file' => drupal_get_path('module', 'translation_entity') . '/translation_entity.admin.inc', + 'finished' => 'content_translation_translatable_batch_done', + 'file' => drupal_get_path('module', 'content_translation') . '/content_translation.admin.inc', ); batch_set($batch); } @@ -369,7 +369,7 @@ function _translation_entity_update_field_translatability($settings) { /** * Form constructor for the confirmation of translatability switching. */ -function translation_entity_translatable_form(array $form, array &$form_state, $field_name) { +function content_translation_translatable_form(array $form, array &$form_state, $field_name) { $field = field_info_field($field_name); $t_args = array('%name' => $field_name); @@ -396,7 +396,7 @@ function translation_entity_translatable_form(array $form, array &$form_state, $ } /** - * Form submission handler for translation_entity_translatable_form(). + * Form submission handler for content_translation_translatable_form(). * * This submit handler maintains consistency between the translatability of an * entity and the language under which the field data is stored. When a field is @@ -407,7 +407,7 @@ function translation_entity_translatable_form(array $form, array &$form_state, $ * untranslatable will cause all of its translations to be permanently removed, * with the exception of the one corresponding to the entity language. */ -function translation_entity_translatable_form_submit(array $form, array $form_state) { +function content_translation_translatable_form_submit(array $form, array $form_state) { // This is the current state that we want to reverse. $translatable = $form_state['values']['translatable']; $field_name = $form_state['field']['field_name']; @@ -429,8 +429,8 @@ function translation_entity_translatable_form_submit(array $form, array $form_st // to Language::LANGCODE_NOT_SPECIFIED before making a field untranslatable lest we lose // information. $operations = array( - array('translation_entity_translatable_batch', array(!$translatable, $field_name)), - array('translation_entity_translatable_switch', array(!$translatable, $field_name)), + array('content_translation_translatable_batch', array(!$translatable, $field_name)), + array('content_translation_translatable_switch', array(!$translatable, $field_name)), ); $operations = $translatable ? $operations : array_reverse($operations); @@ -440,8 +440,8 @@ function translation_entity_translatable_form_submit(array $form, array $form_st $batch = array( 'title' => $title, 'operations' => $operations, - 'finished' => 'translation_entity_translatable_batch_done', - 'file' => drupal_get_path('module', 'translation_entity') . '/translation_entity.admin.inc', + 'finished' => 'content_translation_translatable_batch_done', + 'file' => drupal_get_path('module', 'content_translation') . '/content_translation.admin.inc', ); batch_set($batch); @@ -458,7 +458,7 @@ function translation_entity_translatable_form_submit(array $form, array $form_st * @param string $field_name * Field machine name. */ -function translation_entity_translatable_switch($translatable, $field_name) { +function content_translation_translatable_switch($translatable, $field_name) { $field = field_info_field($field_name); if ($field['translatable'] !== $translatable) { $field['translatable'] = $translatable; @@ -475,7 +475,7 @@ function translation_entity_translatable_switch($translatable, $field_name) { * @param string $field_name * Field machine name. */ -function translation_entity_translatable_batch($translatable, $field_name, &$context) { +function content_translation_translatable_batch($translatable, $field_name, &$context) { $field = field_info_field($field_name); $column = isset($field['columns']['value']) ? 'value' : key($field['columns']); $query_field = "$field_name.$column"; @@ -554,10 +554,10 @@ function translation_entity_translatable_batch($translatable, $field_name, &$con // language. $entity->{$field_name}[$langcode] = $entity->{$field_name}[Language::LANGCODE_NOT_SPECIFIED]; // Store the original value. - _translation_entity_update_field($entity_type, $entity, $field_name); + _content_translation_update_field($entity_type, $entity, $field_name); $entity->{$field_name}[Language::LANGCODE_NOT_SPECIFIED] = array(); // Remove the language neutral value. - _translation_entity_update_field($entity_type, $entity, $field_name); + _content_translation_update_field($entity_type, $entity, $field_name); } elseif (!$translatable && isset($entity->{$field_name}[$langcode])) { // The field has been marked untranslatable and has data in the entity @@ -565,14 +565,14 @@ function translation_entity_translatable_batch($translatable, $field_name, &$con // other translations. $entity->{$field_name}[Language::LANGCODE_NOT_SPECIFIED] = $entity->{$field_name}[$langcode]; // Store the original value. - _translation_entity_update_field($entity_type, $entity, $field_name); + _content_translation_update_field($entity_type, $entity, $field_name); // Remove translations. foreach ($entity->{$field_name} as $langcode => $items) { if ($langcode != Language::LANGCODE_NOT_SPECIFIED) { $entity->{$field_name}[$langcode] = array(); } } - _translation_entity_update_field($entity_type, $entity, $field_name); + _content_translation_update_field($entity_type, $entity, $field_name); } else { // No need to save unchanged entities. @@ -587,7 +587,7 @@ function translation_entity_translatable_batch($translatable, $field_name, &$con /** * Stores the given field translations. */ -function _translation_entity_update_field($entity_type, EntityInterface $entity, $field_name) { +function _content_translation_update_field($entity_type, EntityInterface $entity, $field_name) { $empty = 0; $translations = $entity->getTranslationLanguages(); @@ -609,7 +609,7 @@ function _translation_entity_update_field($entity_type, EntityInterface $entity, /** * Batch finished callback: Checks the exit status of the batch operation. */ -function translation_entity_translatable_batch_done($success, $results, $operations) { +function content_translation_translatable_batch_done($success, $results, $operations) { if ($success) { drupal_set_message(t("Successfully changed field translation setting.")); } diff --git a/core/modules/translation_entity/translation_entity.admin.js b/core/modules/content_translation/content_translation.admin.js similarity index 90% rename from core/modules/translation_entity/translation_entity.admin.js rename to core/modules/content_translation/content_translation.admin.js index 2b934e8..72283a1 100644 --- a/core/modules/translation_entity/translation_entity.admin.js +++ b/core/modules/content_translation/content_translation.admin.js @@ -5,9 +5,9 @@ /** * Forces applicable options to be checked as translatable. */ -Drupal.behaviors.translationEntityDependentOptions = { +Drupal.behaviors.contentTranslationDependentOptions = { attach: function (context, settings) { - var $options = settings.translationEntityDependentOptions; + var $options = settings.contentTranslationDependentOptions; var $collections = []; // We're given a generic name to look for so we find all inputs containing @@ -24,11 +24,11 @@ Drupal.behaviors.translationEntityDependentOptions = { var $dependent_columns = $collection.dependent_columns; $fields.change(function() { - Drupal.behaviors.translationEntityDependentOptions.check($fields, $dependent_columns, $(this)); + Drupal.behaviors.contentTranslationDependentOptions.check($fields, $dependent_columns, $(this)); }); // Run the check function on first trigger of this behavior. - Drupal.behaviors.translationEntityDependentOptions.check($fields, $dependent_columns, false); + Drupal.behaviors.contentTranslationDependentOptions.check($fields, $dependent_columns, false); }); }, check: function($fields, $dependent_columns, $changed) { @@ -58,7 +58,7 @@ Drupal.behaviors.translationEntityDependentOptions = { /** * Makes field translatability inherit bundle translatability. */ -Drupal.behaviors.translationEntity = { +Drupal.behaviors.contentTranslation = { attach: function (context) { // Initially hide all field rows for non translatable bundles and all column // rows for non translatable fields. diff --git a/core/modules/translation_entity/translation_entity.info.yml b/core/modules/content_translation/content_translation.info.yml similarity index 100% rename from core/modules/translation_entity/translation_entity.info.yml rename to core/modules/content_translation/content_translation.info.yml diff --git a/core/modules/translation_entity/translation_entity.install b/core/modules/content_translation/content_translation.install similarity index 90% rename from core/modules/translation_entity/translation_entity.install rename to core/modules/content_translation/content_translation.install index 977d5fd..bd817bc 100644 --- a/core/modules/translation_entity/translation_entity.install +++ b/core/modules/content_translation/content_translation.install @@ -2,7 +2,7 @@ /** * @file - * Installation functions for Entity Translation module. + * Installation functions for Content Translation module. */ use Drupal\Core\Language\Language; @@ -10,9 +10,9 @@ /** * Implements hook_schema(). */ -function translation_entity_schema() { - $schema['translation_entity'] = array( - 'description' => 'Table to track entity translations', +function content_translation_schema() { + $schema['content_translation'] = array( + 'description' => 'Table to track content translations', 'fields' => array( 'entity_type' => array( 'type' => 'varchar', @@ -81,10 +81,10 @@ function translation_entity_schema() { /** * Implements hook_install(). */ -function translation_entity_install() { +function content_translation_install() { // Assign a fairly low weight to ensure our implementation of // hook_module_implements_alter() is run among the last ones. - module_set_weight('translation_entity', 10); + module_set_weight('content_translation', 10); language_negotiation_include(); language_negotiation_set(Language::TYPE_CONTENT, array(LANGUAGE_NEGOTIATION_URL => 0)); } @@ -92,7 +92,7 @@ function translation_entity_install() { /** * Implements hook_enable(). */ -function translation_entity_enable() { +function content_translation_enable() { // Translation works when at least two languages are enabled. if (count(language_list()) < 2) { $t_args = array('!language_url' => url('admin/config/regional/language')); diff --git a/core/modules/translation_entity/translation_entity.module b/core/modules/content_translation/content_translation.module similarity index 71% rename from core/modules/translation_entity/translation_entity.module rename to core/modules/content_translation/content_translation.module index 64cd8d6..c0c3535 100644 --- a/core/modules/translation_entity/translation_entity.module +++ b/core/modules/content_translation/content_translation.module @@ -14,12 +14,12 @@ /** * Implements hook_help(). */ -function translation_entity_help($path, $arg) { +function content_translation_help($path, $arg) { switch ($path) { - case 'admin/help#translation_entity': + case 'admin/help#content_translation': $output = ''; $output .= '

' . t('About') . '

'; - $output .= '

' . t('The Entity Translation module allows you to create and manage translations for your Drupal site content. You can specify which elements need to be translated at the content-type level for content items and comments, at the vocabulary level for taxonomy terms, and at the site level for user accounts. Other modules may provide additional elements that can be translated. For more information, see the online handbook entry for Entity Translation.', array('!url' => 'http://drupal.org/documentation/modules/entity_translation')) . '

'; + $output .= '

' . t('The Content Translation module allows you to create and manage translations for your Drupal site content. You can specify which elements need to be translated at the content-type level for content items and comments, at the vocabulary level for taxonomy terms, and at the site level for user accounts. Other modules may provide additional elements that can be translated. For more information, see the online handbook entry for Content Translation.', array('!url' => 'http://drupal.org/documentation/modules/entity_translation')) . '

'; $output .= '

' . t('Uses') . '

'; $output .= '
'; $output .= '
' . t('Enabling translation') . '
'; @@ -32,7 +32,7 @@ function translation_entity_help($path, $arg) { $output .= '
' . t('Maintaining translations') . '
'; $output .= '
' . t('If editing content in one language requires that translated versions also be updated to reflect the change, use the Flag other translations as outdated check box to mark the translations as outdated and in need of revision.') . '
'; $output .= '
' . t('Translation permissions') . '
'; - $output .= '
' . t('The Entity Translation module makes a basic set of permissions available. Additional permissions are made available after translation is enabled for each translatable element.', array('@permissions' => url('admin/people/permissions', array('fragment' => 'module-translation_entity')))) . '
'; + $output .= '
' . t('The Content Translation module makes a basic set of permissions available. Additional permissions are made available after translation is enabled for each translatable element.', array('@permissions' => url('admin/people/permissions', array('fragment' => 'module-content_translation')))) . '
'; $output .= '
'; return $output; @@ -48,14 +48,14 @@ function translation_entity_help($path, $arg) { /** * Implements hook_module_implements_alter(). */ -function translation_entity_module_implements_alter(&$implementations, $hook) { +function content_translation_module_implements_alter(&$implementations, $hook) { switch ($hook) { // Move some of our hook implementations to the end of the list. case 'menu_alter': case 'entity_info_alter': - $group = $implementations['translation_entity']; - unset($implementations['translation_entity']); - $implementations['translation_entity'] = $group; + $group = $implementations['content_translation']; + unset($implementations['content_translation']); + $implementations['content_translation'] = $group; break; } } @@ -63,7 +63,7 @@ function translation_entity_module_implements_alter(&$implementations, $hook) { /** * Implements hook_language_type_info_alter(). */ -function translation_entity_language_types_info_alter(array &$language_types) { +function content_translation_language_types_info_alter(array &$language_types) { // Make content language negotiation configurable by removing its predefined // configuration. unset($language_types[Language::TYPE_CONTENT]['fixed']); @@ -72,22 +72,22 @@ function translation_entity_language_types_info_alter(array &$language_types) { /** * Implements hook_entity_info_alter(). */ -function translation_entity_entity_info_alter(array &$entity_info) { +function content_translation_entity_info_alter(array &$entity_info) { // Provide defaults for translation info. foreach ($entity_info as $entity_type => &$info) { if (empty($info['translatable'])) { continue; } - if (!isset($info['translation']['translation_entity'])) { - $info['translation']['translation_entity'] = array(); + if (!isset($info['translation']['content_translation'])) { + $info['translation']['content_translation'] = array(); } // Every fieldable entity type must have a translation controller class, no // matter if it is enabled for translation or not. As a matter of fact we // might need it to correctly switch field translatability when a field is // shared accross different entities. - $info['controllers'] += array('translation' => 'Drupal\translation_entity\EntityTranslationController'); + $info['controllers'] += array('translation' => 'Drupal\content_translation\ContentTranslationController'); // If no menu base path is provided we default to the usual // "entity_type/%entity_type" pattern. @@ -105,8 +105,8 @@ function translation_entity_entity_info_alter(array &$entity_info) { ); $entity_position = count(explode('/', $path)) - 1; - $info['translation']['translation_entity'] += array( - 'access_callback' => 'translation_entity_translate_access', + $info['translation']['content_translation'] += array( + 'access_callback' => 'content_translation_translate_access', 'access_arguments' => array($entity_position), ); } @@ -115,10 +115,10 @@ function translation_entity_entity_info_alter(array &$entity_info) { /** * Implements hook_entity_bundle_info_alter(). */ -function translation_entity_entity_bundle_info_alter(&$bundles) { +function content_translation_entity_bundle_info_alter(&$bundles) { foreach ($bundles as $entity_type => &$info) { foreach ($info as $bundle => &$bundle_info) { - $enabled = translation_entity_get_config($entity_type, $bundle, 'enabled'); + $enabled = content_translation_get_config($entity_type, $bundle, 'enabled'); $bundle_info['translatable'] = !empty($enabled); } } @@ -127,17 +127,17 @@ function translation_entity_entity_bundle_info_alter(&$bundles) { /** * Implements hook_menu(). */ -function translation_entity_menu() { +function content_translation_menu() { $items = array(); // Create tabs for all possible entity types. foreach (entity_get_info() as $entity_type => $info) { // Provide the translation UI only for enabled types. - if (translation_entity_enabled($entity_type)) { + if (content_translation_enabled($entity_type)) { $path = $info['menu_base_path']; $entity_position = count(explode('/', $path)) - 1; $keys = array_flip(array('theme_callback', 'theme_arguments', 'access_callback', 'access_arguments', 'load_arguments')); - $menu_info = array_intersect_key($info['translation']['translation_entity'], $keys) + array('file' => 'translation_entity.pages.inc'); + $menu_info = array_intersect_key($info['translation']['content_translation'], $keys) + array('file' => 'content_translation.pages.inc'); $item = array(); // Plugin annotations cannot contain spaces, thus we need to restore them @@ -148,7 +148,7 @@ function translation_entity_menu() { $items["$path/translations"] = array( 'title' => 'Translate', - 'page callback' => 'translation_entity_overview', + 'page callback' => 'content_translation_overview', 'page arguments' => array($entity_position), 'type' => MENU_LOCAL_TASK, 'context' => MENU_CONTEXT_PAGE | MENU_CONTEXT_INLINE, @@ -168,9 +168,9 @@ function translation_entity_menu() { $args = array($entity_position, $language_position, $language_position + 1); $items["$path/translations/add/%language/%language"] = array( 'title' => 'Add', - 'page callback' => 'translation_entity_add_page', + 'page callback' => 'content_translation_add_page', 'page arguments' => $args, - 'access callback' => 'translation_entity_add_access', + 'access callback' => 'content_translation_add_access', 'access arguments' => $args, 'type' => MENU_LOCAL_TASK, 'weight' => 1, @@ -180,9 +180,9 @@ function translation_entity_menu() { $args = array($entity_position, $language_position); $items["$path/translations/edit/%language"] = array( 'title' => 'Edit', - 'page callback' => 'translation_entity_edit_page', + 'page callback' => 'content_translation_edit_page', 'page arguments' => $args, - 'access callback' => 'translation_entity_edit_access', + 'access callback' => 'content_translation_edit_access', 'access arguments' => $args, 'type' => MENU_LOCAL_TASK, 'weight' => 1, @@ -192,20 +192,20 @@ function translation_entity_menu() { $items["$path/translations/delete/%language"] = array( 'title' => 'Delete', 'page callback' => 'drupal_get_form', - 'page arguments' => array('translation_entity_delete_confirm', $entity_position, $language_position), - 'access callback' => 'translation_entity_delete_access', + 'page arguments' => array('content_translation_delete_confirm', $entity_position, $language_position), + 'access callback' => 'content_translation_delete_access', 'access arguments' => $args, ) + $item; } } - $items['admin/config/regional/translation_entity/translatable/%'] = array( + $items['admin/config/regional/content_translation/translatable/%'] = array( 'title' => 'Confirm change in translatability.', 'description' => 'Confirm page for changing field translatability.', 'page callback' => 'drupal_get_form', - 'page arguments' => array('translation_entity_translatable_form', 5), - 'access arguments' => array('administer entity translation'), - 'file' => 'translation_entity.admin.inc', + 'page arguments' => array('content_translation_translatable_form', 5), + 'access arguments' => array('administer content translation'), + 'file' => 'content_translation.admin.inc', ); return $items; @@ -214,10 +214,10 @@ function translation_entity_menu() { /** * Implements hook_menu_alter(). */ -function translation_entity_menu_alter(array &$items) { +function content_translation_menu_alter(array &$items) { // Check that the declared menu base paths are actually valid. foreach (entity_get_info() as $entity_type => $info) { - if (translation_entity_enabled($entity_type)) { + if (content_translation_enabled($entity_type)) { $path = $info['menu_base_path']; // If the base path is not defined we cannot provide the translation UI @@ -225,14 +225,14 @@ function translation_entity_menu_alter(array &$items) { // a menu loader associated, hence we need to check also for the plain "%" // variant. See for instance comment_menu(). if (!isset($items[$path]) && !isset($items["$path/edit"]) - && !isset($items[_translation_entity_menu_strip_loaders($path)])) { + && !isset($items[_content_translation_menu_strip_loaders($path)])) { unset( $items["$path/translations"], $items["$path/translations/add/%language/%language"], $items["$path/translations/delete/%language"] ); $t_args = array('@entity_type' => isset($info['label']) ? $info['label'] : $entity_type); - watchdog('entity translation', 'The entities of type @entity_type do not define a valid base path: it will not be possible to translate them.', $t_args, WATCHDOG_WARNING); + watchdog('content translation', 'The entities of type @entity_type do not define a valid base path: it will not be possible to translate them.', $t_args, WATCHDOG_WARNING); } else { $entity_position = count(explode('/', $path)) - 1; @@ -267,7 +267,7 @@ function translation_entity_menu_alter(array &$items) { * @return * The given path where all the menu loaders are replaced with "%". */ -function _translation_entity_menu_strip_loaders($path) { +function _content_translation_menu_strip_loaders($path) { return preg_replace('|%[^/]+|', '%', $path); } @@ -277,10 +277,10 @@ function _translation_entity_menu_strip_loaders($path) { * @param \Drupal\Core\Entity\EntityInterface $entity * The entity whose translation overview should be displayed. */ -function translation_entity_translate_access(EntityInterface $entity) { +function content_translation_translate_access(EntityInterface $entity) { $entity_type = $entity->entityType(); return empty($entity->language()->locked) && language_multilingual() && $entity->isTranslatable() && - (user_access('create entity translations') || user_access('update entity translations') || user_access('delete entity translations')); + (user_access('create content translations') || user_access('update content translations') || user_access('delete content translations')); } /** @@ -294,7 +294,7 @@ function translation_entity_translate_access(EntityInterface $entity) { * (optional) The account for which view access should be checked. Defaults to * the current user. */ -function translation_entity_view_access(EntityInterface $entity, $langcode, AccountInterface $account = NULL) { +function content_translation_view_access(EntityInterface $entity, $langcode, AccountInterface $account = NULL) { $entity_type = $entity->entityType(); return !empty($entity->translation[$langcode]['status']) || user_access('translate any entity', $account) || user_access("translate $entity_type entities", $account); } @@ -311,12 +311,12 @@ function translation_entity_view_access(EntityInterface $entity, $langcode, Acco * (optional) The language of the translated values. Defaults to the current * content language. */ -function translation_entity_add_access(EntityInterface $entity, Language $source = NULL, Language $target = NULL) { +function content_translation_add_access(EntityInterface $entity, Language $source = NULL, Language $target = NULL) { $source = !empty($source) ? $source : $entity->language(); $target = !empty($target) ? $target : language(Language::TYPE_CONTENT); $translations = $entity->getTranslationLanguages(); $languages = language_list(); - return $source->langcode != $target->langcode && isset($languages[$source->langcode]) && isset($languages[$target->langcode]) && !isset($translations[$target->langcode]) && translation_entity_access($entity, 'create'); + return $source->langcode != $target->langcode && isset($languages[$source->langcode]) && isset($languages[$target->langcode]) && !isset($translations[$target->langcode]) && content_translation_access($entity, 'create'); } /** @@ -328,11 +328,11 @@ function translation_entity_add_access(EntityInterface $entity, Language $source * (optional) The language of the translated values. Defaults to the current * content language. */ -function translation_entity_edit_access(EntityInterface $entity, Language $language = NULL) { +function content_translation_edit_access(EntityInterface $entity, Language $language = NULL) { $language = !empty($language) ? $language : language(Language::TYPE_CONTENT); $translations = $entity->getTranslationLanguages(); $languages = language_list(); - return isset($languages[$language->langcode]) && $language->langcode != $entity->language()->langcode && isset($translations[$language->langcode]) && translation_entity_access($entity, 'update'); + return isset($languages[$language->langcode]) && $language->langcode != $entity->language()->langcode && isset($translations[$language->langcode]) && content_translation_access($entity, 'update'); } /** @@ -344,26 +344,26 @@ function translation_entity_edit_access(EntityInterface $entity, Language $langu * (optional) The language of the translated values. Defaults to the current * content language. */ -function translation_entity_delete_access(EntityInterface $entity, Language $language = NULL) { +function content_translation_delete_access(EntityInterface $entity, Language $language = NULL) { $language = !empty($language) ? $language : language(Language::TYPE_CONTENT); $translations = $entity->getTranslationLanguages(); $languages = language_list(); - return isset($languages[$language->langcode]) && $language->langcode != $entity->language()->langcode && isset($translations[$language->langcode]) && translation_entity_access($entity, 'delete'); + return isset($languages[$language->langcode]) && $language->langcode != $entity->language()->langcode && isset($translations[$language->langcode]) && content_translation_access($entity, 'delete'); } /** * Implements hook_library_info(). */ -function translation_entity_library_info() { - $path = drupal_get_path('module', 'translation_entity'); - $libraries['drupal.translation_entity.admin'] = array( - 'title' => 'Translation entity UI', +function content_translation_library_info() { + $path = drupal_get_path('module', 'content_translation'); + $libraries['drupal.content_translation.admin'] = array( + 'title' => 'Content translation UI', 'version' => VERSION, 'js' => array( - $path . '/translation_entity.admin.js' => array(), + $path . '/content_translation.admin.js' => array(), ), 'css' => array( - $path . '/css/translation_entity.admin.css' => array(), + $path . '/css/content_translation.admin.css' => array(), ), 'dependencies' => array( array('system', 'jquery'), @@ -394,10 +394,10 @@ function translation_entity_library_info() { * @todo Generalize this logic so that it is available to any module needing * per-bundle configuration. */ -function translation_entity_get_config_key($entity_type, $bundle, $setting) { +function content_translation_get_config_key($entity_type, $bundle, $setting) { $entity_type = preg_replace('/[^0-9a-zA-Z_]/', "_", $entity_type); $bundle = preg_replace('/[^0-9a-zA-Z_]/', "_", $bundle); - return $entity_type . '.' . $bundle . '.translation_entity.' . $setting; + return $entity_type . '.' . $bundle . '.content_translation.' . $setting; } /** @@ -413,9 +413,9 @@ function translation_entity_get_config_key($entity_type, $bundle, $setting) { * @returns mixed * The stored value for the given setting. */ -function translation_entity_get_config($entity_type, $bundle, $setting) { - $key = translation_entity_get_config_key($entity_type, $bundle, $setting); - return config('translation_entity.settings')->get($key); +function content_translation_get_config($entity_type, $bundle, $setting) { + $key = content_translation_get_config_key($entity_type, $bundle, $setting); + return config('content_translation.settings')->get($key); } /** @@ -430,9 +430,9 @@ function translation_entity_get_config($entity_type, $bundle, $setting) { * @param $value * The value to be stored for the given setting. */ -function translation_entity_set_config($entity_type, $bundle, $setting, $value) { - $key = translation_entity_get_config_key($entity_type, $bundle, $setting); - return config('translation_entity.settings')->set($key, $value)->save(); +function content_translation_set_config($entity_type, $bundle, $setting, $value) { + $key = content_translation_get_config_key($entity_type, $bundle, $setting); + return config('content_translation.settings')->set($key, $value)->save(); } /** @@ -448,14 +448,14 @@ function translation_entity_set_config($entity_type, $bundle, $setting, $value) * TRUE if the specified bundle is translatable. If no bundle is provided * returns TRUE if at least one of the entity bundles is translatable. */ -function translation_entity_enabled($entity_type, $bundle = NULL) { +function content_translation_enabled($entity_type, $bundle = NULL) { $enabled = FALSE; $info = entity_get_info($entity_type); if (!empty($info['translatable'])) { $bundles = !empty($bundle) ? array($bundle) : array_keys(entity_get_bundles($entity_type)); foreach ($bundles as $bundle) { - if (translation_entity_get_config($entity_type, $bundle, 'enabled')) { + if (content_translation_get_config($entity_type, $bundle, 'enabled')) { $enabled = TRUE; break; } @@ -471,11 +471,11 @@ function translation_entity_enabled($entity_type, $bundle = NULL) { * @return array * An array of entity types keyed by entity type. */ -function translation_entity_types_translatable() { +function content_translation_types_translatable() { $entity_types = &drupal_static(__FUNCTION__, array()); foreach (entity_get_info() as $entity_type => $info) { - if (translation_entity_enabled($entity_type)) { + if (content_translation_enabled($entity_type)) { // Lazy load router items. if (!isset($items)) { $items = menu_get_router(); @@ -483,7 +483,7 @@ function translation_entity_types_translatable() { // Check whether the required paths are defined. We need to strip out the // menu loader and replace it with a plain "%" as router items have no // menu loader in them. - $path = _translation_entity_menu_strip_loaders($info['menu_base_path']); + $path = _content_translation_menu_strip_loaders($info['menu_base_path']); if (!empty($items[$path]) && !empty($items[$path . '/translations'])) { $entity_types[$entity_type] = $entity_type; } @@ -494,15 +494,15 @@ function translation_entity_types_translatable() { } /** - * Entity translation controller factory. + * Content translation controller factory. * * @param string $entity_type * The type of the entity being translated. * - * @return \Drupal\translation_entity\EntityTranslationControllerInterface - * An instance of the entity translation controller interface. + * @return \Drupal\content_translation\ContentTranslationControllerInterface + * An instance of the content translation controller interface. */ -function translation_entity_controller($entity_type) { +function content_translation_controller($entity_type) { $entity_info = entity_get_info($entity_type); // @todo Throw an exception if the key is missing. return new $entity_info['controllers']['translation']($entity_type, $entity_info); @@ -515,15 +515,15 @@ function translation_entity_controller($entity_type) { * The form state array holding the entity form controller. * * @return \Drupal\Core\Entity\EntityFormControllerInterface; - * An instance of the entity translation form interface or FALSE if not an + * An instance of the content translation form interface or FALSE if not an * entity form. */ -function translation_entity_form_controller(array $form_state) { +function content_translation_form_controller(array $form_state) { return isset($form_state['controller']) && $form_state['controller'] instanceof EntityFormControllerInterface ? $form_state['controller'] : FALSE; } /** - * Checks whether an entity translation is accessible. + * Checks whether a content translation is accessible. * * @param \Drupal\Core\Entity\EntityInterface $entity * The entity to be accessed. @@ -537,26 +537,26 @@ function translation_entity_form_controller(array $form_state) { * @return * TRUE if the current user is allowed to view the translation. */ -function translation_entity_access(EntityInterface $entity, $op) { - return translation_entity_controller($entity->entityType())->getTranslationAccess($entity, $op) ; +function content_translation_access(EntityInterface $entity, $op) { + return content_translation_controller($entity->entityType())->getTranslationAccess($entity, $op) ; } /** * Implements hook_permission(). */ -function translation_entity_permission() { +function content_translation_permission() { $permission = array( - 'administer entity translation' => array( + 'administer content translation' => array( 'title' => t('Administer translation settings'), 'description' => t('Configure translatability of entities and fields.'), ), - 'create entity translations' => array( + 'create content translations' => array( 'title' => t('Create translations'), ), - 'update entity translations' => array( + 'update content translations' => array( 'title' => t('Edit translations'), ), - 'delete entity translations' => array( + 'delete content translations' => array( 'title' => t('Delete translations'), ), 'translate any entity' => array( @@ -573,7 +573,7 @@ function translation_entity_permission() { switch ($info['permission_granularity']) { case 'bundle': foreach (entity_get_bundles($entity_type) as $bundle => $bundle_info) { - if (translation_entity_enabled($entity_type, $bundle)) { + if (content_translation_enabled($entity_type, $bundle)) { $t_args['%bundle_label'] = isset($bundle_info['label']) ? $bundle_info['label'] : $bundle; $permission["translate $bundle $entity_type"] = array( 'title' => t('Translate %bundle_label @entity_label', $t_args), @@ -583,7 +583,7 @@ function translation_entity_permission() { break; case 'entity_type': - if (translation_entity_enabled($entity_type)) { + if (content_translation_enabled($entity_type)) { $permission["translate $entity_type"] = array( 'title' => t('Translate @entity_label', $t_args), ); @@ -599,9 +599,9 @@ function translation_entity_permission() { /** * Implements hook_form_alter(). */ -function translation_entity_form_alter(array &$form, array &$form_state) { - if (($form_controller = translation_entity_form_controller($form_state)) && ($entity = $form_controller->getEntity()) && !$entity->isNew() && $entity->isTranslatable()) { - $controller = translation_entity_controller($entity->entityType()); +function content_translation_form_alter(array &$form, array &$form_state) { + if (($form_controller = content_translation_form_controller($form_state)) && ($entity = $form_controller->getEntity()) && !$entity->isNew() && $entity->isTranslatable()) { + $controller = content_translation_controller($entity->entityType()); $controller->entityFormAlter($form, $form_state, $entity); // @todo Move the following lines to the code generating the property form @@ -637,18 +637,18 @@ function translation_entity_form_alter(array &$form, array &$form_state) { * * Performs language fallback for unaccessible translations. */ -function translation_entity_field_language_alter(&$display_language, $context) { +function content_translation_field_language_alter(&$display_language, $context) { $entity = $context['entity']; $entity_type = $entity->entityType(); - if (isset($entity->translation[$context['langcode']]) && $entity->isTranslatable() && !translation_entity_view_access($entity, $context['langcode'])) { + if (isset($entity->translation[$context['langcode']]) && $entity->isTranslatable() && !content_translation_view_access($entity, $context['langcode'])) { $instances = field_info_instances($entity_type, $entity->bundle()); // Avoid altering the real entity. $entity = clone($entity); $entity_langcode = $entity->language()->langcode; foreach ($entity->translation as $langcode => $translation) { - if ($langcode == $context['langcode'] || !translation_entity_view_access($entity, $langcode)) { + if ($langcode == $context['langcode'] || !content_translation_view_access($entity, $langcode)) { // Unset unaccessible field translations: if the field is untranslatable // unsetting a language different from Language::LANGCODE_NOT_SPECIFIED has no // effect. @@ -672,10 +672,10 @@ function translation_entity_field_language_alter(&$display_language, $context) { /** * Implements hook_entity_load(). */ -function translation_entity_entity_load(array $entities, $entity_type) { +function content_translation_entity_load(array $entities, $entity_type) { $enabled_entities = array(); - if (translation_entity_enabled($entity_type)) { + if (content_translation_enabled($entity_type)) { foreach ($entities as $entity) { if ($entity->isTranslatable()) { $enabled_entities[$entity->id()] = $entity; @@ -684,7 +684,7 @@ function translation_entity_entity_load(array $entities, $entity_type) { } if (!empty($enabled_entities)) { - translation_entity_load_translation_metadata($enabled_entities, $entity_type); + content_translation_load_translation_metadata($enabled_entities, $entity_type); } } @@ -696,8 +696,8 @@ function translation_entity_entity_load(array $entities, $entity_type) { * @param string $entity_type * The type of the entities. */ -function translation_entity_load_translation_metadata(array $entities, $entity_type) { - $query = 'SELECT * FROM {translation_entity} te WHERE te.entity_type = :entity_type AND te.entity_id IN (:entity_id)'; +function content_translation_load_translation_metadata(array $entities, $entity_type) { + $query = 'SELECT * FROM {content_translation} te WHERE te.entity_type = :entity_type AND te.entity_id IN (:entity_id)'; $result = db_query($query, array(':entity_type' => $entity_type, ':entity_id' => array_keys($entities))); $exclude = array('entity_type', 'entity_id', 'langcode'); foreach ($result as $record) { @@ -714,14 +714,14 @@ function translation_entity_load_translation_metadata(array $entities, $entity_t /** * Implements hook_entity_insert(). */ -function translation_entity_entity_insert(EntityInterface $entity) { +function content_translation_entity_insert(EntityInterface $entity) { // Only do something if translation support for the given entity is enabled. if (!$entity->isTranslatable()) { return; } $fields = array('entity_type', 'entity_id', 'langcode', 'source', 'outdated', 'uid', 'status', 'created', 'changed'); - $query = db_insert('translation_entity')->fields($fields); + $query = db_insert('content_translation')->fields($fields); foreach ($entity->getTranslationLanguages() as $langcode => $language) { $translation = isset($entity->translation[$langcode]) ? $entity->translation[$langcode] : array(); @@ -754,13 +754,13 @@ function translation_entity_entity_insert(EntityInterface $entity) { /** * Implements hook_entity_delete(). */ -function translation_entity_entity_delete(EntityInterface $entity) { +function content_translation_entity_delete(EntityInterface $entity) { // Only do something if translation support for the given entity is enabled. if (!$entity->isTranslatable()) { return; } - db_delete('translation_entity') + db_delete('content_translation') ->condition('entity_type', $entity->entityType()) ->condition('entity_id', $entity->id()) ->execute(); @@ -769,26 +769,26 @@ function translation_entity_entity_delete(EntityInterface $entity) { /** * Implements hook_entity_update(). */ -function translation_entity_entity_update(EntityInterface $entity) { +function content_translation_entity_update(EntityInterface $entity) { // Only do something if translation support for the given entity is enabled. if (!$entity->isTranslatable()) { return; } // Delete and create to ensure no stale value remains behind. - translation_entity_entity_delete($entity); - translation_entity_entity_insert($entity); + content_translation_entity_delete($entity); + content_translation_entity_insert($entity); } /** * Implements hook_field_extra_fields(). */ -function translation_entity_field_extra_fields() { +function content_translation_field_extra_fields() { $extra = array(); foreach (entity_get_info() as $entity_type => $info) { foreach (entity_get_bundles($entity_type) as $bundle => $bundle_info) { - if (translation_entity_enabled($entity_type, $bundle)) { + if (content_translation_enabled($entity_type, $bundle)) { $extra[$entity_type][$bundle]['form']['translation'] = array( 'label' => t('Translation'), 'description' => t('Translation settings'), @@ -804,7 +804,7 @@ function translation_entity_field_extra_fields() { /** * 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) { +function content_translation_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']; @@ -819,9 +819,9 @@ function translation_entity_form_field_ui_field_edit_form_alter(array &$form, ar '#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, + '#href' => 'admin/config/regional/content_translation/translatable/' . $field_name, '#options' => array('query' => drupal_get_destination()), - '#access' => user_access('administer entity translation'), + '#access' => user_access('administer content translation'), ), ); } @@ -839,10 +839,10 @@ function translation_entity_form_field_ui_field_edit_form_alter(array &$form, ar /** * Implements hook_form_FORM_ID_alter() for 'field_ui_field_instance_edit_form'. */ -function translation_entity_form_field_ui_field_instance_edit_form_alter(array &$form, array &$form_state, $form_id) { +function content_translation_form_field_ui_field_instance_edit_form_alter(array &$form, array &$form_state, $form_id) { if ($form['#field']['translatable']) { - module_load_include('inc', 'translation_entity', 'translation_entity.admin'); - $element = translation_entity_field_sync_widget($form['#field'], $form['#instance']); + module_load_include('inc', 'content_translation', 'content_translation.admin'); + $element = content_translation_field_sync_widget($form['#field'], $form['#instance']); if ($element) { $form['instance']['settings']['translation_sync'] = $element; } @@ -852,7 +852,7 @@ function translation_entity_form_field_ui_field_instance_edit_form_alter(array & /** * Implements hook_field_info_alter(). */ -function translation_entity_field_info_alter(&$info) { +function content_translation_field_info_alter(&$info) { foreach ($info as $field_type => &$field_type_info) { // By default no column has to be synchronized. $field_type_info['settings'] += array('translation_sync' => FALSE); @@ -864,25 +864,25 @@ function translation_entity_field_info_alter(&$info) { /** * Implements hook_entity_presave(). */ -function translation_entity_entity_presave(EntityInterface $entity) { +function content_translation_entity_presave(EntityInterface $entity) { $entity_info = $entity->entityInfo(); if ($entity->isTranslatable() && !empty($entity_info['fieldable'])) { $attributes = drupal_container()->get('request')->attributes; - Drupal::service('translation_entity.synchronizer')->synchronizeFields($entity, $attributes->get('working_langcode'), $attributes->get('source_langcode')); + Drupal::service('content_translation.synchronizer')->synchronizeFields($entity, $attributes->get('working_langcode'), $attributes->get('source_langcode')); } } /** * Implements hook_element_info_alter(). */ -function translation_entity_element_info_alter(&$type) { +function content_translation_element_info_alter(&$type) { if (isset($type['language_configuration'])) { - $type['language_configuration']['#process'][] = 'translation_entity_language_configuration_element_process'; + $type['language_configuration']['#process'][] = 'content_translation_language_configuration_element_process'; } } /** - * Returns a widget to enable entity translation per entity bundle. + * Returns a widget to enable content translation per entity bundle. * * Backward compatibility layer to support entities not using the language * configuration form element. @@ -898,14 +898,14 @@ function translation_entity_element_info_alter(&$type) { * @param array $form_state * The configuration form state array. */ -function translation_entity_enable_widget($entity_type, $bundle, array &$form, array &$form_state) { - $key = $form_state['translation_entity']['key']; +function content_translation_enable_widget($entity_type, $bundle, array &$form, array &$form_state) { + $key = $form_state['content_translation']['key']; if (!isset($form_state['language'][$key])) { $form_state['language'][$key] = array(); } $form_state['language'][$key] += array('entity_type' => $entity_type, 'bundle' => $bundle); - $element = translation_entity_language_configuration_element_process(array('#name' => $key), $form_state, $form); - unset($element['translation_entity']['#element_validate']); + $element = content_translation_language_configuration_element_process(array('#name' => $key), $form_state, $form); + unset($element['content_translation']['#element_validate']); return $element; } @@ -918,37 +918,37 @@ function translation_entity_enable_widget($entity_type, $bundle, array &$form, a * @return * Processed language configuration element. */ -function translation_entity_language_configuration_element_process(array $element, array &$form_state, array &$form) { - if (empty($element['#translation_entity_skip_alter']) && user_access('administer entity translation')) { - $form_state['translation_entity']['key'] = $element['#name']; +function content_translation_language_configuration_element_process(array $element, array &$form_state, array &$form) { + if (empty($element['#content_translation_skip_alter']) && user_access('administer content translation')) { + $form_state['content_translation']['key'] = $element['#name']; $context = $form_state['language'][$element['#name']]; - $element['translation_entity'] = array( + $element['content_translation'] = array( '#type' => 'checkbox', '#title' => t('Enable translation'), - '#default_value' => translation_entity_enabled($context['entity_type'], $context['bundle']), - '#element_validate' => array('translation_entity_language_configuration_element_validate'), + '#default_value' => content_translation_enabled($context['entity_type'], $context['bundle']), + '#element_validate' => array('content_translation_language_configuration_element_validate'), '#prefix' => '', ); - $form['#submit'][] = 'translation_entity_language_configuration_element_submit'; + $form['#submit'][] = 'content_translation_language_configuration_element_submit'; } return $element; } /** - * Form validation handler for element added with translation_entity_language_configuration_element_process(). + * Form validation handler for element added with content_translation_language_configuration_element_process(). * * Checks whether translation can be enabled: if language is set to one of the * special languages and language selector is not hidden, translation cannot be * enabled. * - * @see translation_entity_language_configuration_element_submit() + * @see content_translation_language_configuration_element_submit() */ -function translation_entity_language_configuration_element_validate($element, array &$form_state, array $form) { - $key = $form_state['translation_entity']['key']; +function content_translation_language_configuration_element_validate($element, array &$form_state, array $form) { + $key = $form_state['content_translation']['key']; $values = $form_state['values'][$key]; - if (language_is_locked($values['langcode']) && !$values['language_show'] && $values['translation_entity']) { + if (language_is_locked($values['langcode']) && !$values['language_show'] && $values['content_translation']) { foreach (language_list(Language::STATE_LOCKED) as $language) { $locked_languages[] = $language->name; } @@ -960,19 +960,19 @@ function translation_entity_language_configuration_element_validate($element, ar } /** - * Form submission handler for element added with translation_entity_language_configuration_element_process(). + * Form submission handler for element added with content_translation_language_configuration_element_process(). * - * Stores the entity translation settings. + * Stores the content translation settings. * - * @see translation_entity_language_configuration_element_validate() + * @see content_translation_language_configuration_element_validate() */ -function translation_entity_language_configuration_element_submit(array $form, array &$form_state) { - $key = $form_state['translation_entity']['key']; +function content_translation_language_configuration_element_submit(array $form, array &$form_state) { + $key = $form_state['content_translation']['key']; $context = $form_state['language'][$key]; - $enabled = $form_state['values'][$key]['translation_entity']; + $enabled = $form_state['values'][$key]['content_translation']; - if (translation_entity_enabled($context['entity_type'], $context['bundle']) != $enabled) { - translation_entity_set_config($context['entity_type'], $context['bundle'], 'enabled', $enabled); + if (content_translation_enabled($context['entity_type'], $context['bundle']) != $enabled) { + content_translation_set_config($context['entity_type'], $context['bundle'], 'enabled', $enabled); entity_info_cache_clear(); menu_router_rebuild(); } @@ -981,21 +981,21 @@ function translation_entity_language_configuration_element_submit(array $form, a /** * Implements hook_form_FORM_ID_alter() for language_content_settings_form(). */ -function translation_entity_form_language_content_settings_form_alter(array &$form, array &$form_state) { - module_load_include('inc', 'translation_entity', 'translation_entity.admin'); - _translation_entity_form_language_content_settings_form_alter($form, $form_state); +function content_translation_form_language_content_settings_form_alter(array &$form, array &$form_state) { + module_load_include('inc', 'content_translation', 'content_translation.admin'); + _content_translation_form_language_content_settings_form_alter($form, $form_state); } /** * Implements hook_preprocess_HOOK() for theme_language_content_settings_table(). */ -function translation_entity_preprocess_language_content_settings_table(&$variables) { - module_load_include('inc', 'translation_entity', 'translation_entity.admin'); - _translation_entity_preprocess_language_content_settings_table($variables); +function content_translation_preprocess_language_content_settings_table(&$variables) { + module_load_include('inc', 'content_translation', 'content_translation.admin'); + _content_translation_preprocess_language_content_settings_table($variables); } /** - * Stores entity translation settings. + * Stores content translation settings. * * @param array $settings * An associative array of settings keyed by entity type and bundle. At bundle @@ -1008,13 +1008,13 @@ function translation_entity_preprocess_language_content_settings_table(&$variabl * - columns: An associative array of translation synchronization settings * keyed by field names. */ -function translation_entity_save_settings($settings) { +function content_translation_save_settings($settings) { foreach ($settings as $entity_type => $entity_settings) { foreach ($entity_settings as $bundle => $bundle_settings) { // The 'translatable' value is set only if it is possible to enable. if (isset($bundle_settings['translatable'])) { // Store whether a bundle has translation enabled or not. - translation_entity_set_config($entity_type, $bundle, 'enabled', $bundle_settings['translatable']); + content_translation_set_config($entity_type, $bundle, 'enabled', $bundle_settings['translatable']); // Store whether fields have translation enabled or not. if (!empty($bundle_settings['columns'])) { diff --git a/core/modules/translation_entity/translation_entity.pages.inc b/core/modules/content_translation/content_translation.pages.inc similarity index 85% rename from core/modules/translation_entity/translation_entity.pages.inc rename to core/modules/content_translation/content_translation.pages.inc index cd212eb..2940585 100644 --- a/core/modules/translation_entity/translation_entity.pages.inc +++ b/core/modules/content_translation/content_translation.pages.inc @@ -2,7 +2,7 @@ /** * @file - * The entity translation user interface. + * The content translation user interface. */ use Drupal\Core\Language\Language; @@ -15,8 +15,8 @@ * @param \Drupal\Core\Entity\EntityInterface $entity * The entity whose translation overview should be displayed. */ -function translation_entity_overview(EntityInterface $entity) { - $controller = translation_entity_controller($entity->entityType()); +function content_translation_overview(EntityInterface $entity) { + $controller = content_translation_controller($entity->entityType()); $entity_manager = Drupal::entityManager(); $languages = language_list(); $original = $entity->language()->langcode; @@ -34,7 +34,7 @@ function translation_entity_overview(EntityInterface $entity) { // If we have a view path defined for the current entity get the switch // links based on it. if ($path) { - $links = _translation_entity_get_switch_links($path); + $links = _content_translation_get_switch_links($path); } // Determine whether the current entity is translatable. @@ -56,10 +56,10 @@ function translation_entity_overview(EntityInterface $entity) { $delete_path = $base_path . '/translations/delete/' . $langcode; if ($base_path) { - $add_links = _translation_entity_get_switch_links($add_path); - $edit_links = _translation_entity_get_switch_links($edit_path); - $translate_links = _translation_entity_get_switch_links($translate_path); - $delete_links = _translation_entity_get_switch_links($delete_path); + $add_links = _content_translation_get_switch_links($add_path); + $edit_links = _content_translation_get_switch_links($edit_path); + $translate_links = _content_translation_get_switch_links($translate_path); + $delete_links = _content_translation_get_switch_links($delete_path); } $operations = array( @@ -146,7 +146,7 @@ function translation_entity_overview(EntityInterface $entity) { // which entity this is. $build['#entity'] = $entity; - $build['translation_entity_overview'] = array( + $build['content_translation_overview'] = array( '#theme' => 'table', '#header' => $header, '#rows' => $rows, @@ -164,7 +164,7 @@ function translation_entity_overview(EntityInterface $entity) { * @returns * A renderable array of language switch links. */ -function _translation_entity_get_switch_links($path) { +function _content_translation_get_switch_links($path) { $links = language_negotiation_get_switch_links(Language::TYPE_CONTENT, $path); if (empty($links)) { // If content language is set up to fall back to the interface language, @@ -190,18 +190,18 @@ function _translation_entity_get_switch_links($path) { * @return array * A processed form array ready to be rendered. */ -function translation_entity_add_page(EntityInterface $entity, Language $source = NULL, Language $target = NULL) { +function content_translation_add_page(EntityInterface $entity, Language $source = NULL, Language $target = NULL) { $source = !empty($source) ? $source : $entity->language(); $target = !empty($target) ? $target : language(Language::TYPE_CONTENT); // @todo Exploit the upcoming hook_entity_prepare() when available. - translation_entity_prepare_translation($entity, $source, $target); + content_translation_prepare_translation($entity, $source, $target); $info = $entity->entityInfo(); $operation = isset($info['default_operation']) ? $info['default_operation'] : 'default'; $form_state['langcode'] = $target->langcode; - $form_state['translation_entity']['source'] = $source; - $form_state['translation_entity']['target'] = $target; - $controller = translation_entity_controller($entity->entityType()); - $form_state['translation_entity']['translation_form'] = !$controller->getAccess($entity, 'update'); + $form_state['content_translation']['source'] = $source; + $form_state['content_translation']['target'] = $target; + $controller = content_translation_controller($entity->entityType()); + $form_state['content_translation']['translation_form'] = !$controller->getAccess($entity, 'update'); return Drupal::entityManager()->getForm($entity, $operation, $form_state); } @@ -217,12 +217,12 @@ function translation_entity_add_page(EntityInterface $entity, Language $source = * @return array * A processed form array ready to be rendered. */ -function translation_entity_edit_page(EntityInterface $entity, Language $language = NULL) { +function content_translation_edit_page(EntityInterface $entity, Language $language = NULL) { $language = !empty($language) ? $language : language(Language::TYPE_CONTENT); $info = $entity->entityInfo(); $operation = isset($info['default_operation']) ? $info['default_operation'] : 'default'; $form_state['langcode'] = $language->langcode; - $form_state['translation_entity']['translation_form'] = TRUE; + $form_state['content_translation']['translation_form'] = TRUE; return Drupal::entityManager()->getForm($entity, $operation, $form_state); } @@ -236,7 +236,7 @@ function translation_entity_edit_page(EntityInterface $entity, Language $languag * @param \Drupal\Core\Language\Language $target * The language to be used as target. */ -function translation_entity_prepare_translation(EntityInterface $entity, Language $source, Language $target) { +function content_translation_prepare_translation(EntityInterface $entity, Language $source, Language $target) { // @todo Unify field and property handling. $instances = field_info_instances($entity->entityType(), $entity->bundle()); $entity = $entity->getNGEntity(); @@ -265,9 +265,9 @@ function translation_entity_prepare_translation(EntityInterface $entity, Languag /** * Form constructor for the translation deletion confirmation. */ -function translation_entity_delete_confirm(array $form, array $form_state, EntityInterface $entity, Language $language) { +function content_translation_delete_confirm(array $form, array $form_state, EntityInterface $entity, Language $language) { $langcode = $language->langcode; - $controller = translation_entity_controller($entity->entityType()); + $controller = content_translation_controller($entity->entityType()); return confirm_form( $form, @@ -280,11 +280,11 @@ function translation_entity_delete_confirm(array $form, array $form_state, Entit } /** - * Form submission handler for translation_entity_delete_confirm(). + * Form submission handler for content_translation_delete_confirm(). */ -function translation_entity_delete_confirm_submit(array $form, array &$form_state) { +function content_translation_delete_confirm_submit(array $form, array &$form_state) { list($entity, $language) = $form_state['build_info']['args']; - $controller = translation_entity_controller($entity->entityType()); + $controller = content_translation_controller($entity->entityType()); // Remove the translated values. $controller->removeTranslation($entity, $language->langcode); diff --git a/core/modules/content_translation/content_translation.services.yml b/core/modules/content_translation/content_translation.services.yml new file mode 100644 index 0000000..1a4a939 --- /dev/null +++ b/core/modules/content_translation/content_translation.services.yml @@ -0,0 +1,4 @@ +services: + content_translation.synchronizer: + class: Drupal\content_translation\FieldTranslationSynchronizer + arguments: ['@plugin.manager.entity'] diff --git a/core/modules/translation_entity/css/translation_entity.admin.css b/core/modules/content_translation/css/translation_entity.admin.css similarity index 100% rename from core/modules/translation_entity/css/translation_entity.admin.css rename to core/modules/content_translation/css/translation_entity.admin.css diff --git a/core/modules/translation_entity/lib/Drupal/translation_entity/EntityTranslationController.php b/core/modules/content_translation/lib/Drupal/content_translation/ContentTranslationController.php similarity index 85% rename from core/modules/translation_entity/lib/Drupal/translation_entity/EntityTranslationController.php rename to core/modules/content_translation/lib/Drupal/content_translation/ContentTranslationController.php index 1fb68e5..944ec69 100644 --- a/core/modules/translation_entity/lib/Drupal/translation_entity/EntityTranslationController.php +++ b/core/modules/content_translation/lib/Drupal/content_translation/ContentTranslationController.php @@ -2,18 +2,18 @@ /** * @file - * Definition of Drupal\translation_entity\EntityTranslationController. + * Definition of Drupal\content_translation\ContentTranslationController. */ -namespace Drupal\translation_entity; +namespace Drupal\content_translation; use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Language\Language; /** - * Base class for entity translation controllers. + * Base class for content translation controllers. */ -class EntityTranslationController implements EntityTranslationControllerInterface { +class ContentTranslationController implements ContentTranslationControllerInterface { /** * The type of the entity being translated. @@ -30,7 +30,7 @@ class EntityTranslationController implements EntityTranslationControllerInterfac protected $entityInfo; /** - * Initializes an instance of the entity translation controller. + * Initializes an instance of the content translation controller. * * @param string $entity_type * The type of the entity being translated. @@ -43,7 +43,7 @@ public function __construct($entity_type, $entity_info) { } /** - * Implements EntityTranslationControllerInterface::removeTranslation(). + * Implements ContentTranslationControllerInterface::removeTranslation(). */ public function removeTranslation(EntityInterface $entity, $langcode) { $translations = $entity->getTranslationLanguages(); @@ -59,7 +59,7 @@ public function removeTranslation(EntityInterface $entity, $langcode) { } /** - * Implements EntityTranslationControllerInterface::retranslate(). + * Implements ContentTranslationControllerInterface::retranslate(). */ public function retranslate(EntityInterface $entity, $langcode = NULL) { $updated_langcode = !empty($langcode) ? $langcode : $entity->language()->langcode; @@ -70,35 +70,35 @@ public function retranslate(EntityInterface $entity, $langcode = NULL) { } /** - * Implements EntityTranslationControllerInterface::getBasePath(). + * Implements ContentTranslationControllerInterface::getBasePath(). */ public function getBasePath(EntityInterface $entity) { return $this->getPathInstance($this->entityInfo['menu_base_path'], $entity->id()); } /** - * Implements EntityTranslationControllerInterface::getEditPath(). + * Implements ContentTranslationControllerInterface::getEditPath(). */ public function getEditPath(EntityInterface $entity) { return isset($this->entityInfo['menu_edit_path']) ? $this->getPathInstance($this->entityInfo['menu_edit_path'], $entity->id()) : FALSE; } /** - * Implements EntityTranslationControllerInterface::getViewPath(). + * Implements ContentTranslationControllerInterface::getViewPath(). */ public function getViewPath(EntityInterface $entity) { return isset($this->entityInfo['menu_view_path']) ? $this->getPathInstance($this->entityInfo['menu_view_path'], $entity->id()) : FALSE; } /** - * Implements EntityTranslationControllerInterface::getAccess(). + * Implements ContentTranslationControllerInterface::getAccess(). */ public function getAccess(EntityInterface $entity, $op) { return TRUE; } /** - * Implements EntityTranslationControllerInterface::getTranslationAccess(). + * Implements ContentTranslationControllerInterface::getTranslationAccess(). */ public function getTranslationAccess(EntityInterface $entity, $op) { // @todo Move this logic into a translation access controller checking also @@ -110,21 +110,21 @@ public function getTranslationAccess(EntityInterface $entity, $op) { if (!user_access('translate any entity') && !empty($info['permission_granularity'])) { $translate_permission = user_access($info['permission_granularity'] == 'bundle' ? "translate {$entity->bundle()} {$entity->entityType()}" : "translate {$entity->entityType()}"); } - return $translate_permission && user_access("$op entity translations"); + return $translate_permission && user_access("$op content translations"); } /** - * Implements EntityTranslationControllerInterface::getSourceLanguage(). + * Implements ContentTranslationControllerInterface::getSourceLanguage(). */ public function getSourceLangcode(array $form_state) { - return isset($form_state['translation_entity']['source']) ? $form_state['translation_entity']['source']->langcode : FALSE; + return isset($form_state['content_translation']['source']) ? $form_state['content_translation']['source']->langcode : FALSE; } /** - * Implements EntityTranslationControllerInterface::entityFormAlter(). + * Implements ContentTranslationControllerInterface::entityFormAlter(). */ public function entityFormAlter(array &$form, array &$form_state, EntityInterface $entity) { - $form_controller = translation_entity_form_controller($form_state); + $form_controller = content_translation_form_controller($form_state); $form_langcode = $form_controller->getFormLangcode($form_state); $entity_langcode = $entity->language()->langcode; $source_langcode = $this->getSourceLangcode($form_state); @@ -222,7 +222,7 @@ public function entityFormAlter(array &$form, array &$form_state, EntityInterfac // We need to display the translation tab only when there is at least one // translation available or a new one is about to be created. if ($new_translation || $has_translations) { - $form['translation_entity'] = array( + $form['content_translation'] = array( '#type' => 'details', '#title' => t('Translation'), '#collapsed' => TRUE, @@ -250,7 +250,7 @@ public function entityFormAlter(array &$form, array &$form_state, EntityInterfac t('An unpublished translation will not be visible without translation permissions.') : t('Only this translation is published. You must publish at least one more translation to unpublish this one.'); - $form['translation_entity']['status'] = array( + $form['content_translation']['status'] = array( '#type' => 'checkbox', '#title' => t('This translation is published'), '#default_value' => $status, @@ -260,7 +260,7 @@ public function entityFormAlter(array &$form, array &$form_state, EntityInterfac $translate = !$new_translation && $entity->translation[$form_langcode]['outdated']; if (!$translate) { - $form['translation_entity']['retranslate'] = array( + $form['content_translation']['retranslate'] = array( '#type' => 'checkbox', '#title' => t('Flag other translations as outdated'), '#default_value' => FALSE, @@ -268,7 +268,7 @@ public function entityFormAlter(array &$form, array &$form_state, EntityInterfac ); } else { - $form['translation_entity']['outdated'] = array( + $form['content_translation']['outdated'] = array( '#type' => 'checkbox', '#title' => t('This translation needs to be updated'), '#default_value' => $translate, @@ -277,7 +277,7 @@ public function entityFormAlter(array &$form, array &$form_state, EntityInterfac } $name = $new_translation ? $GLOBALS['user']->name : user_load($entity->translation[$form_langcode]['uid'])->name; - $form['translation_entity']['name'] = array( + $form['content_translation']['name'] = array( '#type' => 'textfield', '#title' => t('Authored by'), '#maxlength' => 60, @@ -287,7 +287,7 @@ public function entityFormAlter(array &$form, array &$form_state, EntityInterfac ); $date = $new_translation ? REQUEST_TIME : $entity->translation[$form_langcode]['created']; - $form['translation_entity']['created'] = array( + $form['content_translation']['created'] = array( '#type' => 'textfield', '#title' => t('Authored on'), '#maxlength' => 25, @@ -319,7 +319,7 @@ public function entityFormAlter(array &$form, array &$form_state, EntityInterfac /** * Process callback: determines which elements get clue in the form. * - * @see \Drupal\translation_entity\EntityTranslationController::entityFormAlter() + * @see \Drupal\content_translation\ContentTranslationController::entityFormAlter() */ public function entityFormSharedElements($element, $form_state, $form) { static $ignored_types; @@ -344,7 +344,7 @@ public function entityFormSharedElements($element, $form_state, $form) { // If we are displaying a multilingual entity form we need to provide // translatability clues, otherwise the shared form elements should be // hidden. - if (empty($form_state['translation_entity']['translation_form'])) { + if (empty($form_state['content_translation']['translation_form'])) { $this->addTranslatabilityClue($element[$key]); } else { @@ -403,16 +403,16 @@ protected function addTranslatabilityClue(&$element) { * @param \Drupal\Core\Entity\EntityInterface $entity * The entity whose form is being built. * - * @see \Drupal\translation_entity\EntityTranslationController::entityFormAlter() + * @see \Drupal\content_translation\ContentTranslationController::entityFormAlter() */ public function entityFormEntityBuild($entity_type, EntityInterface $entity, array $form, array &$form_state) { - $form_controller = translation_entity_form_controller($form_state); + $form_controller = content_translation_form_controller($form_state); $form_langcode = $form_controller->getFormLangcode($form_state); if (!isset($entity->translation[$form_langcode])) { $entity->translation[$form_langcode] = array(); } - $values = isset($form_state['values']['translation_entity']) ? $form_state['values']['translation_entity'] : array(); + $values = isset($form_state['values']['content_translation']) ? $form_state['values']['content_translation'] : array(); $translation = &$entity->translation[$form_langcode]; // @todo Use the entity setter when all entities support multilingual @@ -441,31 +441,31 @@ public function entityFormEntityBuild($entity_type, EntityInterface $entity, arr } /** - * Form validation handler for EntityTranslationController::entityFormAlter(). + * Form validation handler for ContentTranslationController::entityFormAlter(). * - * Validates the submitted entity translation metadata. + * Validates the submitted content translation metadata. */ function entityFormValidate($form, &$form_state) { - if (!empty($form_state['values']['translation_entity'])) { - $translation = $form_state['values']['translation_entity']; + if (!empty($form_state['values']['content_translation'])) { + $translation = $form_state['values']['content_translation']; // Validate the "authored by" field. if (!empty($translation['name']) && !($account = user_load_by_name($translation['name']))) { - form_set_error('translation_entity][name', t('The translation authoring username %name does not exist.', array('%name' => $translation['name']))); + form_set_error('content_translation][name', t('The translation authoring username %name does not exist.', array('%name' => $translation['name']))); } // Validate the "authored on" field. if (!empty($translation['created']) && strtotime($translation['created']) === FALSE) { - form_set_error('translation_entity][created', t('You have to specify a valid translation authoring date.')); + form_set_error('content_translation][created', t('You have to specify a valid translation authoring date.')); } } } /** - * Form submission handler for EntityTranslationController::entityFormAlter(). + * Form submission handler for ContentTranslationController::entityFormAlter(). * * Takes care of the source language change. */ public function entityFormSourceChange($form, &$form_state) { - $form_controller = translation_entity_form_controller($form_state); + $form_controller = content_translation_form_controller($form_state); $entity = $form_controller->getEntity(); $source = $form_state['values']['source_langcode']['source']; $path = $this->getBasePath($entity) . '/translations/add/' . $source . '/' . $form_controller->getFormLangcode($form_state); @@ -475,12 +475,12 @@ public function entityFormSourceChange($form, &$form_state) { } /** - * Form submission handler for EntityTranslationController::entityFormAlter(). + * Form submission handler for ContentTranslationController::entityFormAlter(). * * Takes care of entity deletion. */ function entityFormDelete($form, &$form_state) { - $form_controller = translation_entity_form_controller($form_state); + $form_controller = content_translation_form_controller($form_state); $entity = $form_controller->getEntity(); if (count($entity->getTranslationLanguages()) > 1) { drupal_set_message(t('This will delete all the translations of %label.', array('%label' => $entity->label())), 'warning'); @@ -488,12 +488,12 @@ function entityFormDelete($form, &$form_state) { } /** - * Form submission handler for EntityTranslationController::entityFormAlter(). + * Form submission handler for ContentTranslationController::entityFormAlter(). * - * Takes care of entity translation deletion. + * Takes care of content translation deletion. */ function entityFormDeleteTranslation($form, &$form_state) { - $form_controller = translation_entity_form_controller($form_state); + $form_controller = content_translation_form_controller($form_state); $entity = $form_controller->getEntity(); $base_path = $this->getBasePath($entity); $form_langcode = $form_controller->getFormLangcode($form_state); diff --git a/core/modules/translation_entity/lib/Drupal/translation_entity/EntityTranslationControllerInterface.php b/core/modules/content_translation/lib/Drupal/content_translation/ContentTranslationControllerInterface.php similarity index 87% rename from core/modules/translation_entity/lib/Drupal/translation_entity/EntityTranslationControllerInterface.php rename to core/modules/content_translation/lib/Drupal/content_translation/ContentTranslationControllerInterface.php index dbac33b..112d8e8 100644 --- a/core/modules/translation_entity/lib/Drupal/translation_entity/EntityTranslationControllerInterface.php +++ b/core/modules/content_translation/lib/Drupal/content_translation/ContentTranslationControllerInterface.php @@ -2,24 +2,24 @@ /** * @file - * Definition of Drupal\translation_entity\EntityTranslationControllerInterface. + * Definition of Drupal\content_translation\ContentTranslationControllerInterface. */ -namespace Drupal\translation_entity; +namespace Drupal\content_translation; use Drupal\Core\Entity\EntityInterface; /** - * Interface for providing entity translation. + * Interface for providing content translation. * * Defines a set of methods to allow any entity to be processed by the entity * translation UI. * - * The entity translation UI relies on the entity info to provide its features. + * The content translation UI relies on the entity info to provide its features. * See the documentation of hook_entity_info() in the Entity API documentation * for more details on all the entity info keys that may be defined. * - * To make Entity Translation automatically support an entity type some keys + * To make Content Translation automatically support an entity type some keys * may need to be defined, but none of them is required unless the entity path * is different from ENTITY_TYPE/%ENTITY_TYPE (e.g. taxonomy/term/1), in which * case at least the 'menu_base_path' key must be defined. This is used to @@ -38,19 +38,19 @@ * Every entity type needs a translation controller to be translated. This can * be specified through the "controllers['translation']" key in the entity * info. If an entity type is enabled for translation and no translation - * controller is defined, Drupal\translation_entity\EntityTranslationController + * controller is defined, Drupal\content_translation\ContentTranslationController * will be assumed. Every translation controller class must implement - * Drupal\translation_entity\EntityTranslationControllerInterface. + * Drupal\content_translation\ContentTranslationControllerInterface. * * If the entity paths match the default patterns above and there is no need for - * an entity-specific translation controller class, Entity Translation will + * an entity-specific translation controller class, Content Translation will * provide built-in support for the entity. It will still be required to enable * translation for each translatable bundle. * * Additionally some more entity info keys can be defined to further customize - * the translation UI. The entity translation info is an associative array that + * the translation UI. The content translation info is an associative array that * has to match the following structure. Two nested arrays keyed respectively - * by the 'translation' key and the 'translation_entity' key. Elements: + * by the 'translation' key and the 'content_translation' key. Elements: * - access callback: The access callback for the translation pages. Defaults to * 'entity_translation_translate_access'. * - access arguments: The access arguments for the translation pages. By @@ -64,19 +64,19 @@ * 'menu_base_path' => 'mymodule/myentity/%my_entity_loader', * 'menu_path_wildcard' => '%my_entity_loader', * 'translation' => array( - * 'translation_entity' => array( + * 'content_translation' => array( * 'access_callback' => 'mymodule_myentity_translate_access', * 'access_arguments' => array(2), * ), * ), * ); - * $info['myentity']['controllers'] += array('translation' => 'Drupal\mymodule\MyEntityTranslationController'); + * $info['myentity']['controllers'] += array('translation' => 'Drupal\mymodule\MyContentTranslationController'); * } * @endcode * * @see \Drupal\Core\Entity\EntityManager */ -interface EntityTranslationControllerInterface { +interface ContentTranslationControllerInterface { /** * Returns the base path for the current entity. diff --git a/core/modules/translation_entity/lib/Drupal/translation_entity/EntityTranslationControllerNG.php b/core/modules/content_translation/lib/Drupal/content_translation/ContentTranslationControllerNG.php similarity index 53% rename from core/modules/translation_entity/lib/Drupal/translation_entity/EntityTranslationControllerNG.php rename to core/modules/content_translation/lib/Drupal/content_translation/ContentTranslationControllerNG.php index fd007cd..6c27d49 100644 --- a/core/modules/translation_entity/lib/Drupal/translation_entity/EntityTranslationControllerNG.php +++ b/core/modules/content_translation/lib/Drupal/content_translation/ContentTranslationControllerNG.php @@ -2,27 +2,27 @@ /** * @file - * Contains \Drupal\translation_entity\EntityTranslationControllerNG. + * Contains \Drupal\content_translation\ContentTranslationControllerNG. */ -namespace Drupal\translation_entity; +namespace Drupal\content_translation; use Drupal\Core\Entity\EntityInterface; /** - * Test entity translation controller. + * Test content translation controller. */ -class EntityTranslationControllerNG extends EntityTranslationController { +class ContentTranslationControllerNG extends ContentTranslationController { /** - * Overrides \Drupal\translation_entity\EntityTranslationController::getAccess(). + * Overrides \Drupal\content_translation\ContentTranslationController::getAccess(). */ public function getAccess(EntityInterface $entity, $op) { return $entity->access($op); } /** - * Overrides \Drupal\translation_entity\EntityTranslationControllerInterface::removeTranslation(). + * Overrides \Drupal\content_translation\ContentTranslationControllerInterface::removeTranslation(). */ public function removeTranslation(EntityInterface $entity, $langcode) { $translation = $entity->getTranslation($langcode); diff --git a/core/modules/translation_entity/lib/Drupal/translation_entity/FieldTranslationSynchronizer.php b/core/modules/content_translation/lib/Drupal/content_translation/FieldTranslationSynchronizer.php similarity index 98% rename from core/modules/translation_entity/lib/Drupal/translation_entity/FieldTranslationSynchronizer.php rename to core/modules/content_translation/lib/Drupal/content_translation/FieldTranslationSynchronizer.php index 39d1a21..45a6c91 100644 --- a/core/modules/translation_entity/lib/Drupal/translation_entity/FieldTranslationSynchronizer.php +++ b/core/modules/content_translation/lib/Drupal/content_translation/FieldTranslationSynchronizer.php @@ -2,10 +2,10 @@ /** * @file - * Contains \Drupal\translation_entity\FieldTranslationSynchronizer. + * Contains \Drupal\content_translation\FieldTranslationSynchronizer. */ -namespace Drupal\translation_entity; +namespace Drupal\content_translation; use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityManager; diff --git a/core/modules/translation_entity/lib/Drupal/translation_entity/FieldTranslationSynchronizerInterface.php b/core/modules/content_translation/lib/Drupal/content_translation/FieldTranslationSynchronizerInterface.php similarity index 95% rename from core/modules/translation_entity/lib/Drupal/translation_entity/FieldTranslationSynchronizerInterface.php rename to core/modules/content_translation/lib/Drupal/content_translation/FieldTranslationSynchronizerInterface.php index 1ae361c..7c73b33 100644 --- a/core/modules/translation_entity/lib/Drupal/translation_entity/FieldTranslationSynchronizerInterface.php +++ b/core/modules/content_translation/lib/Drupal/content_translation/FieldTranslationSynchronizerInterface.php @@ -2,10 +2,10 @@ /** * @file - * Contains \Drupal\translation_entity\FieldTranslationSynchronizerInterface. + * Contains \Drupal\content_translation\FieldTranslationSynchronizerInterface. */ -namespace Drupal\translation_entity; +namespace Drupal\content_translation; use Drupal\Core\Entity\EntityInterface; diff --git a/core/modules/translation_entity/lib/Drupal/translation_entity/Plugin/views/field/TranslationLink.php b/core/modules/content_translation/lib/Drupal/content_translation/Plugin/views/field/TranslationLink.php similarity index 89% rename from core/modules/translation_entity/lib/Drupal/translation_entity/Plugin/views/field/TranslationLink.php rename to core/modules/content_translation/lib/Drupal/content_translation/Plugin/views/field/TranslationLink.php index 6c0dcab..2abd160 100644 --- a/core/modules/translation_entity/lib/Drupal/translation_entity/Plugin/views/field/TranslationLink.php +++ b/core/modules/content_translation/lib/Drupal/content_translation/Plugin/views/field/TranslationLink.php @@ -2,10 +2,10 @@ /** * @file - * Contains \Drupal\translation_entity\Plugin\views\field\TranslationLink. + * Contains \Drupal\content_translation\Plugin\views\field\TranslationLink. */ -namespace Drupal\translation_entity\Plugin\views\field; +namespace Drupal\content_translation\Plugin\views\field; use Drupal\views\Plugin\views\field\FieldPluginBase; use Drupal\Component\Annotation\PluginID; @@ -16,7 +16,7 @@ * * @ingroup views_field_handlers * - * @PluginID("translation_entity_link") + * @PluginID("content_translation_link") */ class TranslationLink extends FieldPluginBase { @@ -60,7 +60,7 @@ function render($values) { * The acutal rendered text (without the link) of this field. */ public function render_link(EntityInterface $entity, \stdClass $values) { - if (translation_entity_translate_access($entity)) { + if (content_translation_translate_access($entity)) { $text = !empty($this->options['text']) ? $this->options['text'] : t('translate'); $this->options['alter']['make_link'] = TRUE; diff --git a/core/modules/translation_entity/lib/Drupal/translation_entity/Tests/ConfigTestTranslationUITest.php b/core/modules/content_translation/lib/Drupal/content_translation/Tests/ConfigTestTranslationUITest.php similarity index 75% rename from core/modules/translation_entity/lib/Drupal/translation_entity/Tests/ConfigTestTranslationUITest.php rename to core/modules/content_translation/lib/Drupal/content_translation/Tests/ConfigTestTranslationUITest.php index 9c51c46..5765cd4 100644 --- a/core/modules/translation_entity/lib/Drupal/translation_entity/Tests/ConfigTestTranslationUITest.php +++ b/core/modules/content_translation/lib/Drupal/content_translation/Tests/ConfigTestTranslationUITest.php @@ -5,12 +5,12 @@ * Definition of Drupal\entity\Tests\ConfigTestTranslationUITest. */ -namespace Drupal\translation_entity\Tests; +namespace Drupal\content_translation\Tests; /** * Tests the Config Test Translation UI. */ -class ConfigTestTranslationUITest extends EntityTranslationUITest { +class ConfigTestTranslationUITest extends ContentTranslationUITest { /** * Modules to enable. @@ -19,13 +19,13 @@ class ConfigTestTranslationUITest extends EntityTranslationUITest { * * @var array */ - public static $modules = array('language', 'translation_entity', 'image', 'config_test'); + public static $modules = array('language', 'content_translation', 'image', 'config_test'); public static function getInfo() { return array( 'name' => 'Config Test Translation UI', - 'description' => 'Tests the test entity translation UI with the test config entity.', - 'group' => 'Entity Translation UI', + 'description' => 'Tests the test content translation UI with the test config entity.', + 'group' => 'Content Translation UI', ); } @@ -35,7 +35,7 @@ function setUp() { } /** - * Overrides \Drupal\translation_entity\Tests\EntityTranslationUITest::enableTranslation(). + * Overrides \Drupal\content_translation\Tests\ContentTranslationUITest::enableTranslation(). */ protected function enableTranslation() { $this->container->get('state')->set('config_test.translatable', TRUE); @@ -43,7 +43,7 @@ protected function enableTranslation() { } /** - * Overrides \Drupal\translation_entity\Tests\EntityTranslationUITest::getNewEntityValues(). + * Overrides \Drupal\content_translation\Tests\ContentTranslationUITest::getNewEntityValues(). */ protected function getNewEntityValues($langcode) { return array( @@ -54,7 +54,7 @@ protected function getNewEntityValues($langcode) { } /** - * Overrides EntityTranslationTest::testTranslationUI(). + * Overrides ContentTranslationTest::testTranslationUI(). * * @todo This override is a copy-paste of parts of the parent method. Turn * ConfigTest into a properly translatable entity and remove this override. @@ -77,7 +77,7 @@ function testTranslationUI() { } /** - * Overrides EntityTranslationUITest::setupTestFields(). + * Overrides ContentTranslationUITest::setupTestFields(). * * The config_test entity is not fieldable. */ diff --git a/core/modules/translation_entity/lib/Drupal/translation_entity/Tests/EntityTestTranslationUITest.php b/core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTestTranslationUITest.php similarity index 59% rename from core/modules/translation_entity/lib/Drupal/translation_entity/Tests/EntityTestTranslationUITest.php rename to core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTestTranslationUITest.php index 3a34da1..ad32718 100644 --- a/core/modules/translation_entity/lib/Drupal/translation_entity/Tests/EntityTestTranslationUITest.php +++ b/core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTestTranslationUITest.php @@ -2,28 +2,28 @@ /** * @file - * Definition of Drupal\entity\Tests\EntityTestTranslationUITest. + * Definition of Drupal\entity\Tests\ContentTestTranslationUITest. */ -namespace Drupal\translation_entity\Tests; +namespace Drupal\content_translation\Tests; /** * Tests the Entity Test Translation UI. */ -class EntityTestTranslationUITest extends EntityTranslationUITest { +class ContentTestTranslationUITest extends ContentTranslationUITest { /** * Modules to enable. * * @var array */ - public static $modules = array('language', 'translation_entity', 'entity_test'); + public static $modules = array('language', 'content_translation', 'entity_test'); public static function getInfo() { return array( 'name' => 'Entity Test translation UI', - 'description' => 'Tests the test entity translation UI with the test entity.', - 'group' => 'Entity Translation UI', + 'description' => 'Tests the test content translation UI with the test entity.', + 'group' => 'Content Translation UI', ); } @@ -37,14 +37,14 @@ function setUp() { } /** - * Overrides \Drupal\translation_entity\Tests\EntityTranslationUITest::getTranslatorPermission(). + * Overrides \Drupal\content_translation\Tests\ContentTranslationUITest::getTranslatorPermission(). */ protected function getTranslatorPermissions() { return array_merge(parent::getTranslatorPermissions(), array('administer entity_test content')); } /** - * Overrides \Drupal\translation_entity\Tests\EntityTranslationUITest::getNewEntityValues(). + * Overrides \Drupal\content_translation\Tests\ContentTranslationUITest::getNewEntityValues(). */ protected function getNewEntityValues($langcode) { return array( diff --git a/core/modules/translation_entity/lib/Drupal/translation_entity/Tests/EntityTranslationSettingsTest.php b/core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationSettingsTest.php similarity index 88% rename from core/modules/translation_entity/lib/Drupal/translation_entity/Tests/EntityTranslationSettingsTest.php rename to core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationSettingsTest.php index 292d6e4..182eb64 100644 --- a/core/modules/translation_entity/lib/Drupal/translation_entity/Tests/EntityTranslationSettingsTest.php +++ b/core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationSettingsTest.php @@ -2,10 +2,10 @@ /** * @file - * Contains Drupal\translation_entity\Tests\EntityTranslationSettingsTest. + * Contains Drupal\content_translation\Tests\ContentTranslationSettingsTest. */ -namespace Drupal\translation_entity\Tests; +namespace Drupal\content_translation\Tests; use Drupal\Core\Language\Language; use Drupal\simpletest\WebTestBase; @@ -13,20 +13,20 @@ /** * Tests the Entity Test Translation UI. */ -class EntityTranslationSettingsTest extends WebTestBase { +class ContentTranslationSettingsTest extends WebTestBase { /** * Modules to enable. * * @var array */ - public static $modules = array('language', 'translation_entity', 'comment'); + public static $modules = array('language', 'content_translation', 'comment'); public static function getInfo() { return array( - 'name' => 'Entity Translation settings', - 'description' => 'Tests the entity translation settings UI.', - 'group' => 'Entity Translation UI', + 'name' => 'Content Translation settings', + 'description' => 'Tests the content translation settings UI.', + 'group' => 'Content Translation UI', ); } @@ -38,7 +38,7 @@ function setUp() { $this->drupalCreateContentType(array('type' => 'article')); $this->drupalCreateContentType(array('type' => 'page')); - $admin_user = $this->drupalCreateUser(array('administer languages', 'administer entity translation')); + $admin_user = $this->drupalCreateUser(array('administer languages', 'administer content translation')); $this->drupalLogin($admin_user); } @@ -108,7 +108,7 @@ function testSettingsUI() { * @param boolean $enabled * TRUE if translatibility should be enabled, FALSE otherwise. * @param array $edit - * An array of values to submit to the entity translation settings page. + * An array of values to submit to the content translation settings page. * * @return boolean * TRUE if the assertion succeeded, FALSE otherwise. @@ -119,7 +119,7 @@ protected function assertSettings($entity_type, $bundle, $enabled, $edit) { $message = format_string('Translation for entity @entity_type (@bundle) is @enabled.', $args); field_info_cache_clear(); entity_info_cache_clear(); - return $this->assertEqual(translation_entity_enabled($entity_type, $bundle), $enabled, $message); + return $this->assertEqual(content_translation_enabled($entity_type, $bundle), $enabled, $message); } } diff --git a/core/modules/translation_entity/lib/Drupal/translation_entity/Tests/EntityTranslationSyncImageTest.php b/core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationSyncImageTest.php similarity index 95% rename from core/modules/translation_entity/lib/Drupal/translation_entity/Tests/EntityTranslationSyncImageTest.php rename to core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationSyncImageTest.php index 6e9b82e..7bfa73f 100644 --- a/core/modules/translation_entity/lib/Drupal/translation_entity/Tests/EntityTranslationSyncImageTest.php +++ b/core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationSyncImageTest.php @@ -2,18 +2,18 @@ /** * @file - * Contains \Drupal\entity\Tests\EntityTranslationSyncImageTest. + * Contains \Drupal\entity\Tests\ContentTranslationSyncImageTest. */ -namespace Drupal\translation_entity\Tests; +namespace Drupal\content_translation\Tests; use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Language\Language; /** - * Tests the Entity Translation image field synchronization capability. + * Tests the Content Translation image field synchronization capability. */ -class EntityTranslationSyncImageTest extends EntityTranslationTestBase { +class ContentTranslationSyncImageTest extends ContentTranslationTestBase { /** * The cardinality of the image field. @@ -34,13 +34,13 @@ class EntityTranslationSyncImageTest extends EntityTranslationTestBase { * * @var array */ - public static $modules = array('language', 'translation_entity', 'entity_test', 'image'); + public static $modules = array('language', 'content_translation', 'entity_test', 'image'); public static function getInfo() { return array( 'name' => 'Image field synchronization', 'description' => 'Tests the field synchronization behavior for the image field.', - 'group' => 'Entity Translation UI', + 'group' => 'Content Translation UI', ); } diff --git a/core/modules/translation_entity/lib/Drupal/translation_entity/Tests/EntityTranslationSyncUnitTest.php b/core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationSyncUnitTest.php similarity index 95% rename from core/modules/translation_entity/lib/Drupal/translation_entity/Tests/EntityTranslationSyncUnitTest.php rename to core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationSyncUnitTest.php index 3a77d95..ab59812 100644 --- a/core/modules/translation_entity/lib/Drupal/translation_entity/Tests/EntityTranslationSyncUnitTest.php +++ b/core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationSyncUnitTest.php @@ -2,24 +2,24 @@ /** * @file - * Contains \Drupal\entity\Tests\EntityTranslationSyncUnitTest. + * Contains \Drupal\entity\Tests\ContentTranslationSyncUnitTest. */ -namespace Drupal\translation_entity\Tests; +namespace Drupal\content_translation\Tests; use Drupal\Core\Language\Language; use Drupal\simpletest\DrupalUnitTestBase; -use Drupal\translation_entity\FieldTranslationSynchronizer; +use Drupal\content_translation\FieldTranslationSynchronizer; /** - * Tests the Entity Translation field synchronization algorithm. + * Tests the Content Translation field synchronization algorithm. */ -class EntityTranslationSyncUnitTest extends DrupalUnitTestBase { +class ContentTranslationSyncUnitTest extends DrupalUnitTestBase { /** * The synchronizer class to be tested. * - * @var \Drupal\translation_entity\FieldTranslationSynchronizer + * @var \Drupal\content_translation\FieldTranslationSynchronizer */ protected $synchronizer; @@ -58,13 +58,13 @@ class EntityTranslationSyncUnitTest extends DrupalUnitTestBase { */ protected $unchangedFieldValues; - public static $modules = array('language', 'translation_entity'); + public static $modules = array('language', 'content_translation'); public static function getInfo() { return array( 'name' => 'Field synchronization', 'description' => 'Tests the field synchronization logic.', - 'group' => 'Entity Translation UI', + 'group' => 'Content Translation UI', ); } diff --git a/core/modules/translation_entity/lib/Drupal/translation_entity/Tests/EntityTranslationTestBase.php b/core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationTestBase.php similarity index 91% rename from core/modules/translation_entity/lib/Drupal/translation_entity/Tests/EntityTranslationTestBase.php rename to core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationTestBase.php index 4b99445..a454b8a 100644 --- a/core/modules/translation_entity/lib/Drupal/translation_entity/Tests/EntityTranslationTestBase.php +++ b/core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationTestBase.php @@ -2,19 +2,19 @@ /** * @file - * Contains \Drupal\entity\Tests\EntityTranslationTestBase. + * Contains \Drupal\entity\Tests\ContentTranslationTestBase. */ -namespace Drupal\translation_entity\Tests; +namespace Drupal\content_translation\Tests; use Drupal\Core\Entity\DatabaseStorageControllerNG; use Drupal\Core\Language\Language; use Drupal\simpletest\WebTestBase; /** - * Tests entity translation workflows. + * Tests content translation workflows. */ -abstract class EntityTranslationTestBase extends WebTestBase { +abstract class ContentTranslationTestBase extends WebTestBase { /** * The entity type being tested. @@ -68,7 +68,7 @@ /** * The translation controller for the current entity type. * - * @var \Drupal\translation_entity\EntityTranslationControllerInterface + * @var \Drupal\content_translation\ContentTranslationControllerInterface */ protected $controller; @@ -81,7 +81,7 @@ function setUp() { $this->setupUsers(); $this->setupTestFields(); - $this->controller = translation_entity_controller($this->entityType); + $this->controller = content_translation_controller($this->entityType); // Rebuild the container so that the new languages are picked up by services // that hold a list of languages. @@ -103,7 +103,7 @@ protected function setupLanguages() { * Returns an array of permissions needed for the translator. */ protected function getTranslatorPermissions() { - return array_filter(array($this->getTranslatePermission(), 'create entity translations', 'update entity translations', 'delete entity translations')); + return array_filter(array($this->getTranslatePermission(), 'create content translations', 'update content translations', 'delete content translations')); } /** @@ -149,7 +149,7 @@ protected function setupBundle() { protected function enableTranslation() { // Enable translation for the current entity type and ensure the change is // picked up. - translation_entity_set_config($this->entityType, $this->bundle, 'enabled', TRUE); + content_translation_set_config($this->entityType, $this->bundle, 'enabled', TRUE); drupal_static_reset(); entity_info_cache_clear(); menu_router_rebuild(); diff --git a/core/modules/translation_entity/lib/Drupal/translation_entity/Tests/EntityTranslationUITest.php b/core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationUITest.php similarity index 88% rename from core/modules/translation_entity/lib/Drupal/translation_entity/Tests/EntityTranslationUITest.php rename to core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationUITest.php index 50e8bbd..6ffad4f 100644 --- a/core/modules/translation_entity/lib/Drupal/translation_entity/Tests/EntityTranslationUITest.php +++ b/core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationUITest.php @@ -2,10 +2,10 @@ /** * @file - * Definition of Drupal\entity\Tests\EntityTranslationUITest. + * Definition of Drupal\entity\Tests\ContentTranslationUITest. */ -namespace Drupal\translation_entity\Tests; +namespace Drupal\content_translation\Tests; use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityNG; @@ -13,9 +13,9 @@ use Drupal\Core\TypedData\ComplexDataInterface; /** - * Tests the Entity Translation UI. + * Tests the Content Translation UI. */ -abstract class EntityTranslationUITest extends EntityTranslationTestBase { +abstract class ContentTranslationUITest extends ContentTranslationTestBase { /** * The id of the entity being translated. @@ -61,7 +61,7 @@ protected function assertBasicTranslation() { $this->assertEqual($stored_value, $value, $message); } - // Add an entity translation. + // Add a content translation. $langcode = 'it'; $values[$langcode] = $this->getNewEntityValues($langcode); @@ -83,7 +83,7 @@ protected function assertBasicTranslation() { // Add another translation and mark the other ones as outdated. $values[$langcode] = $this->getNewEntityValues($langcode); - $edit = $this->getEditValues($values, $langcode) + array('translation_entity[retranslate]' => TRUE); + $edit = $this->getEditValues($values, $langcode) + array('content_translation[retranslate]' => TRUE); $this->drupalPost($path, $edit, $this->getFormSubmitAction($entity)); $entity = entity_load($this->entityType, $this->entityId, TRUE); @@ -108,7 +108,7 @@ protected function assertOutdatedStatus() { $default_langcode = $this->langcodes[0]; // Mark translations as outdated. - $edit = array('translation_entity[retranslate]' => TRUE); + $edit = array('content_translation[retranslate]' => TRUE); $this->drupalPost($langcode . '/' . $this->controller->getEditPath($entity), $edit, $this->getFormSubmitAction($entity)); $entity = entity_load($this->entityType, $this->entityId, TRUE); @@ -118,14 +118,14 @@ protected function assertOutdatedStatus() { $path = $prefix . $this->controller->getEditPath($entity); $this->drupalGet($path); if ($enabled_langcode == $langcode) { - $this->assertFieldByXPath('//input[@name="translation_entity[retranslate]"]', FALSE, 'The retranslate flag is not checked by default.'); + $this->assertFieldByXPath('//input[@name="content_translation[retranslate]"]', FALSE, 'The retranslate flag is not checked by default.'); } else { - $this->assertFieldByXPath('//input[@name="translation_entity[outdated]"]', TRUE, 'The translate flag is checked by default.'); - $edit = array('translation_entity[outdated]' => FALSE); + $this->assertFieldByXPath('//input[@name="content_translation[outdated]"]', TRUE, 'The translate flag is checked by default.'); + $edit = array('content_translation[outdated]' => FALSE); $this->drupalPost($path, $edit, $this->getFormSubmitAction($entity)); $this->drupalGet($path); - $this->assertFieldByXPath('//input[@name="translation_entity[retranslate]"]', FALSE, 'The retranslate flag is now shown.'); + $this->assertFieldByXPath('//input[@name="content_translation[retranslate]"]', FALSE, 'The retranslate flag is now shown.'); $entity = entity_load($this->entityType, $this->entityId, TRUE); $this->assertFalse($entity->translation[$enabled_langcode]['outdated'], 'The "outdated" status has been correctly stored.'); } @@ -142,7 +142,7 @@ protected function assertPublishedStatus() { // Unpublish translations. foreach ($this->langcodes as $index => $langcode) { if ($index > 0) { - $edit = array('translation_entity[status]' => FALSE); + $edit = array('content_translation[status]' => FALSE); $this->drupalPost($langcode . '/' . $path, $edit, $this->getFormSubmitAction($entity)); $entity = entity_load($this->entityType, $this->entityId, TRUE); $this->assertFalse($entity->translation[$langcode]['status'], 'The translation has been correctly unpublished.'); @@ -151,7 +151,7 @@ protected function assertPublishedStatus() { // Check that the last published translation cannot be unpublished. $this->drupalGet($path); - $this->assertFieldByXPath('//input[@name="translation_entity[status]" and @disabled="disabled"]', TRUE, 'The last translation is published and cannot be unpublished.'); + $this->assertFieldByXPath('//input[@name="content_translation[status]" and @disabled="disabled"]', TRUE, 'The last translation is published and cannot be unpublished.'); } /** @@ -170,8 +170,8 @@ protected function assertAuthoringInfo() { 'created' => REQUEST_TIME - mt_rand(0, 1000), ); $edit = array( - 'translation_entity[name]' => $user->name, - 'translation_entity[created]' => format_date($values[$langcode]['created'], 'custom', 'Y-m-d H:i:s O'), + 'content_translation[name]' => $user->name, + 'content_translation[created]' => format_date($values[$langcode]['created'], 'custom', 'Y-m-d H:i:s O'), ); $prefix = $index > 0 ? $langcode . '/' : ''; $this->drupalPost($prefix . $path, $edit, $this->getFormSubmitAction($entity)); @@ -187,8 +187,8 @@ protected function assertAuthoringInfo() { $langcode = 'en'; $edit = array( // User names have by default length 8. - 'translation_entity[name]' => $this->randomName(12), - 'translation_entity[created]' => '19/11/1978', + 'content_translation[name]' => $this->randomName(12), + 'content_translation[created]' => '19/11/1978', ); $this->drupalPost($path, $edit, $this->getFormSubmitAction($entity)); $this->assertTrue($this->xpath('//div[@id="messages"]//div[contains(@class, "error")]//ul'), 'Invalid values generate a list of form errors.'); diff --git a/core/modules/translation_entity/lib/Drupal/translation_entity/Tests/EntityTranslationWorkflowsTest.php b/core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationWorkflowsTest.php similarity index 91% rename from core/modules/translation_entity/lib/Drupal/translation_entity/Tests/EntityTranslationWorkflowsTest.php rename to core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationWorkflowsTest.php index 9475ab0..4930283 100644 --- a/core/modules/translation_entity/lib/Drupal/translation_entity/Tests/EntityTranslationWorkflowsTest.php +++ b/core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationWorkflowsTest.php @@ -2,18 +2,18 @@ /** * @file - * Contains \Drupal\entity\Tests\EntityTranslationWorkflowsTest. + * Contains \Drupal\entity\Tests\ContentTranslationWorkflowsTest. */ -namespace Drupal\translation_entity\Tests; +namespace Drupal\content_translation\Tests; use Drupal\Core\Language\Language; use Drupal\user\UserInterface; /** - * Tests entity translation workflows. + * Tests content translation workflows. */ -class EntityTranslationWorkflowsTest extends EntityTranslationTestBase { +class ContentTranslationWorkflowsTest extends ContentTranslationTestBase { /** * The entity used for testing. @@ -27,13 +27,13 @@ class EntityTranslationWorkflowsTest extends EntityTranslationTestBase { * * @var array */ - public static $modules = array('language', 'translation_entity', 'entity_test'); + public static $modules = array('language', 'content_translation', 'entity_test'); public static function getInfo() { return array( 'name' => 'Entity Test translation workflows', - 'description' => 'Tests the entity translation workflows for the test entity.', - 'group' => 'Entity Translation UI', + 'description' => 'Tests the content translation workflows for the test entity.', + 'group' => 'Content Translation UI', ); } @@ -43,7 +43,7 @@ function setUp() { } /** - * Overrides \Drupal\translation_entity\Tests\EntityTranslationTestBase::getEditorPermissions(). + * Overrides \Drupal\content_translation\Tests\ContentTranslationTestBase::getEditorPermissions(). */ protected function getEditorPermissions() { return array('administer entity_test content'); @@ -91,7 +91,7 @@ function testWorkflows() { $ops = array('create' => t('Add'), 'update' => t('Edit'), 'delete' => t('Delete')); $translations_path = $this->controller->getBasePath($this->entity) . "/translations"; foreach ($ops as $current_op => $label) { - $user = $this->drupalCreateUser(array($this->getTranslatePermission(), "$current_op entity translations")); + $user = $this->drupalCreateUser(array($this->getTranslatePermission(), "$current_op content translations")); $this->drupalLogin($user); $this->drupalGet($translations_path); diff --git a/core/modules/translation_entity/lib/Drupal/translation_entity/Tests/Views/TranslationEntityViewsUITest.php b/core/modules/content_translation/lib/Drupal/content_translation/Tests/Views/ContentTranslationViewsUITest.php similarity index 62% rename from core/modules/translation_entity/lib/Drupal/translation_entity/Tests/Views/TranslationEntityViewsUITest.php rename to core/modules/content_translation/lib/Drupal/content_translation/Tests/Views/ContentTranslationViewsUITest.php index ab1f4ef..5dbe880 100644 --- a/core/modules/translation_entity/lib/Drupal/translation_entity/Tests/Views/TranslationEntityViewsUITest.php +++ b/core/modules/content_translation/lib/Drupal/content_translation/Tests/Views/ContentTranslationViewsUITest.php @@ -2,17 +2,17 @@ /** * @file - * Contains \Drupal\translation_entity\Tests\Views\TranslationEntityViewsUITest. + * Contains \Drupal\content_translation\Tests\Views\ContentTranslationViewsUITest. */ -namespace Drupal\translation_entity\Tests\Views; +namespace Drupal\content_translation\Tests\Views; use Drupal\views_ui\Tests\UITestBase; /** - * Tests the views UI when translation_entity is enabled. + * Tests the views UI when content_translation is enabled. */ -class TranslationEntityViewsUITest extends UITestBase { +class ContentTranslationViewsUITest extends UITestBase { /** * Views used by this test. @@ -26,12 +26,12 @@ class TranslationEntityViewsUITest extends UITestBase { * * @var array */ - public static $modules = array('translation_entity'); + public static $modules = array('content_translation'); public static function getInfo() { return array( - 'name' => 'Entity Translation: Views UI', - 'description' => 'Tests the views UI when entity translation is enabled.', + 'name' => 'Content Translation: Views UI', + 'description' => 'Tests the views UI when content translation is enabled.', 'group' => 'Views module integration', ); } diff --git a/core/modules/content_translation/lib/Drupal/content_translation/Tests/Views/TranslationLinkTest.php b/core/modules/content_translation/lib/Drupal/content_translation/Tests/Views/TranslationLinkTest.php new file mode 100644 index 0000000..1f5e457 --- /dev/null +++ b/core/modules/content_translation/lib/Drupal/content_translation/Tests/Views/TranslationLinkTest.php @@ -0,0 +1,61 @@ + 'Content Translation: Link field', + 'description' => 'Tests the content translation overview link field handler.', + 'group' => 'Views module integration', + ); + } + + function setUp() { + // @todo Use entity_type once it is has multilingual Views integration. + $this->entityType = 'user'; + + parent::setUp(); + + ViewTestData::importTestViews(get_class($this), array('content_translation_test_views')); + } + + /** + * Tests the content translation overview link field handler. + */ + public function testTranslationLink() { + $this->drupalGet('test-entity-translations-link'); + $this->assertLinkByHref('user/1/translations'); + $this->assertNoLinkByHref('user/2/translations', 'The translations link is not present when content_translation_translate_access() is FALSE.'); + } + +} diff --git a/core/modules/content_translation/tests/modules/content_translation_test_views/content_translation_test_views.info.yml b/core/modules/content_translation/tests/modules/content_translation_test_views/content_translation_test_views.info.yml new file mode 100644 index 0000000..9e261db --- /dev/null +++ b/core/modules/content_translation/tests/modules/content_translation_test_views/content_translation_test_views.info.yml @@ -0,0 +1,10 @@ +name: 'Content translation test views' +type: module +description: 'Provides default views for views content translation tests.' +package: Testing +version: VERSION +core: 8.x +dependencies: + - content_translation + - views +hidden: true diff --git a/core/modules/translation_entity/tests/modules/translation_entity_test_views/translation_entity_test_views.module b/core/modules/content_translation/tests/modules/content_translation_test_views/content_translation_test_views.module similarity index 100% rename from core/modules/translation_entity/tests/modules/translation_entity_test_views/translation_entity_test_views.module rename to core/modules/content_translation/tests/modules/content_translation_test_views/content_translation_test_views.module diff --git a/core/modules/translation_entity/tests/modules/translation_entity_test_views/test_views/views.view.test_entity_translations_link.yml b/core/modules/content_translation/tests/modules/content_translation_test_views/test_views/views.view.test_entity_translations_link.yml similarity index 97% rename from core/modules/translation_entity/tests/modules/translation_entity_test_views/test_views/views.view.test_entity_translations_link.yml rename to core/modules/content_translation/tests/modules/content_translation_test_views/test_views/views.view.test_entity_translations_link.yml index 30f98a3..ac1f7a2 100644 --- a/core/modules/translation_entity/tests/modules/translation_entity_test_views/test_views/views.view.test_entity_translations_link.yml +++ b/core/modules/content_translation/tests/modules/content_translation_test_views/test_views/views.view.test_entity_translations_link.yml @@ -59,7 +59,7 @@ display: empty_zero: '0' hide_alter_empty: '1' text: Translate - plugin_id: translation_entity_link + plugin_id: content_translation_link filters: uid_raw: id: uid_raw diff --git a/core/modules/menu/lib/Drupal/menu/MenuFormController.php b/core/modules/menu/lib/Drupal/menu/MenuFormController.php index d5b8106..62a92ff 100644 --- a/core/modules/menu/lib/Drupal/menu/MenuFormController.php +++ b/core/modules/menu/lib/Drupal/menu/MenuFormController.php @@ -143,8 +143,8 @@ protected function actions(array $form, array &$form_state) { // We cannot leverage the regular submit handler definition because we have // button-specific ones here. Hence we need to explicitly set it for the // submit action, otherwise it would be ignored. - if ($this->moduleHandler->moduleExists('translation_entity')) { - array_unshift($actions['submit']['#submit'], 'translation_entity_language_configuration_element_submit'); + if ($this->moduleHandler->moduleExists('content_translation')) { + array_unshift($actions['submit']['#submit'], 'content_translation_language_configuration_element_submit'); } return $actions; } diff --git a/core/modules/node/config/views.view.content.yml b/core/modules/node/config/views.view.content.yml index ff4b5ee..ec0856b 100644 --- a/core/modules/node/config/views.view.content.yml +++ b/core/modules/node/config/views.view.content.yml @@ -230,7 +230,7 @@ display: empty: '' text: Translate optional: '1' - plugin_id: translation_entity_link + plugin_id: content_translation_link dropbutton: id: dropbutton table: views diff --git a/core/modules/node/lib/Drupal/node/NodeTranslationController.php b/core/modules/node/lib/Drupal/node/NodeTranslationController.php index 4531a8e..1109724 100644 --- a/core/modules/node/lib/Drupal/node/NodeTranslationController.php +++ b/core/modules/node/lib/Drupal/node/NodeTranslationController.php @@ -8,29 +8,29 @@ namespace Drupal\node; use Drupal\Core\Entity\EntityInterface; -use Drupal\translation_entity\EntityTranslationController; +use Drupal\content_translation\ContentTranslationController; /** * Defines the translation controller class for nodes. */ -class NodeTranslationController extends EntityTranslationController { +class NodeTranslationController extends ContentTranslationController { /** - * Overrides EntityTranslationController::getAccess(). + * Overrides ContentTranslationController::getAccess(). */ public function getAccess(EntityInterface $entity, $op) { return node_access($op, $entity); } /** - * Overrides EntityTranslationController::entityFormAlter(). + * Overrides ContentTranslationController::entityFormAlter(). */ public function entityFormAlter(array &$form, array &$form_state, EntityInterface $entity) { parent::entityFormAlter($form, $form_state, $entity); // Move the translation fieldset to a vertical tab. - if (isset($form['translation_entity'])) { - $form['translation_entity'] += array( + if (isset($form['content_translation'])) { + $form['content_translation'] += array( '#group' => 'additional_settings', '#weight' => 100, '#attributes' => array( @@ -40,14 +40,14 @@ public function entityFormAlter(array &$form, array &$form_state, EntityInterfac // We do not need to show these values on node forms: they inherit the // basic node property values. - $form['translation_entity']['status']['#access'] = FALSE; - $form['translation_entity']['name']['#access'] = FALSE; - $form['translation_entity']['created']['#access'] = FALSE; + $form['content_translation']['status']['#access'] = FALSE; + $form['content_translation']['name']['#access'] = FALSE; + $form['content_translation']['created']['#access'] = FALSE; } } /** - * Overrides EntityTranslationController::entityFormTitle(). + * Overrides ContentTranslationController::entityFormTitle(). */ protected function entityFormTitle(EntityInterface $entity) { $type_name = node_get_type_label($entity); @@ -55,12 +55,12 @@ protected function entityFormTitle(EntityInterface $entity) { } /** - * Overrides EntityTranslationController::entityFormEntityBuild(). + * Overrides ContentTranslationController::entityFormEntityBuild(). */ public function entityFormEntityBuild($entity_type, EntityInterface $entity, array $form, array &$form_state) { - if (isset($form_state['values']['translation_entity'])) { - $form_controller = translation_entity_form_controller($form_state); - $translation = &$form_state['values']['translation_entity']; + if (isset($form_state['values']['content_translation'])) { + $form_controller = content_translation_form_controller($form_state); + $translation = &$form_state['values']['content_translation']; $translation['status'] = $form_controller->getEntity()->status; $translation['name'] = $form_state['values']['name']; $translation['created'] = $form_state['values']['date']; diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeTranslationUITest.php b/core/modules/node/lib/Drupal/node/Tests/NodeTranslationUITest.php index 9344355..bea3245 100644 --- a/core/modules/node/lib/Drupal/node/Tests/NodeTranslationUITest.php +++ b/core/modules/node/lib/Drupal/node/Tests/NodeTranslationUITest.php @@ -8,12 +8,12 @@ namespace Drupal\node\Tests; use Drupal\Core\Entity\EntityInterface; -use Drupal\translation_entity\Tests\EntityTranslationUITest; +use Drupal\content_translation\Tests\ContentTranslationUITest; /** * Tests the Node Translation UI. */ -class NodeTranslationUITest extends EntityTranslationUITest { +class NodeTranslationUITest extends ContentTranslationUITest { /** * The title of the test node. @@ -25,7 +25,7 @@ class NodeTranslationUITest extends EntityTranslationUITest { * * @var array */ - public static $modules = array('language', 'translation_entity', 'node', 'datetime', 'field_ui'); + public static $modules = array('language', 'content_translation', 'node', 'datetime', 'field_ui'); public static function getInfo() { return array( @@ -43,7 +43,7 @@ function setUp() { } /** - * Overrides \Drupal\translation_entity\Tests\EntityTranslationUITest::setupBundle(). + * Overrides \Drupal\content_translation\Tests\ContentTranslationUITest::setupBundle(). */ protected function setupBundle() { parent::setupBundle(); @@ -51,14 +51,14 @@ protected function setupBundle() { } /** - * Overrides \Drupal\translation_entity\Tests\EntityTranslationUITest::getTranslatorPermission(). + * Overrides \Drupal\content_translation\Tests\ContentTranslationUITest::getTranslatorPermission(). */ protected function getTranslatorPermissions() { return array_merge(parent::getTranslatorPermissions(), array('administer nodes', "edit any $this->bundle content")); } /** - * Overrides \Drupal\translation_entity\Tests\EntityTranslationUITest::getNewEntityValues(). + * Overrides \Drupal\content_translation\Tests\ContentTranslationUITest::getNewEntityValues(). */ protected function getNewEntityValues($langcode) { // Node title is not translatable yet, hence we use a fixed value. @@ -66,7 +66,7 @@ protected function getNewEntityValues($langcode) { } /** - * Overrides \Drupal\translation_entity\Tests\EntityTranslationUITest::getFormSubmitAction(). + * Overrides \Drupal\content_translation\Tests\ContentTranslationUITest::getFormSubmitAction(). */ protected function getFormSubmitAction(EntityInterface $entity) { if ($entity->status) { @@ -76,7 +76,7 @@ protected function getFormSubmitAction(EntityInterface $entity) { } /** - * Overrides \Drupal\translation_entity\Tests\EntityTranslationUITest::assertPublishedStatus(). + * Overrides \Drupal\content_translation\Tests\ContentTranslationUITest::assertPublishedStatus(). */ protected function assertPublishedStatus() { $entity = entity_load($this->entityType, $this->entityId, TRUE); @@ -108,7 +108,7 @@ protected function assertPublishedStatus() { } /** - * Overrides \Drupal\translation_entity\Tests\EntityTranslationUITest::assertAuthoringInfo(). + * Overrides \Drupal\content_translation\Tests\ContentTranslationUITest::assertAuthoringInfo(). */ protected function assertAuthoringInfo() { $entity = entity_load($this->entityType, $this->entityId, TRUE); @@ -189,8 +189,8 @@ public function testDisabledBundle() { $disabledNode = $this->drupalCreateNode(array('type' => $disabledBundle)); // Make sure that only a single row was inserted into the - // {translation_entity} table. - $rows = db_query('SELECT * FROM {translation_entity}')->fetchAll(); + // {content_translation} table. + $rows = db_query('SELECT * FROM {content_translation}')->fetchAll(); $this->assertEqual(1, count($rows)); $this->assertEqual($enabledNode->id(), reset($rows)->entity_id); } diff --git a/core/modules/node/node.views.inc b/core/modules/node/node.views.inc index b4b34eb..d1c027a 100644 --- a/core/modules/node/node.views.inc +++ b/core/modules/node/node.views.inc @@ -217,12 +217,12 @@ function node_views_data() { ); } - if (Drupal::moduleHandler()->moduleExists('translation_entity')) { + if (Drupal::moduleHandler()->moduleExists('content_translation')) { $data['node']['translation_link'] = array( 'title' => t('Translation link'), 'help' => t('Provide a link to the translations overview for nodes.'), 'field' => array( - 'id' => 'translation_entity_link', + 'id' => 'content_translation_link', ), ); } diff --git a/core/modules/system/lib/Drupal/system/Tests/Module/DependencyTest.php b/core/modules/system/lib/Drupal/system/Tests/Module/DependencyTest.php index 96955cd..0143d1a 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Module/DependencyTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Module/DependencyTest.php @@ -20,16 +20,16 @@ public static function getInfo() { } /** - * Attempts to enable the Entity Translation module without Language enabled. + * Attempts to enable the Content Translation module without Language enabled. */ function testEnableWithoutDependency() { - // Attempt to enable Entity Translation without Language enabled. + // Attempt to enable Content Translation without Language enabled. $edit = array(); - $edit['modules[Multilingual][translation_entity][enable]'] = 'translation_entity'; + $edit['modules[Multilingual][content_translation][enable]'] = 'content_translation'; $this->drupalPost('admin/modules', $edit, t('Save configuration')); $this->assertText(t('Some required modules must be enabled'), 'Dependency required.'); - $this->assertModules(array('translation_entity', 'language'), FALSE); + $this->assertModules(array('content_translation', 'language'), FALSE); // Assert that the language tables weren't enabled. $this->assertTableCount('language', FALSE); @@ -37,7 +37,7 @@ function testEnableWithoutDependency() { $this->drupalPost(NULL, NULL, t('Continue')); $this->assertText(t('The configuration options have been saved.'), 'Modules status has been updated.'); - $this->assertModules(array('translation_entity', 'language'), TRUE); + $this->assertModules(array('content_translation', 'language'), TRUE); // Assert that the language tables were enabled. $this->assertTableCount('language', TRUE); diff --git a/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/Plugin/Core/Entity/EntityTest.php b/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/Plugin/Core/Entity/EntityTest.php index 25167c7..6ce0c1b 100644 --- a/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/Plugin/Core/Entity/EntityTest.php +++ b/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/Plugin/Core/Entity/EntityTest.php @@ -25,7 +25,7 @@ * "form" = { * "default" = "Drupal\entity_test\EntityTestFormController" * }, - * "translation" = "Drupal\translation_entity\EntityTranslationControllerNG" + * "translation" = "Drupal\content_translation\ContentTranslationControllerNG" * }, * base_table = "entity_test", * fieldable = TRUE, diff --git a/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/Plugin/Core/Entity/EntityTestMul.php b/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/Plugin/Core/Entity/EntityTestMul.php index d39f915..99455a5 100644 --- a/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/Plugin/Core/Entity/EntityTestMul.php +++ b/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/Plugin/Core/Entity/EntityTestMul.php @@ -24,7 +24,7 @@ * "form" = { * "default" = "Drupal\entity_test\EntityTestFormController" * }, - * "translation" = "Drupal\translation_entity\EntityTranslationControllerNG" + * "translation" = "Drupal\content_translation\ContentTranslationControllerNG" * }, * base_table = "entity_test_mul", * data_table = "entity_test_mul_property_data", diff --git a/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/Plugin/Core/Entity/EntityTestMulRev.php b/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/Plugin/Core/Entity/EntityTestMulRev.php index aa5fcd9..b0bd877 100644 --- a/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/Plugin/Core/Entity/EntityTestMulRev.php +++ b/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/Plugin/Core/Entity/EntityTestMulRev.php @@ -24,7 +24,7 @@ * "form" = { * "default" = "Drupal\entity_test\EntityTestFormController" * }, - * "translation" = "Drupal\translation_entity\EntityTranslationControllerNG" + * "translation" = "Drupal\content_translation\ContentTranslationControllerNG" * }, * base_table = "entity_test_mulrev", * data_table = "entity_test_mulrev_property_data", diff --git a/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/Plugin/Core/Entity/EntityTestRev.php b/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/Plugin/Core/Entity/EntityTestRev.php index d3984ea..6209cf5 100644 --- a/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/Plugin/Core/Entity/EntityTestRev.php +++ b/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/Plugin/Core/Entity/EntityTestRev.php @@ -24,7 +24,7 @@ * "form" = { * "default" = "Drupal\entity_test\EntityTestFormController" * }, - * "translation" = "Drupal\translation_entity\EntityTranslationControllerNG" + * "translation" = "Drupal\content_translation\ContentTranslationControllerNG" * }, * base_table = "entity_test_rev", * revision_table = "entity_test_rev_revision", diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/TermTranslationController.php b/core/modules/taxonomy/lib/Drupal/taxonomy/TermTranslationController.php index eaf0dbf..3b50d17 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/TermTranslationController.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/TermTranslationController.php @@ -8,15 +8,15 @@ namespace Drupal\taxonomy; use Drupal\Core\Entity\EntityInterface; -use Drupal\translation_entity\EntityTranslationControllerNG; +use Drupal\content_translation\ContentTranslationControllerNG; /** * Defines the translation controller class for terms. */ -class TermTranslationController extends EntityTranslationControllerNG { +class TermTranslationController extends ContentTranslationControllerNG { /** - * Overrides EntityTranslationController::entityFormAlter(). + * Overrides ContentTranslationController::entityFormAlter(). */ public function entityFormAlter(array &$form, array &$form_state, EntityInterface $entity) { parent::entityFormAlter($form, $form_state, $entity); @@ -32,7 +32,7 @@ public function entityFormAlter(array &$form, array &$form_state, EntityInterfac */ function entityFormSave(array $form, array &$form_state) { if ($this->getSourceLangcode($form_state)) { - $entity = translation_entity_form_controller($form_state)->getEntity(); + $entity = content_translation_form_controller($form_state)->getEntity(); // We need a redirect here, otherwise we would get an access denied page, // since the current URL would be preserved and we would try to add a // translation for a language that already has a translation. diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermTranslationUITest.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermTranslationUITest.php index 15e0ccb..20f6988 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermTranslationUITest.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermTranslationUITest.php @@ -8,12 +8,12 @@ namespace Drupal\taxonomy\Tests; use Drupal\Core\Language\Language; -use Drupal\translation_entity\Tests\EntityTranslationUITest; +use Drupal\content_translation\Tests\ContentTranslationUITest; /** * Tests the Term Translation UI. */ -class TermTranslationUITest extends EntityTranslationUITest { +class TermTranslationUITest extends ContentTranslationUITest { /** * The name of the test taxonomy term. @@ -32,7 +32,7 @@ class TermTranslationUITest extends EntityTranslationUITest { * * @var array */ - public static $modules = array('language', 'translation_entity', 'taxonomy'); + public static $modules = array('language', 'content_translation', 'taxonomy'); public static function getInfo() { return array( @@ -50,7 +50,7 @@ function setUp() { } /** - * Overrides \Drupal\translation_entity\Tests\EntityTranslationUITest::setupBundle(). + * Overrides \Drupal\content_translation\Tests\ContentTranslationUITest::setupBundle(). */ protected function setupBundle() { parent::setupBundle(); @@ -67,14 +67,14 @@ protected function setupBundle() { } /** - * Overrides \Drupal\translation_entity\Tests\EntityTranslationUITest::getTranslatorPermission(). + * Overrides \Drupal\content_translation\Tests\ContentTranslationUITest::getTranslatorPermission(). */ protected function getTranslatorPermissions() { return array_merge(parent::getTranslatorPermissions(), array('administer taxonomy')); } /** - * Overrides \Drupal\translation_entity\Tests\EntityTranslationUITest::getNewEntityValues(). + * Overrides \Drupal\content_translation\Tests\ContentTranslationUITest::getNewEntityValues(). */ protected function getNewEntityValues($langcode) { // Term name is not translatable hence we use a fixed value. @@ -82,14 +82,14 @@ protected function getNewEntityValues($langcode) { } /** - * Overrides \Drupal\translation_entity\Tests\EntityTranslationUITest::testTranslationUI(). + * Overrides \Drupal\content_translation\Tests\ContentTranslationUITest::testTranslationUI(). */ public function testTranslationUI() { parent::testTranslationUI(); // Make sure that no row was inserted for taxonomy vocabularies, which do // not have translations enabled. - $rows = db_query('SELECT * FROM {translation_entity}')->fetchAll(); + $rows = db_query('SELECT * FROM {content_translation}')->fetchAll(); $this->assertEqual(2, count($rows)); $this->assertEqual('taxonomy_term', $rows[0]->entity_type); $this->assertEqual('taxonomy_term', $rows[1]->entity_type); diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/VocabularyFormController.php b/core/modules/taxonomy/lib/Drupal/taxonomy/VocabularyFormController.php index f6d7f42..db8c145 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/VocabularyFormController.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/VocabularyFormController.php @@ -98,8 +98,8 @@ protected function actions(array $form, array &$form_state) { // We cannot leverage the regular submit handler definition because we // have button-specific ones here. Hence we need to explicitly set it for // the submit action, otherwise it would be ignored. - if (module_exists('translation_entity')) { - array_unshift($actions['submit']['#submit'], 'translation_entity_language_configuration_element_submit'); + if (module_exists('content_translation')) { + array_unshift($actions['submit']['#submit'], 'content_translation_language_configuration_element_submit'); } return $actions; } diff --git a/core/modules/taxonomy/taxonomy.admin.inc b/core/modules/taxonomy/taxonomy.admin.inc index 24b71f9..e8bd8e0 100644 --- a/core/modules/taxonomy/taxonomy.admin.inc +++ b/core/modules/taxonomy/taxonomy.admin.inc @@ -215,7 +215,7 @@ function taxonomy_overview_terms($form, &$form_state, Vocabulary $vocabulary) { 'query' => $destination, ), ); - if (module_invoke('translation_entity', 'translate_access', $term)) { + if (module_invoke('content_translation', 'translate_access', $term)) { $operations['translate'] = array( 'title' => t('translate'), 'href' => 'taxonomy/term/' . $term->id() . '/translations', diff --git a/core/modules/taxonomy/taxonomy.views.inc b/core/modules/taxonomy/taxonomy.views.inc index 876c6c8..5646268 100644 --- a/core/modules/taxonomy/taxonomy.views.inc +++ b/core/modules/taxonomy/taxonomy.views.inc @@ -176,13 +176,13 @@ function taxonomy_views_data() { ), ); - // Entity translation field. - if (Drupal::moduleHandler()->moduleExists('translation_entity')) { + // Content translation field. + if (Drupal::moduleHandler()->moduleExists('content_translation')) { $data['taxonomy_term_data']['translation_link'] = array( 'title' => t('Translation link'), 'help' => t('Provide a link to the translations overview for taxonomy terms.'), 'field' => array( - 'id' => 'translation_entity_link', + 'id' => 'content_translation_link', ), ); } diff --git a/core/modules/translation_entity/lib/Drupal/translation_entity/Tests/Views/TranslationLinkTest.php b/core/modules/translation_entity/lib/Drupal/translation_entity/Tests/Views/TranslationLinkTest.php deleted file mode 100644 index 7c9788e..0000000 --- a/core/modules/translation_entity/lib/Drupal/translation_entity/Tests/Views/TranslationLinkTest.php +++ /dev/null @@ -1,61 +0,0 @@ - 'Entity Translation: Link field', - 'description' => 'Tests the Entity translation overview link field handler.', - 'group' => 'Views module integration', - ); - } - - function setUp() { - // @todo Use entity_type once it is has multilingual Views integration. - $this->entityType = 'user'; - - parent::setUp(); - - ViewTestData::importTestViews(get_class($this), array('translation_entity_test_views')); - } - - /** - * Tests the Entity translation overview link field handler. - */ - public function testTranslationLink() { - $this->drupalGet('test-entity-translations-link'); - $this->assertLinkByHref('user/1/translations'); - $this->assertNoLinkByHref('user/2/translations', 'The translations link is not present when translation_entity_translate_access() is FALSE.'); - } - -} diff --git a/core/modules/translation_entity/tests/modules/translation_entity_test_views/translation_entity_test_views.info.yml b/core/modules/translation_entity/tests/modules/translation_entity_test_views/translation_entity_test_views.info.yml deleted file mode 100644 index 623f484..0000000 --- a/core/modules/translation_entity/tests/modules/translation_entity_test_views/translation_entity_test_views.info.yml +++ /dev/null @@ -1,10 +0,0 @@ -name: 'Entity translation test views' -type: module -description: 'Provides default views for views entity translation tests.' -package: Testing -version: VERSION -core: 8.x -dependencies: - - translation_entity - - views -hidden: true diff --git a/core/modules/translation_entity/translation_entity.services.yml b/core/modules/translation_entity/translation_entity.services.yml deleted file mode 100644 index 541bd3d..0000000 --- a/core/modules/translation_entity/translation_entity.services.yml +++ /dev/null @@ -1,4 +0,0 @@ -services: - translation_entity.synchronizer: - class: Drupal\translation_entity\FieldTranslationSynchronizer - arguments: ['@plugin.manager.entity'] diff --git a/core/modules/user/config/views.view.user_admin_people.yml b/core/modules/user/config/views.view.user_admin_people.yml index 90c17e1..6a08227 100644 --- a/core/modules/user/config/views.view.user_admin_people.yml +++ b/core/modules/user/config/views.view.user_admin_people.yml @@ -548,7 +548,7 @@ display: hide_alter_empty: '1' text: Translate optional: '1' - plugin_id: translation_entity_link + plugin_id: content_translation_link dropbutton: id: dropbutton table: views diff --git a/core/modules/user/lib/Drupal/user/AccountSettingsForm.php b/core/modules/user/lib/Drupal/user/AccountSettingsForm.php index 5c8880b..c43dc6d 100644 --- a/core/modules/user/lib/Drupal/user/AccountSettingsForm.php +++ b/core/modules/user/lib/Drupal/user/AccountSettingsForm.php @@ -98,14 +98,14 @@ public function buildForm(array $form, array &$form_state) { ); // @todo Remove this check once language settings are generalized. - if ($this->moduleHandler->moduleExists('translation_entity')) { + if ($this->moduleHandler->moduleExists('content_translation')) { $form['language'] = array( '#type' => 'details', '#title' => t('Language settings'), '#tree' => TRUE, ); - $form_state['translation_entity']['key'] = 'language'; - $form['language'] += translation_entity_enable_widget('user', 'user', $form, $form_state); + $form_state['content_translation']['key'] = 'language'; + $form['language'] += content_translation_enable_widget('user', 'user', $form, $form_state); } // User registration settings. diff --git a/core/modules/user/lib/Drupal/user/ProfileTranslationController.php b/core/modules/user/lib/Drupal/user/ProfileTranslationController.php index c1b2414..5cb9cc8 100644 --- a/core/modules/user/lib/Drupal/user/ProfileTranslationController.php +++ b/core/modules/user/lib/Drupal/user/ProfileTranslationController.php @@ -8,15 +8,15 @@ namespace Drupal\user; use Drupal\Core\Entity\EntityInterface; -use Drupal\translation_entity\EntityTranslationController; +use Drupal\content_translation\ContentTranslationController; /** * Defines the translation controller class for terms. */ -class ProfileTranslationController extends EntityTranslationController { +class ProfileTranslationController extends ContentTranslationController { /** - * Overrides EntityTranslationController::entityFormAlter(). + * Overrides ContentTranslationController::entityFormAlter(). */ public function entityFormAlter(array &$form, array &$form_state, EntityInterface $entity) { parent::entityFormAlter($form, $form_state, $entity); @@ -32,7 +32,7 @@ public function entityFormAlter(array &$form, array &$form_state, EntityInterfac */ function entityFormSave(array $form, array &$form_state) { if ($this->getSourceLangcode($form_state)) { - $entity = translation_entity_form_controller($form_state)->getEntity(); + $entity = content_translation_form_controller($form_state)->getEntity(); // We need a redirect here, otherwise we would get an access denied page // since the current URL would be preserved and we would try to add a // translation for a language that already has a translation. diff --git a/core/modules/user/lib/Drupal/user/Tests/UserTranslationUITest.php b/core/modules/user/lib/Drupal/user/Tests/UserTranslationUITest.php index d92754e..0b7883f 100644 --- a/core/modules/user/lib/Drupal/user/Tests/UserTranslationUITest.php +++ b/core/modules/user/lib/Drupal/user/Tests/UserTranslationUITest.php @@ -7,12 +7,12 @@ namespace Drupal\user\Tests; -use Drupal\translation_entity\Tests\EntityTranslationUITest; +use Drupal\content_translation\Tests\ContentTranslationUITest; /** * Tests the User Translation UI. */ -class UserTranslationUITest extends EntityTranslationUITest { +class UserTranslationUITest extends ContentTranslationUITest { /** * The user name of the test user. @@ -24,7 +24,7 @@ class UserTranslationUITest extends EntityTranslationUITest { * * @var array */ - public static $modules = array('language', 'translation_entity', 'user', 'views'); + public static $modules = array('language', 'content_translation', 'user', 'views'); public static function getInfo() { return array( @@ -44,14 +44,14 @@ function setUp() { } /** - * Overrides \Drupal\translation_entity\Tests\EntityTranslationUITest::getTranslatorPermission(). + * Overrides \Drupal\content_translation\Tests\ContentTranslationUITest::getTranslatorPermission(). */ protected function getTranslatorPermissions() { return array_merge(parent::getTranslatorPermissions(), array('administer users')); } /** - * Overrides \Drupal\translation_entity\Tests\EntityTranslationUITest::getNewEntityValues(). + * Overrides \Drupal\content_translation\Tests\ContentTranslationUITest::getNewEntityValues(). */ protected function getNewEntityValues($langcode) { // User name is not translatable hence we use a fixed value. diff --git a/core/modules/user/user.admin.inc b/core/modules/user/user.admin.inc index c406b10..02a0b08 100644 --- a/core/modules/user/user.admin.inc +++ b/core/modules/user/user.admin.inc @@ -68,7 +68,7 @@ function user_admin_account() { 'href' => 'user/' . $account->uid . '/edit', 'query' => $destination, ); - if (module_invoke('translation_entity', 'translate_access', $account)) { + if (module_invoke('content_translation', 'translate_access', $account)) { $links['translate'] = array( 'title' => t('Translate'), 'href' => 'user/' . $account->uid . '/translations', diff --git a/core/modules/user/user.views.inc b/core/modules/user/user.views.inc index 83474b0..f9b35ca 100644 --- a/core/modules/user/user.views.inc +++ b/core/modules/user/user.views.inc @@ -281,12 +281,12 @@ function user_views_data() { ), ); - if (Drupal::moduleHandler()->moduleExists('translation_entity')) { + if (Drupal::moduleHandler()->moduleExists('content_translation')) { $data['users']['translation_link'] = array( 'title' => t('Translation link'), 'help' => t('Provide a link to the translations overview for users.'), 'field' => array( - 'id' => 'translation_entity_link', + 'id' => 'content_translation_link', ), ); }