diff --git a/core/modules/comment/comment.module b/core/modules/comment/comment.module index 70218a5..4acbe6d 100644 --- a/core/modules/comment/comment.module +++ b/core/modules/comment/comment.module @@ -1841,7 +1841,7 @@ function comment_form($form, &$form_state, $comment) { // If a content type has multilingual support we set the comment to inherit the // content language. Otherwise mark the comment as language neutral. $comment_langcode = $comment->language; - if (($comment_langcode == LANGUAGE_NONE) && variable_get('language_content_type_' . $node->type, 0)) { + if (($comment_langcode == LANGUAGE_NONE) && variable_get('node_type_language_' . $node->type, 0)) { $comment_langcode = $language_content->langcode; } $form['language'] = array( diff --git a/core/modules/field/modules/text/text.test b/core/modules/field/modules/text/text.test index 5936937..e061a39 100644 --- a/core/modules/field/modules/text/text.test +++ b/core/modules/field/modules/text/text.test @@ -434,7 +434,7 @@ class TextTranslationTestCase extends DrupalWebTestCase { $this->drupalPost('admin/config/regional/language/add', $edit, t('Add language')); // Set "Article" content type to use multilingual support with translation. - $edit = array('language_content_type' => 2); + $edit = array('node_type_language' => 2); $this->drupalPost('admin/structure/types/manage/article', $edit, t('Save content type')); $this->assertRaw(t('The content type %type has been updated.', array('%type' => 'Article')), t('Article content type has been updated.')); } diff --git a/core/modules/locale/locale.module b/core/modules/locale/locale.module index a712c49..f723460 100644 --- a/core/modules/locale/locale.module +++ b/core/modules/locale/locale.module @@ -247,31 +247,6 @@ function locale_language_selector_form($user) { } /** - * Implements hook_form_FORM_ID_alter(). - */ -function locale_form_node_type_form_alter(&$form, &$form_state) { - if (isset($form['type'])) { - $form['workflow']['language_content_type'] = array( - '#type' => 'radios', - '#title' => t('Multilingual support'), - '#default_value' => variable_get('language_content_type_' . $form['#node_type']->type, 0), - '#options' => array(t('Disabled'), t('Enabled')), - '#description' => t('Enable multilingual support for this content type. If enabled, a language selection field will be added to the editing form, allowing you to select from one of the enabled languages. If disabled, new posts are saved with the default language. Existing content will not be affected by changing this option.', array('!languages' => url('admin/config/regional/language'))), - ); - } -} - -/** - * Return whether the given content type has multilingual support. - * - * @return - * True if multilingual support is enabled. - */ -function locale_multilingual_node_type($type_name) { - return (bool) variable_get('language_content_type_' . $type_name, 0); -} - -/** * Implements hook_form_alter(). * * Adds language fields to user forms. @@ -295,27 +270,6 @@ function locale_form_alter(&$form, &$form_state, $form_id) { * Implements hook_form_BASE_FORM_ID_alter(). */ function locale_form_node_form_alter(&$form, &$form_state) { - if (isset($form['#node']->type) && locale_multilingual_node_type($form['#node']->type)) { - $languages = language_list(TRUE); - $language_options = array(LANGUAGE_NONE => t('Language neutral')); - foreach ($languages as $langcode => $language) { - $language_options[$langcode] = $language->name; - } - $form['language'] = array( - '#type' => 'select', - '#title' => t('Language'), - '#default_value' => (isset($form['#node']->language) ? $form['#node']->language : ''), - '#options' => $language_options, - ); - } - // Node type without language selector: assign the default for new nodes - elseif (!isset($form['#node']->nid)) { - $default = language_default(); - $form['language'] = array( - '#type' => 'value', - '#value' => $default->langcode - ); - } $form['#submit'][] = 'locale_field_node_form_submit'; } diff --git a/core/modules/locale/locale.test b/core/modules/locale/locale.test index f102d4b..8f2d8de 100644 --- a/core/modules/locale/locale.test +++ b/core/modules/locale/locale.test @@ -1104,7 +1104,7 @@ class LocaleUninstallFunctionalTest extends DrupalWebTestCase { $this->assertEqual($GLOBALS['language']->langcode, $this->langcode, t('Current language: %lang', array('%lang' => $GLOBALS['language']->langcode))); // Enable multilingual workflow option for articles. - variable_set('language_content_type_article', 1); + variable_set('node_type_language_article', 1); // Change JavaScript translations directory. variable_set('locale_js_directory', 'js_translations'); @@ -1173,10 +1173,6 @@ class LocaleUninstallFunctionalTest extends DrupalWebTestCase { $javascript_parsed_count = count(variable_get('javascript_parsed', array())); $this->assertEqual($javascript_parsed_count, 0, t('JavaScript parsed count: %count', array('%count' => $javascript_parsed_count))); - // Check multilingual workflow option for articles. - $multilingual = variable_get('language_content_type_article', 0); - $this->assertEqual($multilingual, 0, t('Multilingual workflow option: %status', array('%status' => t($multilingual ? 'enabled': 'disabled')))); - // Check JavaScript translations directory. $locale_js_directory = variable_get('locale_js_directory', 'languages'); $this->assertEqual($locale_js_directory, 'languages', t('JavaScript translations directory: %dir', array('%dir' => $locale_js_directory))); @@ -1823,7 +1819,7 @@ class LocaleContentFunctionalTest extends DrupalWebTestCase { $this->drupalGet('admin/structure/types/manage/page'); $this->assertText(t('Multilingual support'), t('Multilingual support fieldset present on content type configuration form.')); $edit = array( - 'language_content_type' => 1, + 'node_type_language' => 1, ); $this->drupalPost('admin/structure/types/manage/page', $edit, t('Save content type')); $this->assertRaw(t('The content type %type has been updated.', array('%type' => 'Basic page')), t('Basic page content type has been updated.')); @@ -1893,7 +1889,7 @@ class LocaleContentFunctionalTest extends DrupalWebTestCase { // Set "Article" content type to use multilingual support. $this->drupalGet('admin/structure/types/manage/article'); $edit = array( - 'language_content_type' => 1, + 'node_type_language' => 1, ); $this->drupalPost('admin/structure/types/manage/article', $edit, t('Save content type')); $this->assertRaw(t('The content type %type has been updated.', array('%type' => 'Article')), t('Article content type has been updated.')); @@ -2331,7 +2327,7 @@ class LocaleMultilingualFieldsFunctionalTest extends DrupalWebTestCase { // Set "Basic page" content type to use multilingual support. $edit = array( - 'language_content_type' => 1, + 'node_type_language' => 1, ); $this->drupalPost('admin/structure/types/manage/page', $edit, t('Save content type')); $this->assertRaw(t('The content type %type has been updated.', array('%type' => 'Basic page')), t('Basic page content type has been updated.')); @@ -2445,7 +2441,7 @@ class LocaleCommentLanguageFunctionalTest extends DrupalWebTestCase { $this->drupalPost('admin/config/regional/language/add', $edit, t('Add language')); // Set "Article" content type to use multilingual support. - $edit = array('language_content_type' => 1); + $edit = array('node_type_language' => 1); $this->drupalPost('admin/structure/types/manage/article', $edit, t('Save content type')); // Enable content language negotiation UI. diff --git a/core/modules/node/content_types.inc b/core/modules/node/content_types.inc index c76a5e2..2013cc3 100644 --- a/core/modules/node/content_types.inc +++ b/core/modules/node/content_types.inc @@ -187,6 +187,14 @@ function node_type_form($form, &$form_state, $type = NULL) { ), '#description' => t('Users with the Administer content permission will be able to override these options.'), ); + if (module_exists('language')) { + $form['workflow']['node_type_language'] = array( + '#type' => 'checkbox', + '#title' => t('Multilingual support'), + '#default_value' => variable_get('node_type_language_' . $type->type, 0), + '#description' => t('Add a language selection field to the editing form, allowing you to select from one of the enabled languages. If disabled, new posts are saved with the default language. Existing content will not be affected by changing this option.', array('!languages' => url('admin/international/language'))), + ); + } $form['display'] = array( '#type' => 'fieldset', '#title' => t('Display settings'), diff --git a/core/modules/node/node.install b/core/modules/node/node.install index 82fd2e7..7ab3de1 100644 --- a/core/modules/node/node.install +++ b/core/modules/node/node.install @@ -456,6 +456,7 @@ function node_uninstall() { ->condition('name', 'node_options_' . $type) ->condition('name', 'node_submitted_' . $type) ->condition('name', 'node_permissions_' . $type) + ->condition('name', 'node_type_language_' . $type) ) ->execute(); } diff --git a/core/modules/node/node.pages.inc b/core/modules/node/node.pages.inc index cd1eb6d..e30f0b1 100644 --- a/core/modules/node/node.pages.inc +++ b/core/modules/node/node.pages.inc @@ -181,6 +181,28 @@ function node_form($form, &$form_state, $node) { // @todo D8: Remove. Modules should access the node using $form_state['node']. $form['#node'] = $node; + if (variable_get('node_type_language_' . $node->type, 0) && module_exists('language')) { + $languages = language_list(TRUE); + $language_options = array(LANGUAGE_NONE => t('Language neutral')); + foreach ($languages as $langcode => $language) { + $language_options[$langcode] = $language->name; + } + $form['language'] = array( + '#type' => 'select', + '#title' => t('Language'), + '#default_value' => (isset($node->language) ? $node->language : ''), + '#options' => $language_options, + ); + } + else { + $form['language'] = array( + '#type' => 'value', + // New nodes without multilingual support get the default language, old + // nodes keep their language if language.module is not available. + '#value' => !isset($form['#node']->nid) ? language_default()->langcode : $node->language, + ); + } + $form['additional_settings'] = array( '#type' => 'vertical_tabs', '#weight' => 99, diff --git a/core/modules/path/path.test b/core/modules/path/path.test index d5a18d3..f8fb8cf 100644 --- a/core/modules/path/path.test +++ b/core/modules/path/path.test @@ -260,7 +260,7 @@ class PathLanguageTestCase extends DrupalWebTestCase { */ function testAliasTranslation() { // Set 'page' content type to enable translation. - variable_set('language_content_type_page', 2); + variable_set('node_type_language_page', 2); $english_node = $this->drupalCreateNode(array('type' => 'page')); $english_alias = $this->randomName(); diff --git a/core/modules/translation/translation.module b/core/modules/translation/translation.module index 30ceee8..c07446a 100644 --- a/core/modules/translation/translation.module +++ b/core/modules/translation/translation.module @@ -111,9 +111,10 @@ function translation_permission() { */ function translation_form_node_type_form_alter(&$form, &$form_state) { // Add translation option to content type form. - $form['workflow']['language_content_type']['#options'][TRANSLATION_ENABLED] = t('Enabled, with translation'); - // Description based on text from locale.module. - $form['workflow']['language_content_type']['#description'] = t('Enable multilingual support for this content type. If enabled, a language selection field will be added to the editing form, allowing you to select from one of the enabled languages. You can also turn on translation for this content type, which lets you have content translated to any of the installed languages. If disabled, new posts are saved with the default language. Existing content will not be affected by changing this option.', array('!languages' => url('admin/config/regional/language'))); + $form['workflow']['node_type_language']['#type'] = 'radios'; + $form['workflow']['node_type_language']['#options'] = array(t('Disabled'), t('Enabled'), TRANSLATION_ENABLED => t('Enabled, with translation')); + // Description based on text from node.module. + $form['workflow']['node_type_language']['#description'] = t('Add a language selection field to the editing form, allowing you to select from one of the enabled languages. You can also turn on translation for this content type, which lets you have content translated to any of the installed languages. If disabled, new posts are saved with the default language. Existing content will not be affected by changing this option.', array('!languages' => url('admin/international/language'))); } /** @@ -475,7 +476,7 @@ function translation_node_get_translations($tnid) { * Boolean value. */ function translation_supported_type($type) { - return variable_get('language_content_type_' . $type, 0) == TRANSLATION_ENABLED; + return variable_get('node_type_language_' . $type, 0) == TRANSLATION_ENABLED; } /** diff --git a/core/modules/translation/translation.test b/core/modules/translation/translation.test index cebe9a5..eeee661 100644 --- a/core/modules/translation/translation.test +++ b/core/modules/translation/translation.test @@ -38,7 +38,7 @@ class TranslationTestCase extends DrupalWebTestCase { // translation. $this->drupalGet('admin/structure/types/manage/page'); $edit = array(); - $edit['language_content_type'] = 2; + $edit['node_type_language'] = 2; $this->drupalPost('admin/structure/types/manage/page', $edit, t('Save content type')); $this->assertRaw(t('The content type %type has been updated.', array('%type' => 'Basic page')), t('Basic page content type has been updated.')); @@ -231,7 +231,7 @@ class TranslationTestCase extends DrupalWebTestCase { // Disable translation support to check that the language switcher is left // untouched only for new nodes. $this->drupalLogin($this->admin_user); - $edit = array('language_content_type' => 0); + $edit = array('node_type_language' => 0); $this->drupalPost('admin/structure/types/manage/page', $edit, t('Save content type')); $this->drupalLogin($this->translator);