diff --git a/core/modules/field/modules/text/text.test b/core/modules/field/modules/text/text.test index 979079a..cffd972 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('node_type_language' => TRANSLATION_ENABLED); + $edit = array('node_type_language_translatable' => TRANSLATION_ENABLED); $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/node/content_types.inc b/core/modules/node/content_types.inc index e2440d3..fe4747a 100644 --- a/core/modules/node/content_types.inc +++ b/core/modules/node/content_types.inc @@ -188,10 +188,46 @@ 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', + $form['language'] = array( + '#type' => 'fieldset', '#title' => t('Multilingual support'), - '#default_value' => variable_get('node_type_language_' . $type->type, 0), + '#collapsible' => TRUE, + '#collapsed' => TRUE, + '#group' => 'additional_settings', + ); + $form['language']['node_type_language_locked'] = array( + '#type' => 'checkbox', + '#title' => t('Locked'), + '#default_value' => variable_get('node_type_language_locked_' . $type->type, 0), + ); + // Build two lists with the disabled and enabled languages. + $languages = language_list(); + $grouped_languages = array(); + foreach ($languages as $langcode => $language) { + $grouped_languages[(int) $language->enabled][$langcode] = $language; + } + $groups = array(t('Disabled languages'), t('Enabled languages')); + // Allow translators to enter content in disabled languages. Translators + // might need to distinguish between enabled and disabled languages, hence + // we divide them in two option groups. + $options[t('Special options')] = array( + LANGUAGE_NONE => t('- None -'), + 'site_default' => t('- Site default -'), + 'current' => t('- Current -'), + ); + foreach (array(1, 0) as $status) { + if (isset($grouped_languages[$status])) { + $group = $groups[$status]; + foreach ($grouped_languages[$status] as $langcode => $language) { + $options[$group][$langcode] = $language->name; + } + } + } + $form['language']['node_type_language_default'] = array( + '#type' => 'select', + '#title' => t('Default'), + '#options' => $options, + '#default_value' => variable_get('node_type_language_default_' . $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/config/regional/language'))), ); } @@ -254,6 +290,24 @@ function node_type_form($form, &$form_state, $type = NULL) { } /** + * + */ +function node_type_get_type_default_language($type) { + $default_language = variable_get('node_type_language_default_' . $type, LANGUAGE_NONE); + + switch ($default_language) { + case 'site_default': + return language_from_default(); + + case 'current': + global $language; + return $language->langcode; + } + + return $default_language; +} + +/** * Helper function for teaser length choices. */ function _node_characters($length) { diff --git a/core/modules/node/node.pages.inc b/core/modules/node/node.pages.inc index ab8b5f1..7a9a84f 100644 --- a/core/modules/node/node.pages.inc +++ b/core/modules/node/node.pages.inc @@ -87,7 +87,8 @@ function node_add($type) { global $user; $types = node_type_get_types(); - $node = (object) array('uid' => $user->uid, 'name' => (isset($user->name) ? $user->name : ''), 'type' => $type, 'language' => LANGUAGE_NONE); + module_load_include('inc', 'node', 'content_types'); + $node = (object) array('uid' => $user->uid, 'name' => (isset($user->name) ? $user->name : ''), 'type' => $type, 'language' => node_type_get_type_default_language($type)); drupal_set_title(t('Create @name', array('@name' => $types[$type]->name)), PASS_THROUGH); $output = drupal_get_form($type . '_node_form', $node); @@ -181,7 +182,7 @@ 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')) { + if (module_exists('language')) { $languages = language_list(TRUE); $language_options = array(); foreach ($languages as $langcode => $language) { @@ -193,6 +194,7 @@ function node_form($form, &$form_state, $node) { '#default_value' => (isset($node->language) ? $node->language : ''), '#options' => $language_options, '#empty_value' => LANGUAGE_NONE, + '#disabled' => variable_get('node_type_language_locked_' . $node->type, TRUE), ); } else { diff --git a/core/modules/poll/poll.test b/core/modules/poll/poll.test index 0c406f0..b1e15eb 100644 --- a/core/modules/poll/poll.test +++ b/core/modules/poll/poll.test @@ -843,7 +843,7 @@ class PollTranslateTestCase extends PollTestCase { // Set "Poll" content type to use multilingual support with translation. $this->drupalGet('admin/structure/types/manage/poll'); $edit = array(); - $edit['node_type_language'] = TRANSLATION_ENABLED; + $edit['node_type_language_translatable'] = TRANSLATION_ENABLED; $this->drupalPost('admin/structure/types/manage/poll', $edit, t('Save content type')); $this->assertRaw(t('The content type %type has been updated.', array('%type' => 'Poll')), t('Poll content type has been updated.')); diff --git a/core/modules/translation/translation.module b/core/modules/translation/translation.module index 2b2a6ff..5082c6c 100644 --- a/core/modules/translation/translation.module +++ b/core/modules/translation/translation.module @@ -111,10 +111,11 @@ function translation_permission() { */ function translation_form_node_type_form_alter(&$form, &$form_state) { // Add translation option to content type form. - $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/config/regional/language'))); + $form['language']['node_type_language_translatable'] = array( + '#type' => 'checkbox', + '#title' => t('Enable translations'), + '#return_value' => TRANSLATION_ENABLED, + ); } /** @@ -476,7 +477,7 @@ function translation_node_get_translations($tnid) { * Boolean value. */ function translation_supported_type($type) { - return variable_get('node_type_language_' . $type, 0) == TRANSLATION_ENABLED; + return variable_get('node_type_language_translatable_' . $type, 0) == TRANSLATION_ENABLED; } /** diff --git a/core/modules/translation/translation.test b/core/modules/translation/translation.test index 64fede4..c247d70 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['node_type_language'] = TRANSLATION_ENABLED; + $edit['node_type_language_translatable'] = TRANSLATION_ENABLED; $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.'));