diff --git a/core/modules/path/lib/Drupal/path/Tests/PathLanguageTest.php b/core/modules/path/lib/Drupal/path/Tests/PathLanguageTest.php index 9e94728..e321bb2 100644 --- a/core/modules/path/lib/Drupal/path/Tests/PathLanguageTest.php +++ b/core/modules/path/lib/Drupal/path/Tests/PathLanguageTest.php @@ -17,7 +17,7 @@ class PathLanguageTest extends PathTestBase { * * @var array */ - public static $modules = array('path', 'locale', 'translation'); + public static $modules = array('path', 'locale', 'content_translation'); public static function getInfo() { return array( @@ -30,8 +30,20 @@ public static function getInfo() { function setUp() { parent::setUp(); + $permissions = array( + 'edit any page content', + 'create page content', + 'administer url aliases', + 'create url aliases', + 'administer languages', + 'access administration pages', + 'administer content types', + 'create content translations', + 'administer content translation', + 'translate any entity' + ); // Create and login user. - $this->web_user = $this->drupalCreateUser(array('edit any page content', 'create page content', 'administer url aliases', 'create url aliases', 'administer languages', 'translate all content', 'access administration pages', 'administer content types')); + $this->web_user = $this->drupalCreateUser($permissions); $this->drupalLogin($this->web_user); // Enable French language. @@ -43,6 +55,11 @@ function setUp() { // Enable URL language detection and selection. $edit = array('language_interface[enabled][language-url]' => 1); $this->drupalPostForm('admin/config/regional/language/detection', $edit, t('Save settings')); + + // Enable translation for page node. + $edit = array('entity_types[node]' => 1, 'settings[node][page][translatable]' => 1, 'settings[node][page][fields][body]' => 1, 'settings[node][page][settings][language][language_show]' => 1); + $this->drupalPostForm('admin/config/regional/content-language', $edit, t('Save')); + } /** @@ -57,12 +74,11 @@ function testAliasTranslation() { $this->assertRaw(t('The content type %type has been updated.', array('%type' => 'Basic page')), 'Basic page content type has been updated.'); variable_set('node_type_language_translation_enabled_page', TRUE); - $english_node = $this->drupalCreateNode(array('type' => 'page')); + $english_node = $this->drupalCreateNode(array('type' => 'page', 'langcode' => 'en')); $english_alias = $this->randomName(); // Edit the node to set language and path. $edit = array(); - $edit['langcode'] = 'en'; $edit['path[alias]'] = $english_alias; $this->drupalPostForm('node/' . $english_node->id() . '/edit', $edit, t('Save')); @@ -71,8 +87,9 @@ function testAliasTranslation() { $this->assertText($english_node->label(), 'Alias works.'); // Translate the node into French. - $this->drupalGet('node/' . $english_node->id() . '/translate'); - $this->clickLink(t('Add translation')); + $this->drupalGet('node/' . $english_node->id() . '/translations'); + $this->clickLink(t('Add')); + $edit = array(); $edit['title'] = $this->randomName(); $edit['body[0][value]'] = $this->randomName(); @@ -89,7 +106,8 @@ function testAliasTranslation() { $languages = language_list(); // Ensure the node was created. - $french_node = $this->drupalGetNodeByTitle($edit["title"]); + $french_node = $english_node->getTranslation('fr'); + $this->assertTrue(($french_node), 'Node found in database.'); // Confirm that the alias works. @@ -97,7 +115,7 @@ function testAliasTranslation() { $this->assertText($french_node->label(), 'Alias for French translation works.'); // Confirm that the alias is returned by url(). - $url = $this->container->get('url_generator')->generateFromPath('node/' . $french_node->id(), array('language' => $languages[$french_node->language()->id])); + $url = $this->container->get('url_generator')->generateFromPath('node/' . $french_node->id(), array('language' => $languages['fr'])); $this->assertTrue(strpos($url, $edit['path[alias]']), 'URL contains the path alias.'); @@ -148,17 +166,17 @@ function testAliasTranslation() { // The alias manager has an internal path lookup cache. Check to see that // it has the appropriate contents at this point. $this->container->get('path.alias_manager')->cacheClear(); - $french_node_path = $this->container->get('path.alias_manager')->getSystemPath($french_alias, $french_node->language()->id); + $french_node_path = $this->container->get('path.alias_manager')->getSystemPath($french_alias, 'fr'); $this->assertEqual($french_node_path, 'node/' . $french_node->id(), 'Normal path works.'); // Second call should return the same path. - $french_node_path = $this->container->get('path.alias_manager')->getSystemPath($french_alias, $french_node->language()->id); + $french_node_path = $this->container->get('path.alias_manager')->getSystemPath($french_alias, 'fr'); $this->assertEqual($french_node_path, 'node/' . $french_node->id(), 'Normal path is the same.'); // Confirm that the alias works. - $french_node_alias = $this->container->get('path.alias_manager')->getPathAlias('node/' . $french_node->id(), $french_node->language()->id); + $french_node_alias = $this->container->get('path.alias_manager')->getPathAlias('node/' . $french_node->id(), 'fr'); $this->assertEqual($french_node_alias, $french_alias, 'Alias works.'); // Second call should return the same alias. - $french_node_alias = $this->container->get('path.alias_manager')->getPathAlias('node/' . $french_node->id(), $french_node->language()->id); + $french_node_alias = $this->container->get('path.alias_manager')->getPathAlias('node/' . $french_node->id(), 'fr'); $this->assertEqual($french_node_alias, $french_alias, 'Alias is the same.'); } } diff --git a/core/modules/system/lib/Drupal/system/Tests/Upgrade/LanguageUpgradePathTest.php b/core/modules/system/lib/Drupal/system/Tests/Upgrade/LanguageUpgradePathTest.php index 2fba93f6..df27013 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Upgrade/LanguageUpgradePathTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Upgrade/LanguageUpgradePathTest.php @@ -82,18 +82,10 @@ public function testLanguageUpgrade() { // Test that the 'language' property was properly renamed to 'langcode'. $language_none_nid = 50; $spanish_nid = 51; - $translation_source_nid = 52; - $translation_nid = 53; // Check directly for the node langcode. $this->assertEqual(node_load($language_none_nid)->language()->id, Language::LANGCODE_NOT_SPECIFIED, "'language' property was renamed to 'langcode' for Language::LANGCODE_NOT_SPECIFIED node."); $this->assertEqual(node_load($spanish_nid)->language()->id, 'ca', "'language' property was renamed to 'langcode' for Catalan node."); - // Check that the translation table works correctly. - $this->drupalGet("node/$translation_source_nid/translate"); - $this->assertResponse(200, 'The translated node has a proper translation table.'); - $this->assertRaw('English (source)', 'English is the source node of the translation.'); - $this->assertRaw('Chuvash', 'There is a Chuvash translation of the node.'); - $this->assertLinkByHref("node/$translation_nid", 0, 'The translation table links to the Chuvash translation.'); - $this->assertRaw('Catalann/aNot translated', 'There is no Catalan translation of this node.'); + // Check for node content type settings upgrade. $this->drupalGet('node/add/article'); $this->assertField('langcode', 'There is a language selector.'); @@ -201,21 +193,4 @@ public function testLanguageNoPluralsUpgrade() { $this->assertFalse(db_index_exists('locales_target', 'plural'), 'Translations without plurals upgraded.'); } - /** - * Tests upgrading translations permissions. - */ - public function testLanguagePermissionsUpgrade() { - // Insert a permission into the Drupal 7 database before running the - // upgrade. - db_insert('role_permission')->fields(array( - 'rid' => 2, - 'permission' => 'translate content', - 'module' => 'translation', - ))->execute(); - - $this->assertTrue($this->performUpgrade(), 'The upgrade was completed successfully.'); - $this->assertFalse(user_roles(FALSE, 'translate content'), 'No translate content role left in config.'); - // Check that translate content has been renamed to translate all content. - $this->assertTrue(user_roles(FALSE, 'translate all content'), 'Rename role translate content to translate all content was completed successfully.'); - } } diff --git a/core/modules/translation/config/schema/translation.schema.yml b/core/modules/translation/config/schema/translation.schema.yml deleted file mode 100644 index 5f9f75c..0000000 --- a/core/modules/translation/config/schema/translation.schema.yml +++ /dev/null @@ -1,9 +0,0 @@ -# Schema for the configuration files of the translation module. - -translation.settings: - type: mapping - label: 'Translation settings' - mapping: - language_type: - type: string - label: 'Language type' diff --git a/core/modules/translation/config/translation.settings.yml b/core/modules/translation/config/translation.settings.yml deleted file mode 100644 index bf1e79b..0000000 --- a/core/modules/translation/config/translation.settings.yml +++ /dev/null @@ -1 +0,0 @@ -language_type: "language_interface" diff --git a/core/modules/translation/lib/Drupal/translation/Access/TranslationNodeOverviewAccessCheck.php b/core/modules/translation/lib/Drupal/translation/Access/TranslationNodeOverviewAccessCheck.php deleted file mode 100644 index 3b54fe1..0000000 --- a/core/modules/translation/lib/Drupal/translation/Access/TranslationNodeOverviewAccessCheck.php +++ /dev/null @@ -1,38 +0,0 @@ -getRequirement('_access_translation_tab'); - if ($request->attributes->has($key)) { - // @todo Remove _translation_tab_access(). - return _translation_tab_access($request->attributes->get($key)) ? static::ALLOW : static::DENY; - } - return static::DENY; - } - -} diff --git a/core/modules/translation/lib/Drupal/translation/Controller/TranslationController.php b/core/modules/translation/lib/Drupal/translation/Controller/TranslationController.php deleted file mode 100644 index 68911ec..0000000 --- a/core/modules/translation/lib/Drupal/translation/Controller/TranslationController.php +++ /dev/null @@ -1,25 +0,0 @@ - 'Translation functionality', - 'description' => 'Create a basic page with translation, modify the page outdating translation, and update translation.', - 'group' => 'Translation' - ); - } - - function setUp() { - parent::setUp(); - - $this->drupalCreateContentType(array('type' => 'page', 'name' => 'Basic page')); - - // Setup users. - $this->admin_user = $this->drupalCreateUser(array('bypass node access', 'administer nodes', 'administer languages', 'administer content types', 'administer blocks', 'access administration pages', 'translate all content')); - $this->translator = $this->drupalCreateUser(array('create page content', 'edit own page content', 'translate all content')); - $this->limited_translator = $this->drupalCreateUser(array('create page content', 'edit own page content', 'translate own content')); - - $this->drupalLogin($this->admin_user); - - // Add languages. - $this->addLanguage('en'); - $this->addLanguage('es'); - - // Set "Basic page" content type to use multilingual support with - // translation. - $this->drupalGet('admin/structure/types/manage/page'); - $edit = array('language_configuration[language_show]' => TRUE, 'node_type_language_translation_enabled' => TRUE); - $this->drupalPostForm('admin/structure/types/manage/page', $edit, t('Save content type')); - $this->assertRaw(t('The content type %type has been updated.', array('%type' => 'Basic page')), 'Basic page content type has been updated.'); - - // Enable the language switcher block. - $this->drupalPlaceBlock('language_block:language_interface'); - - // Reset static caches in our local language environment. - $this->resetCaches(); - - $this->drupalLogin($this->translator); - } - - /** - * Creates, modifies, and updates a basic page with a translation. - */ - function testContentTranslation() { - // Create Basic page in English. - $node_title = $this->randomName(); - $node_body = $this->randomName(); - $node = $this->createPage($node_title, $node_body, 'en'); - // Unpublish the original node to check that this has no impact on the - // translation overview page, publish it again afterwards. - $this->drupalLogin($this->admin_user); - $this->drupalPostForm('node/' . $node->id() . '/edit', array(), t('Save and unpublish')); - $this->drupalGet('node/' . $node->id() . '/translate'); - $this->drupalPostForm('node/' . $node->id() . '/edit', array(), t('Save and publish')); - $this->drupalLogin($this->translator); - - // Check that the "add translation" link uses a localized path. - $languages = language_list(); - $prefixes = language_negotiation_url_prefixes(); - $this->drupalGet('node/' . $node->id() . '/translate'); - $this->assertLinkByHref($prefixes['es'] . '/node/add/' . $node->getType(), 0, format_string('The "add translation" link for %language points to the localized path of the target language.', array('%language' => $languages['es']->name))); - - // Submit translation in Spanish. - $node_translation_title = $this->randomName(); - $node_translation_body = $this->randomName(); - $node_translation = $this->createTranslation($node, $node_translation_title, $node_translation_body, 'es'); - - // Check that the "edit translation" and "view node" links use localized - // paths. - $this->drupalGet('node/' . $node->id() . '/translate'); - $this->assertLinkByHref($prefixes['es'] . '/node/' . $node_translation->id() . '/edit', 0, format_string('The "edit" link for the translation in %language points to the localized path of the translation language.', array('%language' => $languages['es']->name))); - $this->assertLinkByHref($prefixes['es'] . '/node/' . $node_translation->id(), 0, format_string('The "view" link for the translation in %language points to the localized path of the translation language.', array('%language' => $languages['es']->name))); - - // Attempt to submit a duplicate translation by visiting the node/add page - // with identical query string. - $this->drupalGet('node/add/page', array('query' => array('translation' => $node->id(), 'target' => 'es'))); - $this->assertRaw(t('A translation of %title in %language already exists', array('%title' => $node_title, '%language' => $languages['es']->name)), 'Message regarding attempted duplicate translation is displayed.'); - - // Attempt a resubmission of the form - this emulates using the back button - // to return to the page then resubmitting the form without a refresh. - $edit = array(); - $edit["title"] = $this->randomName(); - $edit['body[0][value]'] = $this->randomName(); - $this->drupalPostForm('node/add/page', $edit, t('Save'), array('query' => array('translation' => $node->id(), 'language' => 'es'))); - $duplicate = $this->drupalGetNodeByTitle($edit["title"]); - $this->assertEqual($duplicate->tnid->value, 0, 'The node does not have a tnid.'); - - // Update original and mark translation as outdated. - $node_body = $this->randomName(); - $node->body->value = $node_body; - $edit = array(); - $edit['body[0][value]'] = $node_body; - $edit['translation[retranslate]'] = TRUE; - $this->drupalPostForm('node/' . $node->id() . '/edit', $edit, t('Save')); - $this->assertRaw(t('Basic page %title has been updated.', array('%title' => $node_title)), 'Original node updated.'); - - // Check to make sure that interface shows translation as outdated. - $this->drupalGet('node/' . $node->id() . '/translate'); - $this->assertRaw('' . t('outdated') . '', 'Translation marked as outdated.'); - - // Update translation and mark as updated. - $edit = array(); - $edit['body[0][value]'] = $this->randomName(); - $edit['translation[status]'] = FALSE; - $this->drupalPostForm('node/' . $node_translation->id() . '/edit', $edit, t('Save')); - $this->assertRaw(t('Basic page %title has been updated.', array('%title' => $node_translation_title)), 'Translated node updated.'); - - // Confirm that language neutral is an option for translators when there are - // disabled languages. - $this->drupalGet('node/add/page'); - $this->assertFieldByXPath('//select[@name="langcode"]//option', Language::LANGCODE_NOT_SPECIFIED, 'Language neutral is available in language selection with disabled languages.'); - $node2 = $this->createPage($this->randomName(), $this->randomName(), Language::LANGCODE_NOT_SPECIFIED); - $this->assertRaw($node2->body->value, 'Language neutral content created with disabled languages available.'); - - // Leave just one language installed and check that the translation overview - // page is still accessible. - $this->drupalLogin($this->admin_user); - $this->drupalPostForm('admin/config/regional/language/delete/es', array(), t('Delete')); - $this->drupalLogin($this->translator); - $this->drupalGet('node/' . $node->id() . '/translate'); - $this->assertRaw(t('Translations of %title', array('%title' => $node->label())), 'Translation overview page available with only one language enabled.'); - } - - /** - * Checks that the language switch links behave properly. - */ - function testLanguageSwitchLinks() { - // Create a Basic page in English and its translation in Spanish. - $node = $this->createPage($this->randomName(), $this->randomName(), 'en'); - $translation_es = $this->createTranslation($node, $this->randomName(), $this->randomName(), 'es'); - - // Check that language switch links are correctly shown for languages - // we have translations for. - $this->assertLanguageSwitchLinks($node, $translation_es); - $this->assertLanguageSwitchLinks($translation_es, $node); - - // Check that links to the displayed translation appear only in the language - // switcher block. - $this->assertLanguageSwitchLinks($node, $node, FALSE, 'node'); - $this->assertLanguageSwitchLinks($node, $node, TRUE, 'block-language'); - - // Unpublish the Spanish translation to check that the related language - // switch link is not shown. - $this->drupalLogin($this->admin_user); - $this->drupalPostForm('node/' . $translation_es->id() . '/edit', array(), t('Save and unpublish')); - $this->drupalLogin($this->translator); - $this->assertLanguageSwitchLinks($node, $translation_es, FALSE); - - // Check that content translation links are shown even when no language - // negotiation is configured. - $this->drupalLogin($this->admin_user); - $edit = array('language_interface[enabled][language-url]' => FALSE); - $this->drupalPostForm('admin/config/regional/language/detection', $edit, t('Save settings')); - $this->resetCaches(); - $this->drupalPostForm('node/' . $translation_es->id() . '/edit', array(), t('Save and publish')); - $this->drupalLogin($this->translator); - $this->assertLanguageSwitchLinks($node, $translation_es, TRUE, 'node'); - } - - /** - * Tests that the language switcher block alterations work as intended. - */ - function testLanguageSwitcherBlockIntegration() { - // Add Italian to have three items in the language switcher block. - $this->drupalLogin($this->admin_user); - $this->addLanguage('it'); - $this->resetCaches(); - $this->drupalLogin($this->translator); - - // Create a Basic page in English. - $type = 'block-language'; - $node = $this->createPage($this->randomName(), $this->randomName(), 'en'); - $this->assertLanguageSwitchLinks($node, $node, TRUE, $type); - $this->assertLanguageSwitchLinks($node, $this->emptyNode('es'), TRUE, $type); - $this->assertLanguageSwitchLinks($node, $this->emptyNode('it'), TRUE, $type); - - // Create the Spanish translation. - $translation_es = $this->createTranslation($node, $this->randomName(), $this->randomName(), 'es'); - $this->assertLanguageSwitchLinks($node, $node, TRUE, $type); - $this->assertLanguageSwitchLinks($node, $translation_es, TRUE, $type); - $this->assertLanguageSwitchLinks($node, $this->emptyNode('it'), TRUE, $type); - - // Create the Italian translation. - $translation_it = $this->createTranslation($node, $this->randomName(), $this->randomName(), 'it'); - $this->assertLanguageSwitchLinks($node, $node, TRUE, $type); - $this->assertLanguageSwitchLinks($node, $translation_es, TRUE, $type); - $this->assertLanguageSwitchLinks($node, $translation_it, TRUE, $type); - - // Create a language neutral node and check that the language switcher is - // left untouched. - $node2 = $this->createPage($this->randomName(), $this->randomName(), Language::LANGCODE_NOT_SPECIFIED); - $node2_en = clone $node2; - $node2_en->langcode = 'en'; - $node2_es = clone $node2; - $node2_es->langcode = 'es'; - $node2_it = clone $node2; - $node2_it->langcode = 'it'; - $this->assertLanguageSwitchLinks($node2_en, $node2_en, TRUE, $type); - $this->assertLanguageSwitchLinks($node2_en, $node2_es, TRUE, $type); - $this->assertLanguageSwitchLinks($node2_en, $node2_it, TRUE, $type); - - // Disable translation support to check that the language switcher is left - // untouched only for new nodes. - $this->drupalLogin($this->admin_user); - $edit = array('language_configuration[language_show]' => FALSE, 'node_type_language_translation_enabled' => FALSE); - $this->drupalPostForm('admin/structure/types/manage/page', $edit, t('Save content type')); - $this->drupalLogin($this->translator); - - // Existing translations trigger alterations even if translation support is - // disabled. - $this->assertLanguageSwitchLinks($node, $node, TRUE, $type); - $this->assertLanguageSwitchLinks($node, $translation_es, TRUE, $type); - $this->assertLanguageSwitchLinks($node, $translation_it, TRUE, $type); - - // Check that new nodes with a language assigned do not trigger language - // switcher alterations when translation support is disabled. - $node = $this->createPage($this->randomName(), $this->randomName()); - $node_es = clone $node; - $node_es->langcode = 'es'; - $node_it = clone $node; - $node_it->langcode = 'it'; - $this->assertLanguageSwitchLinks($node, $node, TRUE, $type); - $this->assertLanguageSwitchLinks($node, $node_es, TRUE, $type); - $this->assertLanguageSwitchLinks($node, $node_it, TRUE, $type); - } - - /** - * Checks that users with "translate own content" role only can translate own content. - */ - function testTranslateOwnContentRole() { - // Create a Basic page in English and its translation in Spanish with user - // that has "translate own content" role. - $this->drupalLogin($this->limited_translator); - $node = $this->createPage($this->randomName(), $this->randomName(), 'en'); - $this->assertLinkByHref('node/' . $node->id() . '/translate', 0, 'User with "translate own content" role can see translate link'); - $this->drupalGet('node/' . $node->id() . '/translate'); - $this->assertResponse(200, 'User with "translate own content" role can get translate page'); - $translation_es = $this->createTranslation($node, $this->randomName(), $this->randomName(), 'es'); - - // Create a page as translator user. - $this->drupalLogin($this->translator); - $node = $this->createPage($this->randomName(), $this->randomName(), 'en'); - // Change to limited_translator and check that translate links aren't shown. - $this->drupalLogin($this->limited_translator); - $this->assertNoLinkByHref('node/' . $node->id() . '/translate', 'User with "translate own content" role can\'t see translate link'); - // Check if user with "translate own content" role can see translate page - // from other user's node. - $this->drupalGet('node/' . $node->id() . '/translate'); - $this->assertResponse(403, 'User with "translate own content" role can\'t get translate page'); - - // Try to change to translate with "brute force". - $this->drupalGet('node/add/page', array('query' => array('translation' => $node->id(), 'target' => 'es'))); - $this->assertResponse(403, 'User with "translate own content" role can\'t get create translate page'); - } - - /** - * Resets static caches to make the test code match the client-side behavior. - */ - function resetCaches() { - drupal_static_reset('language_list'); - $this->rebuildContainer(); - } - - /** - * Returns an empty node data structure. - * - * @param $langcode - * The language code. - * - * @return - * An empty node data structure. - */ - function emptyNode($langcode) { - return entity_create('node', array('nid' => NULL, 'langcode' => $langcode, 'type' => 'page')); - } - - /** - * Installs the specified language, or enables it if it is already installed. - * - * @param $langcode - * The language code to check. - */ - function addLanguage($langcode) { - // Check to make sure that language has not already been installed. - $this->drupalGet('admin/config/regional/language'); - - if (strpos($this->drupalGetContent(), 'languages[' . $langcode . ']') === FALSE) { - // Doesn't have language installed so add it. - $edit = array(); - $edit['predefined_langcode'] = $langcode; - $this->drupalPostForm('admin/config/regional/language/add', $edit, t('Add language')); - - // Make sure we are not using a stale list. - drupal_static_reset('language_list'); - $languages = language_list(); - $this->assertTrue(array_key_exists($langcode, $languages), 'Language was installed successfully.'); - - if (array_key_exists($langcode, $languages)) { - $this->assertRaw(t('The language %language has been created and can now be used.', array('%language' => $languages[$langcode]->name)), 'Language has been created.'); - } - } - else { - // It's installed. No need to do anything. - $this->assertTrue(TRUE, 'Language [' . $langcode . '] already installed.'); - } - } - - /** - * Creates a "Basic page" in the specified language. - * - * @param $title - * The title of a basic page in the specified language. - * @param $body - * The body of a basic page in the specified language. - * @param $langcode - * (optional) Language code. - * - * @return - * A node object. - */ - function createPage($title, $body, $langcode = NULL) { - $edit = array(); - $edit['title'] = $title; - $edit['body[0][value]'] = $body; - if (!empty($langcode)) { - $edit['langcode'] = $langcode; - } - $this->drupalPostForm('node/add/page', $edit, t('Save')); - $this->assertRaw(t('Basic page %title has been created.', array('%title' => $title)), 'Basic page created.'); - - // Check to make sure the node was created. - $node = $this->drupalGetNodeByTitle($title); - $this->assertTrue($node, 'Node found in database.'); - - return $node; - } - - /** - * Creates a translation for a basic page in the specified language. - * - * @param \Drupal\Core\Entity\EntityInterface $node - * The basic page to create the translation for. - * @param $title - * The title of a basic page in the specified language. - * @param $body - * The body of a basic page in the specified language. - * @param $langcode - * (optional) Language code. - * - * @return - * Translation object. - */ - function createTranslation(EntityInterface $node, $title, $body, $langcode) { - $this->drupalGet('node/add/page', array('query' => array('translation' => $node->id(), 'target' => $langcode))); - - $this->assertFieldByXPath('//input[@id="edit-title"]', $node->label(), "Original title value correctly populated."); - - $edit = array(); - $edit['title'] = $title; - $edit['body[0][value]'] = $body; - $this->drupalPostForm(NULL, $edit, t('Save')); - $this->assertRaw(t('Basic page %title has been created.', array('%title' => $title)), 'Translation created.'); - - // Check to make sure that translation was successful. - $translation = $this->drupalGetNodeByTitle($title); - $this->assertTrue($translation, 'Node found in database.'); - $this->assertTrue($translation->tnid->value == $node->id(), 'Translation set id correctly stored.'); - - return $translation; - } - - /** - * Asserts an element identified by the given XPath has the given content. - * - * @param $xpath - * The XPath used to find the element. - * @param array $arguments - * An array of arguments with keys in the form ':name' matching the - * placeholders in the query. The values may be either strings or numeric - * values. - * @param $value - * The text content of the matched element to assert. - * @param $message - * The message to display. - * @param $group - * The group this message belongs to. - * - * @return - * TRUE on pass, FALSE on fail. - */ - function assertContentByXPath($xpath, array $arguments = array(), $value = NULL, $message = '', $group = 'Other') { - $found = $this->findContentByXPath($xpath, $arguments, $value); - return $this->assertTrue($found, $message, $group); - } - - /** - * Tests whether the specified language switch links are found. - * - * @param $node - * The node to display. - * @param $translation - * The translation whose link has to be checked. - * @param $find - * TRUE if the link must be present in the node page. - * @param $types - * The page areas to be checked. - * - * @return - * TRUE if the language switch links are found, FALSE if not. - */ - function assertLanguageSwitchLinks(NodeInterface $node, NodeInterface $translation, $find = TRUE, $types = NULL) { - if (empty($types)) { - $types = array('node', 'block-language'); - } - elseif (is_string($types)) { - $types = array($types); - } - - $result = TRUE; - $page_language = $node->language(); - $translation_language = $translation->language(); - $url = url('node/' . $translation->id(), array('language' => $translation_language)); - - $this->drupalGet('node/' . $node->id(), array('language' => $page_language)); - - foreach ($types as $type) { - $args = array('%translation_language' => $translation_language->name, '%page_language' => $page_language->name, '%type' => $type); - if ($find) { - $message = format_string('[%page_language] Language switch item found for %translation_language language in the %type page area.', $args); - } - else { - $message = format_string('[%page_language] Language switch item not found for %translation_language language in the %type page area.', $args); - } - - // node uses the article tag. - $tag = $type == 'node' ? 'article' : 'div'; - - if ($translation->id()) { - $xpath = '//' . $tag . '[contains(@class, :type)]//a[@href=:url]'; - } - else { - $xpath = '//' . $tag . '[contains(@class, :type)]//span[contains(@class, "locale-untranslated")]'; - } - - $found = $this->findContentByXPath($xpath, array(':type' => $type, ':url' => $url), $translation_language->name); - $result = $this->assertTrue($found == $find, $message) && $result; - } - - return $result; - } - - /** - * Searches for elements matching the given xpath and value. - * - * @param $xpath - * The XPath used to find the element. - * @param array $arguments - * An array of arguments with keys in the form ':name' matching the - * placeholders in the query. The values may be either strings or numeric - * values. - * @param $value - * The text content of the matched element to assert. - * - * @return - * TRUE if found, otherwise FALSE. - */ - function findContentByXPath($xpath, array $arguments = array(), $value = NULL) { - $elements = $this->xpath($xpath, $arguments); - - $found = TRUE; - if ($value && $elements) { - $found = FALSE; - foreach ($elements as $element) { - if ((string) $element == $value) { - $found = TRUE; - break; - } - } - } - - return $elements && $found; - } -} diff --git a/core/modules/translation/tests/translation_test.info.yml b/core/modules/translation/tests/translation_test.info.yml deleted file mode 100644 index 1316ee9..0000000 --- a/core/modules/translation/tests/translation_test.info.yml +++ /dev/null @@ -1,7 +0,0 @@ -name: 'Content Translation Test' -type: module -description: 'Support module for the content translation tests.' -core: 8.x -package: Testing -version: VERSION -hidden: true diff --git a/core/modules/translation/tests/translation_test.module b/core/modules/translation/tests/translation_test.module deleted file mode 100644 index 3b7fe76..0000000 --- a/core/modules/translation/tests/translation_test.module +++ /dev/null @@ -1,15 +0,0 @@ -save(); -} diff --git a/core/modules/translation/translation.info.yml b/core/modules/translation/translation.info.yml deleted file mode 100644 index 895a771..0000000 --- a/core/modules/translation/translation.info.yml +++ /dev/null @@ -1,10 +0,0 @@ -name: 'Content Translation (deprecated)' -type: module -description: 'Allows content to be translated into different languages.' -dependencies: - - node - - language -package: Multilingual -version: VERSION -core: 8.x -hidden: true diff --git a/core/modules/translation/translation.install b/core/modules/translation/translation.install deleted file mode 100644 index ad15ba0..0000000 --- a/core/modules/translation/translation.install +++ /dev/null @@ -1,27 +0,0 @@ - array('translate all content'), - )); -} - -/** -* Moves "translation_language_type" from variable to config. -* -* @ingroup config_upgrade - */ -function translation_update_8001() { - update_variables_to_config('translation.settings', array( - 'translation_language_type' => 'language_type', - )); -} diff --git a/core/modules/translation/translation.js b/core/modules/translation/translation.js deleted file mode 100644 index 2232ba3..0000000 --- a/core/modules/translation/translation.js +++ /dev/null @@ -1,21 +0,0 @@ -(function ($) { - -"use strict"; - -Drupal.behaviors.TranslationEnable = { - attach: function (context) { - $('#edit-node-type-language-default, #edit-node-type-language-hidden', context).change(function(context) { - var default_language = $('#edit-node-type-language-default').val(); - - if ((default_language === 'und' || default_language === 'zxx' || default_language === 'mul') && $('#edit-node-type-language-hidden').prop('checked')) { - $('.form-item-node-type-language-translation-enabled').hide(); - $('#edit-node-type-language-translation-enabled').prop('checked', false); - } else { - $('.form-item-node-type-language-translation-enabled').show(); - } - }); - $('#edit-node-type-language-default', context).trigger('change'); - } -}; - -})(jQuery); diff --git a/core/modules/translation/translation.module b/core/modules/translation/translation.module deleted file mode 100644 index bd1bf31..0000000 --- a/core/modules/translation/translation.module +++ /dev/null @@ -1,604 +0,0 @@ -' . t('About') . ''; - $output .= '

' . t('The Content Translation module allows content to be translated into different languages. Working with the Locale module (which manages enabled languages and provides translation for the site interface), the Content Translation module is key to creating and maintaining translated site content. For more information, see the online handbook entry for Content Translation module.', array('@locale' => url('admin/help/locale'), '@translation' => 'http://drupal.org/documentation/modules/translation/')) . '

'; - $output .= '

' . t('Uses') . '

'; - $output .= '
'; - $output .= '
' . t('Configuring content types for translation') . '
'; - $output .= '
' . t('To configure a particular content type for translation, visit the Content types page, and click the edit link for the content type. In the Publishing options section, select Enabled, with translation under Multilingual support.', array('@content-types' => url('admin/structure/types'))) . '
'; - $output .= '
' . t('Assigning a language to content') . '
'; - $output .= '
' . t('Use the Language drop down to select the appropriate language when creating or editing content.') . '
'; - $output .= '
' . t('Translating content') . '
'; - $output .= '
' . t('Users with the translate all content or translate own content permission can translate content, if the content type has been configured to allow translations. To translate content, select the Translate tab when viewing the content, select the language for which you wish to provide content, and then enter the content.') . '
'; - $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 translations as outdated check box to mark the translations as outdated and in need of revision. Individual translations may also be marked for revision by selecting the This translation needs to be updated check box on the translation editing form.') . '
'; - $output .= '
'; - return $output; - case 'node/%/translate': - $output = '

' . t('Translations of a piece of content are managed with translation sets. Each translation set has one source post and any number of translations in any of the enabled languages. All translations are tracked to be up to date or outdated based on whether the source post was modified significantly.', array('!languages' => url('admin/config/regional/language'))) . '

'; - return $output; - } -} - -/** - * Implements hook_menu(). - */ -function translation_menu() { - $items = array(); - $items['node/%node/translate'] = array( - 'title' => 'Translate', - 'route_name' => 'translation.node_overview', - 'type' => MENU_LOCAL_TASK, - 'context' => MENU_CONTEXT_PAGE | MENU_CONTEXT_INLINE, - 'weight' => 2, - ); - return $items; -} - -/** - * Access callback: Checks that the user has permission to 'translate - * all content' or to 'translate own content' and has created the node - * being translated. - * - * Only displays the translation tab for nodes that are not language-neutral - * of types that have translation enabled. - * - * @param $node - * A node entity. - * - * @return - * TRUE if the translation tab should be displayed, FALSE otherwise. - * - * @see translation_menu() - */ -function _translation_tab_access(NodeInterface $node) { - if ($node->language()->id != Language::LANGCODE_NOT_SPECIFIED && translation_supported_type($node->getType()) && node_access('view', $node)) { - return translation_user_can_translate_node($node); - } - return FALSE; -} - -/** - * Implements hook_admin_paths(). - */ -function translation_admin_paths() { - if (\Drupal::config('node.settings')->get('use_admin_theme')) { - $paths = array( - 'node/*/translate' => TRUE, - ); - return $paths; - } -} - -/** - * Implements hook_permission(). - */ -function translation_permission() { - return array( - 'translate all content' => array( - 'title' => t('Translate all content'), - ), - 'translate own content' => array( - 'title' => t('Translate own content'), - ), - ); -} - -/** - * Implements hook_node_create_access(). - */ -function translation_node_create_access($account) { - $query = \Drupal::request()->query; - $translation = $query->get('translation'); - $target = $query->get('target'); - $request_has_translation_arg = !empty($translation) && !empty($target) && is_numeric($translation); - if ($request_has_translation_arg) { - $source_node = node_load($translation); - if (empty($source_node) || !translation_user_can_translate_node($source_node, $account)){ - return NODE_ACCESS_DENY; - } - } - - return NODE_ACCESS_IGNORE; -} - -/** - * Check if the user has permissions to translate a node. - * - * @param $node - * Node being checked. - * @param $account - * User object to check translation permissions. - * - * @return - * TRUE if the user can translate a node, FALSE otherwise. - */ -function translation_user_can_translate_node($node, $account = NULL) { - // If no user object is supplied, the access check is for the current user. - if (empty($account)) { - $account = \Drupal::currentUser(); - } - return node_access('view', $node, $account) && (user_access('translate all content', $account) || ($node->getAuthorId() == $account->id() && user_access('translate own content', $account))); -} - -/** - * Implements hook_form_FORM_ID_alter() for node_type_form(). - */ -function translation_form_node_type_form_alter(&$form, &$form_state) { - // Hide form element if default language is a constant. - // TODO: When form #states allows OR values change this to use form #states. - $form['#attached']['library'][] = array('translation', 'drupal.translation'); - // Add translation option to content type form. - $form['language']['node_type_language_translation_enabled'] = array( - '#type' => 'checkbox', - '#title' => t('Enable translation'), - '#default_value' => variable_get('node_type_language_translation_enabled_' . $form_state['controller']->getEntity()->id(), FALSE), - '#element_validate' => array('translation_node_type_language_translation_enabled_validate'), - '#prefix' => "", - ); -} - -/** - * Checks if translation can be enabled. - * - * If language is set to one of the special languages - * and language selector is not hidden, translation cannot be enabled. - */ -function translation_node_type_language_translation_enabled_validate($element, &$form_state, $form) { - if (language_is_locked($form_state['values']['language_configuration']['langcode']) && !$form_state['values']['language_configuration']['language_show'] && $form_state['values']['node_type_language_translation_enabled']) { - foreach (language_list(Language::STATE_LOCKED) as $language) { - $locked_languages[] = $language->name; - } - form_set_error('node_type_language_translation_enabled', t('Translation is not supported if language is always one of: @locked_languages', array('@locked_languages' => implode(", ", $locked_languages)))); - } -} - -/** - * Implements hook_form_BASE_FORM_ID_alter() for node_form(). - * - * Alters language fields on node edit forms when a translation is about to be - * created. - * - * @see node_form() - */ -function translation_form_node_form_alter(&$form, &$form_state) { - $node = $form_state['controller']->getEntity(); - if (translation_supported_type($node->getType())) { - if (!empty($node->translation_source)) { - // We are creating a translation. Lock language field. - $form['langcode']['#disabled'] = TRUE; - } - elseif (!$node->isNew() && $node->tnid->value) { - // Disable languages for existing translations, so it is not possible - // to switch this node to some language which is already in the - // translation set. Also remove the language neutral option. - unset($form['langcode']['#options'][Language::LANGCODE_NOT_SPECIFIED]); - foreach (translation_node_get_translations($node->tnid->value) as $langcode => $translation) { - if ($translation->nid != $node->id()) { - unset($form['langcode']['#options'][$langcode]); - } - } - // Add translation values and workflow options. - $form['translation'] = array( - '#type' => 'details', - '#title' => t('Translation settings'), - '#access' => translation_user_can_translate_node($node), - '#collapsed' => !$node->translate->value, - '#tree' => TRUE, - '#weight' => 30, - ); - if ($node->tnid->value == $node->id()) { - // This is the source node of the translation. - $form['translation']['retranslate'] = array( - '#type' => 'checkbox', - '#title' => t('Flag translations as outdated'), - '#default_value' => 0, - '#description' => t('If you made a significant change, which means translations should be updated, you can flag all translations of this post as outdated. This will not change any other property of those posts, like whether they are published or not.'), - ); - $form['translation']['status'] = array('#type' => 'value', '#value' => 0); - } - else { - $form['translation']['status'] = array( - '#type' => 'checkbox', - '#title' => t('This translation needs to be updated'), - '#default_value' => $node->translate->value, - '#description' => t('When this option is checked, this translation needs to be updated because the source post has changed. Uncheck when the translation is up to date again.'), - ); - } - $form['#entity_builders'][] = 'translation_node_builder'; - } - } -} - -/** - * Entity form builder to add translation metadata to the node. - * - * @todo: Remove this in favor of an entity field. - */ -function translation_node_builder($entity_type, $entity, &$form, &$form_state) { - if (isset($form_state['values']['translation'])) { - $entity->translation = $form_state['values']['translation']; - } -} - -/** - * Implements hook_node_view(). - * - * Displays translation links with language names if this node is part of a - * translation set. If no language provider is enabled, "fall back" to simple - * links built through the result of translation_node_get_translations(). - */ -function translation_node_view(EntityInterface $node, EntityDisplay $display, $view_mode) { - // If the site has no translations or is not multilingual we have no content - // translation links to display. - if ($node->tnid->value && language_multilingual() && $translations = translation_node_get_translations($node->tnid->value)) { - $languages = language_list(Language::STATE_ALL); - - // There might be a language provider enabled defining custom language - // switch links which need to be taken into account while generating the - // content translation links. As custom language switch links are available - // only for configurable language types and interface language is the only - // configurable language type in core, we use it as default. Contributed - // modules can change this behavior by setting the system variable below. - $type = \Drupal::config('translation.settings')->get('language_type'); - $custom_links = language_negotiation_get_switch_links($type, 'node/' . $node->id()); - $links = array(); - - foreach ($translations as $langcode => $translation) { - // Do not show links to the same node or to unpublished translations. - if ($translation->status && isset($languages[$langcode]) && $langcode != $node->language()->id) { - $key = "translation_$langcode"; - - if (isset($custom_links->links[$langcode])) { - $links[$key] = $custom_links->links[$langcode]; - } - else { - $links[$key] = array( - 'href' => "node/{$translation->nid}", - 'title' => language_name($langcode), - 'language' => $languages[$langcode], - ); - } - - // Custom switch links are more generic than content translation links, - // hence we override existing attributes with the ones below. - $links[$key] += array('attributes' => array()); - $attributes = array( - 'title' => $translation->title, - 'class' => array('translation-link'), - ); - $links[$key]['attributes'] = $attributes + $links[$key]['attributes']; - } - } - - $node->content['links']['translation'] = array( - '#theme' => 'links__node__translation', - '#links' => $links, - '#attributes' => array('class' => array('links', 'inline')), - ); - } -} - -/** - * Implements hook_node_prepare_form(). - */ -function translation_node_prepare_form(NodeInterface $node, $form_display, $operation, array &$form_state) { - $query = \Drupal::request()->query; - $translation = $query->get('translation'); - $target = $query->get('target'); - // Only act if we are dealing with a content type supporting translations. - if (translation_supported_type($node->getType()) && - // And it's a new node. - $node->isNew() && - // And the request variables are set properly. - !empty($translation) && - !empty($target) && - is_numeric($translation)) { - - $source_node = node_load($translation); - - $language_list = language_list(); - $langcode = $target; - if (!isset($language_list[$langcode]) || ($source_node->language()->id == $langcode)) { - // If not supported language, or same language as source node, break. - return; - } - - // Ensure we don't have an existing translation in this language. - if (!empty($source_node->tnid->value)) { - $translations = translation_node_get_translations($source_node->tnid->value); - if (isset($translations[$langcode])) { - drupal_set_message(t('A translation of %title in %language already exists, a new %type will be created instead of a translation.', array('%title' => $source_node->label(), '%language' => $language_list[$langcode]->name, '%type' => $node->getType())), 'error'); - return; - } - } - - // Populate fields based on source node. - $node->langcode = $langcode; - $node->translation_source = $source_node; - $node->title = $source_node->getTitle(); - } -} - -/** - * Implements hook_node_insert(). - */ -function translation_node_insert(EntityInterface $node) { - // Only act if we are dealing with a content type supporting translations. - if (translation_supported_type($node->getType())) { - if (!empty($node->translation_source)) { - if ($node->translation_source->tnid->value) { - // Add node to existing translation set. - $tnid = $node->translation_source->tnid->value; - } - else { - // Create new translation set, using nid from the source node. - $tnid = $node->translation_source->id(); - db_update('node') - ->fields(array( - 'tnid' => $tnid, - 'translate' => 0, - )) - ->condition('nid', $node->translation_source->id()) - ->execute(); - } - db_update('node') - ->fields(array( - 'tnid' => $tnid, - 'translate' => 0, - )) - ->condition('nid', $node->id()) - ->execute(); - // Save tnid to avoid loss in case of resave. - $node->tnid = $tnid; - } - } -} - -/** - * Implements hook_node_update(). - */ -function translation_node_update(NodeInterface $node) { - // Only act if we are dealing with a content type supporting translations. - if (translation_supported_type($node->getType())) { - if (isset($node->translation) && $node->translation && $node->tnid->value) { - // Update translation information. - db_update('node') - ->fields(array( - 'tnid' => $node->tnid->value, - 'translate' => $node->translation['status'], - )) - ->condition('nid', $node->id()) - ->execute(); - if (!empty($node->translation['retranslate'])) { - // This is the source node, asking to mark all translations outdated. - db_update('node') - ->fields(array('translate' => 1)) - ->condition('nid', $node->id(), '<>') - ->condition('tnid', $node->tnid->value) - ->execute(); - } - } - } -} - -/** - * Implements hook_node_validate(). - * - * Ensures that duplicate translations can't be created for the same source. - */ -function translation_node_validate(NodeInterface $node, $form, &$form_state) { - // Only act on translatable nodes with a tnid or translation_source. - $form_node = $form_state['controller']->getEntity(); - if (translation_supported_type($node->getType()) && ($node->tnid->value || ($form_node->translation_source && $form_node->translation_source->id()))) { - $tnid = $node->tnid->value ?: $form_node->translation_source->id(); - $translations = translation_node_get_translations($tnid); - if (isset($translations[$node->language()->id]) && $translations[$node->language()->id]->nid != $node->id()) { - form_set_error('langcode', t('There is already a translation in this language.')); - } - } -} - -/** - * Implements hook_node_predelete(). - */ -function translation_node_predelete(NodeInterface $node) { - // Only act if we are dealing with a content type supporting translations. - if (translation_supported_type($node->getType())) { - translation_remove_from_set($node); - } -} - -/** - * Removes a node from its translation set and updates accordingly. - * - * @param $node - * A node entity. - */ -function translation_remove_from_set(NodeInterface $node) { - if ($node->tnid->value) { - $query = db_update('node') - ->fields(array( - 'tnid' => 0, - 'translate' => 0, - )); - if (db_query('SELECT COUNT(*) FROM {node} WHERE tnid = :tnid', array(':tnid' => $node->tnid->value))->fetchField() == 1) { - // There is only one node left in the set: remove the set altogether. - $query - ->condition('tnid', $node->tnid->value) - ->execute(); - } - else { - $query - ->condition('nid', $node->id()) - ->execute(); - - // If the node being removed was the source of the translation set, - // we pick a new source - preferably one that is up to date. - if ($node->tnid->value == $node->id()) { - $new_tnid = db_query('SELECT nid FROM {node} WHERE tnid = :tnid ORDER BY translate ASC, nid ASC', array(':tnid' => $node->tnid->value))->fetchField(); - db_update('node') - ->fields(array('tnid' => $new_tnid)) - ->condition('tnid', $node->tnid->value) - ->execute(); - } - } - } -} - -/** - * Gets all nodes in a given translation set. - * - * @param $tnid - * The translation source nid of the translation set, the identifier of the - * node used to derive all translations in the set. - * - * @return - * Array of partial node objects (nid, title, langcode) representing all - * nodes in the translation set, in effect all translations of node $tnid, - * including node $tnid itself. Because these are partial nodes, you need to - * node_load() the full node, if you need more properties. The array is - * indexed by language code. - */ -function translation_node_get_translations($tnid) { - if (is_numeric($tnid) && $tnid) { - $translations = &drupal_static(__FUNCTION__, array()); - - if (!isset($translations[$tnid])) { - $translations[$tnid] = array(); - $query = db_select('node_field_data', 'n'); - $query->innerJoin('node', 'nb', 'nb.nid = n.nid AND nb.langcode = n.langcode'); - $query->fields('n', array('nid', 'uid', 'status', 'title', 'langcode')) - ->fields('nb', array('type')) - ->condition('nb.tnid', $tnid) - ->addTag('node_access'); - $result = $query->execute(); - - foreach ($result as $node) { - $translations[$tnid][$node->langcode] = $node; - } - } - return $translations[$tnid]; - } -} - -/** - * Returns whether the given content type has support for translations. - * - * @return - * TRUE if translation is supported, and FALSE if not. - */ -function translation_supported_type($type) { - return variable_get('node_type_language_translation_enabled_' . $type, FALSE); -} - -/** - * Returns the paths of all translations of a node, based on its Drupal path. - * - * @param $path - * A Drupal path, for example node/432. - * - * @return - * An array of paths of translations of the node accessible to the current - * user, keyed with language codes. - */ -function translation_path_get_translations($path) { - $paths = array(); - // Check for a node related path, and for its translations. - if ((preg_match("!^node/(\d+)(/.+|)$!", $path, $matches)) && ($node = node_load((int) $matches[1])) && $node->tnid->value) { - foreach (translation_node_get_translations($node->tnid->value) as $language => $translation_node) { - $paths[$language] = 'node/' . $translation_node->id() . $matches[2]; - } - } - return $paths; -} - -/** - * Implements hook_language_switch_links_alter(). - * - * Replaces links with pointers to translated versions of the content. - */ -function translation_language_switch_links_alter(array &$links, $type, $path) { - $language_type = \Drupal::config('translation.settings')->get('language_type'); - if ($type == $language_type && preg_match("!^node/(\d+)(/.+|)!", $path, $matches)) { - $node = node_load((int) $matches[1]); - - if (empty($node->tnid->value)) { - // If the node cannot be found nothing needs to be done. If it does not - // have translations it might be a language neutral node, in which case we - // must leave the language switch links unaltered. This is true also for - // nodes not having translation support enabled. - if (empty($node) || $node->language()->id == Language::LANGCODE_NOT_SPECIFIED || !translation_supported_type($node->getType())) { - return; - } - $translations = array($node->language()->id => $node); - } - else { - $translations = translation_node_get_translations($node->tnid->value); - } - - foreach ($links as $langcode => $link) { - if (isset($translations[$langcode]) && $translations[$langcode]->status) { - // Translation in a different node. - $nid = $translations[$langcode] instanceof EntityInterface ? $translations[$langcode]->id() : $translations[$langcode]->nid; - $links[$langcode]['href'] = 'node/' . $nid . $matches[2]; - } - else { - // No translation in this language, or no permission to view. - unset($links[$langcode]['href']); - $links[$langcode]['attributes']['class'][] = 'locale-untranslated'; - } - } - } -} - -/** - * Implements hook_library_info(). - */ -function translation_library_info() { - $libraries['drupal.translation'] = array( - 'title' => 'Translation', - 'version' => \Drupal::VERSION, - 'js' => array( - drupal_get_path('module', 'translation') . '/translation.js' => array(), - ), - 'dependencies' => array( - array('system', 'jquery'), - array('system', 'drupal'), - ), - ); - - return $libraries; -} diff --git a/core/modules/translation/translation.pages.inc b/core/modules/translation/translation.pages.inc deleted file mode 100644 index a1f6360..0000000 --- a/core/modules/translation/translation.pages.inc +++ /dev/null @@ -1,105 +0,0 @@ -tnid->value) { - // Already part of a set, grab that set. - $tnid = $node->tnid->value; - $translations = translation_node_get_translations($node->tnid->value); - } - else { - // We have no translation source nid, this could be a new set, emulate that. - $tnid = $node->id(); - $translations = array($node->language()->id => $node); - } - - $type = \Drupal::config('translation.settings')->get('language_type'); - $header = array(t('Language'), t('Title'), t('Status'), t('Operations')); - - foreach (language_list() as $langcode => $language) { - $options = array(); - $language_name = $language->name; - if (isset($translations[$langcode])) { - // Existing translation in the translation set: display status. - // We load the full node to check whether the user can edit it. - $nid = $translations[$langcode] instanceof EntityInterface ? $translations[$langcode]->id() : $translations[$langcode]->nid; - $translation_node = node_load($nid); - $path = 'node/' . $translation_node->id(); - $links = language_negotiation_get_switch_links($type, $path); - $title = empty($links->links[$langcode]['href']) ? l($translation_node->label(), $path) : l($translation_node->label(), $links->links[$langcode]['href'], $links->links[$langcode]); - if (node_access('update', $translation_node)) { - $path = 'node/' . $translation_node->id() . '/edit'; - $links = language_negotiation_get_switch_links($type, $path); - if (!empty($links->links[$langcode]['href'])) { - $options['edit'] = array( - 'title' => t('edit'), - ) + $links->links[$langcode]; - } - } - $status = $translation_node->isPublished() ? t('Published') : t('Not published'); - $status .= $translation_node->translate->value ? ' - ' . t('outdated') . '' : ''; - if ($translation_node->id() == $tnid) { - $language_name = t('@language_name (source)', array('@language_name' => $language_name)); - } - } - else { - // No such translation in the set yet: help user to create it. - $title = t('n/a'); - if (node_access('create', $node)) { - $path = 'node/add/' . $node->getType(); - $links = language_negotiation_get_switch_links($type, $path); - $query = array('query' => array('translation' => $node->id(), 'target' => $langcode)); - if (!empty($links->links[$langcode]['href'])) { - $options['add'] = array( - 'title' => t('Add translation'), - ) + $links->links[$langcode]; - $options['add'] = NestedArray::mergeDeep($options['add'], $query); - } - } - $status = t('Not translated'); - } - $row = array(); - $row[] = $language_name; - $row[] = $title; - $row[] = $status; - $row[] = array( - 'data' => array( - '#type' => 'operations', - '#links' => $options, - ), - ); - $rows[] = $row; - } - - $build['#title'] = t('Translations of %title', array('%title' => $node->label())); - - $build['translation_node_overview'] = array( - '#theme' => 'table', - '#header' => $header, - '#rows' => $rows, - ); - - return $build; -} diff --git a/core/modules/translation/translation.routing.yml b/core/modules/translation/translation.routing.yml deleted file mode 100644 index 7129075..0000000 --- a/core/modules/translation/translation.routing.yml +++ /dev/null @@ -1,7 +0,0 @@ -translation.node_overview: - path: '/node/{node}/translate' - defaults: - _title: 'Translate' - _content: '\Drupal\translation\Controller\TranslationController::nodeOverview' - requirements: - _access_translation_tab: 'node' diff --git a/core/modules/translation/translation.services.yml b/core/modules/translation/translation.services.yml deleted file mode 100644 index e6520d5..0000000 --- a/core/modules/translation/translation.services.yml +++ /dev/null @@ -1,5 +0,0 @@ -services: - access_check.translation.node_overview: - class: Drupal\translation\Access\TranslationNodeOverviewAccessCheck - tags: - - { name: access_check } diff --git a/core/modules/views/lib/Drupal/views/Tests/Handler/HandlerAllTest.php b/core/modules/views/lib/Drupal/views/Tests/Handler/HandlerAllTest.php index 7ad88da..549163e 100644 --- a/core/modules/views/lib/Drupal/views/Tests/Handler/HandlerAllTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/Handler/HandlerAllTest.php @@ -38,7 +38,7 @@ class HandlerAllTest extends HandlerTestBase { 'search', 'statistics', 'taxonomy', - 'translation', + 'translation_content', 'user', );