Commit 77bd8f4c authored by Dries's avatar Dries

- Patch #1260860 by Gábor Hojtsy, sun: rework language list admin user interface.

parent 3fe00209
......@@ -769,14 +769,7 @@ function _locale_prepare_predefined_list() {
unset($predefined[$key]);
continue;
}
// Include native name in output, if possible
if (count($value) > 1) {
$tname = t($value[0]);
$predefined[$key] = ($tname == $value[1]) ? $tname : "$tname ($value[1])";
}
else {
$predefined[$key] = t($value[0]);
}
$predefined[$key] = t($value[0]);
}
asort($predefined);
return $predefined;
......
......@@ -17,50 +17,105 @@
/**
* User interface for the language overview screen.
*/
function locale_languages_overview_form() {
function locale_language_overview_form($form, &$form_state) {
drupal_static_reset('language');
$languages = language_list('language');
$default = language_default();
$options = array();
$form['weight'] = array('#tree' => TRUE);
foreach ($languages as $langcode => $language) {
$form['languages'] = array(
'#languages' => $languages,
'#language_default' => $default,
'#tree' => TRUE,
'#header' => array(
t('Name'),
t('Enabled'),
t('Default'),
t('Weight'),
t('Operations'),
),
'#theme' => 'locale_language_overview_form_table',
);
$options[$langcode] = '';
if ($language->enabled) {
$enabled[] = $langcode;
}
$form['weight'][$langcode] = array(
foreach ($languages as $langcode => $language) {
$form['languages'][$langcode]['#weight'] = $language->weight;
$form['languages'][$langcode]['name'] = array(
'#markup' => check_plain($language->name),
);
$form['languages'][$langcode]['enabled'] = array(
'#type' => 'checkbox',
'#title' => t('Enable @title', array('@title' => $language->name)),
'#title_display' => 'invisible',
'#default_value' => (int) $language->enabled,
'#disabled' => $langcode == $default->language,
);
$form['languages'][$langcode]['default'] = array(
'#type' => 'radio',
'#parents' => array('site_default'),
'#title' => t('Set @title as default', array('@title' => $language->name)),
'#title_display' => 'invisible',
'#return_value' => $langcode,
'#default_value' => ($langcode == $default->language ? $langcode : NULL),
'#id' => 'edit-site-default-' . $langcode,
);
$form['languages'][$langcode]['weight'] = array(
'#type' => 'weight',
'#title' => t('Weight for @title', array('@title' => $language->name)),
'#title_display' => 'invisible',
'#default_value' => $language->weight,
'#attributes' => array('class' => array('language-order-weight')),
'#attributes' => array(
'class' => array('language-order-weight'),
),
);
$form['name'][$langcode] = array('#markup' => check_plain($language->name));
$form['native'][$langcode] = array('#markup' => check_plain($language->native));
$form['direction'][$langcode] = array('#markup' => ($language->direction == LANGUAGE_RTL ? t('Right to left') : t('Left to right')));
}
$form['enabled'] = array(
'#type' => 'checkboxes',
'#title' => t('Enabled languages'),
'#title_display' => 'invisible',
'#options' => $options,
'#default_value' => $enabled,
);
$form['site_default'] = array(
'#type' => 'radios',
'#title' => t('Default language'),
'#title_display' => 'invisible',
'#options' => $options,
'#default_value' => language_default()->language,
);
$form['languages'][$langcode]['operations'] = array(
'#theme_wrappers' => array('locale_language_operations'),
'#weight' => 100,
);
$form['languages'][$langcode]['operations']['edit'] = array(
'#type' => 'link',
'#title' => t('edit'),
'#href' => 'admin/config/regional/language/edit/' . $langcode,
);
$form['languages'][$langcode]['operations']['delete'] = array(
'#type' => 'link',
'#title' => t('delete'),
'#href' => 'admin/config/regional/language/delete/' . $langcode,
'#access' => $langcode != 'en' && $langcode != $default->language,
);
}
$form['actions'] = array('#type' => 'actions');
$form['actions']['submit'] = array('#type' => 'submit', '#value' => t('Save configuration'));
$form['#theme'] = 'locale_languages_overview_form';
$form['actions']['submit'] = array(
'#type' => 'submit',
'#value' => t('Save configuration'),
);
return $form;
}
/**
* Returns HTML for operation links in locale_language_overview_form() table.
*
* @todo Introduce #type '[table_]operations' or just simply #type 'links'.
*/
function theme_locale_language_operations($variables) {
$links = array();
foreach (element_children($variables['elements']) as $key) {
// Children are only rendered if the current user has access.
if (isset($variables['elements'][$key]['#children'])) {
$links[$key] = $variables['elements'][$key]['#children'];
}
}
// If there are links, render a link list.
if (!empty($links)) {
return theme('item_list__operations', array(
'items' => $links,
'attributes' => array('class' => array('links', 'inline')),
));
}
// Otherwise, ensure to produce no output.
return '';
}
/**
* Returns HTML for the language overview form.
*
......@@ -70,43 +125,27 @@ function locale_languages_overview_form() {
*
* @ingroup themeable
*/
function theme_locale_languages_overview_form($variables) {
function theme_locale_language_overview_form_table($variables) {
$form = $variables['form'];
$default = language_default();
foreach ($form['name'] as $key => $element) {
// Do not take form control structures.
if (is_array($element) && element_child($key)) {
// Disable checkbox for the default language, because it cannot be disabled.
if ($key == $default->language) {
$form['enabled'][$key]['#attributes']['disabled'] = 'disabled';
}
// Add invisible labels for the checkboxes and radio buttons in the table
// for accessibility. These changes are only required and valid when the
// form is themed as a table, so it would be wrong to perform them in the
// form constructor.
$title = drupal_render($form['name'][$key]);
$form['enabled'][$key]['#title'] = t('Enable !title', array('!title' => $title));
$form['enabled'][$key]['#title_display'] = 'invisible';
$form['site_default'][$key]['#title'] = t('Set !title as default', array('!title' => $title));
$form['site_default'][$key]['#title_display'] = 'invisible';
$rows[] = array(
'data' => array(
'<strong>' . $title . '</strong>',
drupal_render($form['native'][$key]),
check_plain($key),
drupal_render($form['direction'][$key]),
array('data' => drupal_render($form['enabled'][$key]), 'align' => 'center'),
drupal_render($form['site_default'][$key]),
drupal_render($form['weight'][$key]),
l(t('edit'), 'admin/config/regional/language/edit/' . $key) . (($key != 'en' && $key != $default->language) ? ' ' . l(t('delete'), 'admin/config/regional/language/delete/' . $key) : '')
),
'class' => array('draggable'),
);
$rows = array();
foreach (element_children($form, TRUE) as $langcode) {
$element = &$form[$langcode];
$row = array(
'class' => array('draggable'),
);
foreach (element_children($element, TRUE) as $column) {
$cell = &$element[$column];
$row['data'][] = drupal_render($cell);
}
$rows[] = $row;
}
$header = array(array('data' => t('English name')), array('data' => t('Native name')), array('data' => t('Code')), array('data' => t('Direction')), array('data' => t('Enabled')), array('data' => t('Default')), array('data' => t('Weight')), array('data' => t('Operations')));
$output = theme('table', array('header' => $header, 'rows' => $rows, 'attributes' => array('id' => 'language-order')));
$output = theme('table', array(
'header' => $form['#header'],
'rows' => $rows,
'attributes' => array('id' => 'language-order'),
));
$output .= drupal_render_children($form);
drupal_add_tabledrag('language-order', 'order', 'sibling', 'language-order-weight');
......@@ -117,22 +156,22 @@ function theme_locale_languages_overview_form($variables) {
/**
* Process language overview form submissions, updating existing languages.
*/
function locale_languages_overview_form_submit($form, &$form_state) {
function locale_language_overview_form_submit($form, &$form_state) {
$languages = language_list();
$old_default = language_default();
$url_prefixes = variable_get('locale_language_negotiation_url_part', LOCALE_LANGUAGE_NEGOTIATION_URL_PREFIX) == LOCALE_LANGUAGE_NEGOTIATION_URL_PREFIX;
foreach ($languages as $langcode => $language) {
$language->default = ($form_state['values']['site_default'] == $langcode);
$language->weight = $form_state['values']['weight'][$langcode];
$language->weight = $form_state['values']['languages'][$langcode]['weight'];
if ($language->default || $old_default->language == $langcode) {
// Automatically enable the default language and the language
// which was default previously (because we will not get the
// value from that disabled checkbox).
$form_state['values']['enabled'][$langcode] = 1;
$form_state['values']['languages'][$langcode]['enabled'] = 1;
}
$language->enabled = (int) !empty($form_state['values']['enabled'][$langcode]);
$language->enabled = (int) !empty($form_state['values']['languages'][$langcode]['enabled']);
// If language URL prefixes are enabled we must clear language domains and
// assign a valid prefix to each non-default language.
......@@ -147,7 +186,6 @@ function locale_languages_overview_form_submit($form, &$form_state) {
}
drupal_set_message(t('Configuration saved.'));
$form_state['redirect'] = 'admin/config/regional/language';
}
/**
......
......@@ -36,28 +36,34 @@ function locale_help($path, $arg) {
$output .= '<dd>' . t("Language negotiation allows your site to automatically change language based on the domain or path used for each request. Users may (optionally) select their preferred language on their <em>My account</em> page, and your site can be configured to honor a web browser's preferred language settings. Site content can be translated using the <a href='@content-help'>Content translation module</a>.", array('@content-help' => url('admin/help/translation'))) . '</dd>';
$output .= '</dl>';
return $output;
case 'admin/config/regional/language':
$output = '<p>' . t('With multiple languages enabled, interface text can be translated, registered users may select their preferred language, and authors can assign a specific language to content. <a href="@translations">Download contributed translations</a> from Drupal.org.', array('@translations' => 'http://localize.drupal.org')) . '</p>';
return $output;
case 'admin/config/regional/language/add':
return '<p>' . t('Add a language to be supported by your site. If your desired language is not available in the <em>Language name</em> drop-down, click <em>Custom language</em> and provide a language code and other details manually. When providing a language code manually, be sure to enter a standardized language code, since this code may be used by browsers to determine an appropriate display language.') . '</p>';
case 'admin/config/regional/language/configure':
$output = '<p>' . t("Define how to decide which language is used to display page elements (primarily text provided by Drupal and modules, such as field labels and help text). This decision is made by evaluating a series of detection methods for languages; the first detection method that gets a result will determine which language is used for that type of text. Define the order of evaluation of language detection methods on this page.") . '</p>';
return $output;
case 'admin/config/regional/language/configure/session':
$output = '<p>' . t('Determine the language from a request/session parameter. Example: "http://example.com?language=de" sets language to German based on the use of "de" within the "language" parameter.') . '</p>';
return $output;
case 'admin/config/regional/translate':
$output = '<p>' . t('This page provides an overview of available translatable strings. See the <a href="@languages">Languages page</a> for more information on adding support for additional languages.', array('@languages' => url('admin/config/regional/language'))) . '</p>';
$output = '<p>' . t('This page allows a translator to search for specific translated and untranslated strings, and is used when creating or editing translations. (Note: For translation tasks involving many strings, it may be more convenient to <a href="@export">export</a> strings for offline editing in a desktop Gettext translation editor.) Searches may be limited to strings in a specific language.', array('@export' => url('admin/config/regional/translate/export'))) . '</p>';
return $output;
case 'admin/config/regional/translate/import':
$output = '<p>' . t('This page imports the translated strings contained in an individual Gettext Portable Object (<em>.po</em>) file. Normally distributed as part of a translation package (each translation package may contain several <em>.po</em> files), a <em>.po</em> file may need to be imported after offline editing in a Gettext translation editor. Importing an individual <em>.po</em> file may be a lengthy process.') . '</p>';
$output .= '<p>' . t('Note that the <em>.po</em> files within a translation package are imported automatically (if available) when new modules or themes are enabled, or as new languages are added. Since this page only allows the import of one <em>.po</em> file at a time, it may be simpler to download and extract a translation package into your Drupal installation directory and <a href="@language-add">add the language</a> (which automatically imports all <em>.po</em> files within the package). Translation packages are available for download on the <a href="@translations">Drupal translation page</a>.', array('@language-add' => url('admin/config/regional/language/add'), '@translations' => 'http://localize.drupal.org')) . '</p>';
return $output;
case 'admin/config/regional/translate/export':
return '<p>' . t('This page exports the translated strings used by your site. An export file may be in Gettext Portable Object (<em>.po</em>) form, which includes both the original string and the translation (used to share translations with others), or in Gettext Portable Object Template (<em>.pot</em>) form, which includes the original strings only (used to create new translations with a Gettext translation editor).') . '</p>';
case 'admin/config/regional/translate/translate':
return '<p>' . t('This page allows a translator to search for specific translated and untranslated strings, and is used when creating or editing translations. (Note: For translation tasks involving many strings, it may be more convenient to <a href="@export">export</a> strings for offline editing in a desktop Gettext translation editor.) Searches may be limited to strings in a specific language.', array('@export' => url('admin/config/regional/translate/export'))) . '</p>';
case 'admin/structure/block/manage/%/%':
if ($arg[4] == 'locale' && $arg[5] == 'language') {
return '<p>' . t('This block is only shown if <a href="@languages">at least two languages are enabled</a> and <a href="@configuration">language negotiation</a> is set to <em>URL</em> or <em>Session</em>.', array('@languages' => url('admin/config/regional/language'), '@configuration' => url('admin/config/regional/language/configure'))) . '</p>';
......@@ -75,7 +81,7 @@ function locale_menu() {
'title' => 'Languages',
'description' => 'Configure languages for content and the user interface.',
'page callback' => 'drupal_get_form',
'page arguments' => array('locale_languages_overview_form'),
'page arguments' => array('locale_language_overview_form'),
'access arguments' => array('administer languages'),
'file' => 'locale.admin.inc',
'weight' => -10,
......@@ -135,25 +141,17 @@ function locale_menu() {
// Translation functionality
$items['admin/config/regional/translate'] = array(
'title' => 'Translate interface',
'description' => 'Translate the built in interface and optionally other text.',
'page callback' => 'locale_translate_overview_screen',
'title' => 'User interface translation',
'description' => 'Translate the built-in user interface.',
'page callback' => 'locale_translate_seek_screen',
'access arguments' => array('translate interface'),
'file' => 'locale.pages.inc',
'weight' => -5,
);
$items['admin/config/regional/translate/overview'] = array(
'title' => 'Overview',
'weight' => 0,
'type' => MENU_DEFAULT_LOCAL_TASK,
);
$items['admin/config/regional/translate/translate'] = array(
'title' => 'Translate',
'weight' => 10,
'type' => MENU_LOCAL_TASK,
'page callback' => 'locale_translate_seek_screen', // search results and form concatenated
'access arguments' => array('translate interface'),
'file' => 'locale.pages.inc',
'weight' => -10,
'type' => MENU_DEFAULT_LOCAL_TASK,
);
$items['admin/config/regional/translate/import'] = array(
'title' => 'Import',
......@@ -393,8 +391,13 @@ function locale_field_node_form_submit($form, &$form_state) {
*/
function locale_theme() {
return array(
'locale_languages_overview_form' => array(
'locale_language_overview_form_table' => array(
'render element' => 'form',
'file' => 'locale.admin.inc',
),
'locale_language_operations' => array(
'render element' => 'elements',
'file' => 'locale.admin.inc',
),
'locale_languages_configure_form' => array(
'render element' => 'form',
......@@ -1056,3 +1059,49 @@ function locale_form_comment_form_alter(&$form, &$form_state, $form_id) {
$form['language']['#value'] = $language_content->language;
}
}
/**
* Implements hook_form_FORM_ID_alter() for locale_language_overview_form().
*/
function locale_form_locale_language_overview_form_alter(&$form, &$form_state) {
$languages = $form['languages']['#languages'];
$total_strings = db_query("SELECT COUNT(*) FROM {locales_source}")->fetchField();
$stats = array_fill_keys(array_keys($languages), array());
// If we have source strings, count translations and calculate progress.
if (!empty($total_strings)) {
$translations = db_query("SELECT COUNT(*) AS translated, t.language FROM {locales_source} s INNER JOIN {locales_target} t ON s.lid = t.lid GROUP BY language");
foreach ($translations as $data) {
$stats[$data->language]['translated'] = $data->translated;
if ($data->translated > 0) {
$stats[$data->language]['ratio'] = round($data->translated / $total_strings * 100, 2);
}
}
}
array_splice($form['languages']['#header'], -1, 0, t('Interface translation'));
foreach ($languages as $langcode => $language) {
$stats[$langcode] += array(
'translated' => 0,
'ratio' => 0,
);
if ($langcode != 'en') {
$form['languages'][$langcode]['locale_statistics'] = array(
'#type' => 'link',
'#title' => t('@translated/@total (@ratio%)', array(
'@translated' => $stats[$langcode]['translated'],
'@total' => $total_strings,
'@ratio' => $stats[$langcode]['ratio'],
)),
'#href' => 'admin/config/regional/translate/translate',
);
}
else {
$form['languages'][$langcode]['locale_statistics'] = array(
'#markup' => t('built-in'),
);
}
}
}
......@@ -5,37 +5,6 @@
* Interface translation summary, editing and deletion user interfaces.
*/
/**
* Overview screen for translations.
*/
function locale_translate_overview_screen() {
drupal_static_reset('language_list');
$languages = language_list('language');
$headers = array(t('Language'), t('Interface translation status'));
$num_strings = db_query("SELECT COUNT(*) FROM {locales_source}")->fetchField();
// Set up overview table with default values, ensuring common order for values.
$rows = array();
foreach ($languages as $langcode => $language) {
$rows[$langcode] = array(
'name' => ($langcode == 'en' ? t('English (built-in)') : t($language->name)),
'status' => ($langcode == 'en' ? t('n/a') : '0/' . $num_strings . ' (0%)'),
);
}
if (!empty($num_strings)) {
// If we have source strings, match translations and compute progress. Not
// all languages may have information.
$translations = db_query("SELECT COUNT(*) AS translation, t.language FROM {locales_source} s INNER JOIN {locales_target} t ON s.lid = t.lid GROUP BY language");
foreach ($translations as $data) {
$ratio = ($data->translation > 0) ? round(($data->translation/$num_strings) * 100.0, 2) : 0;
$rows[$data->language]['status'] = $data->translation . '/' . $num_strings . " ($ratio%)";
}
}
return theme('table', array('header' => $headers, 'rows' => $rows));
}
/**
* String search screen.
*/
......
......@@ -70,10 +70,8 @@ class LocaleConfigurationTest extends DrupalWebTestCase {
);
$this->drupalPost('admin/config/regional/language/add', $edit, t('Add custom language'));
$this->assertEqual($this->getUrl(), url('admin/config/regional/language', array('absolute' => TRUE)), t('Correct page redirection.'));
$this->assertText($langcode, t('Language code found.'));
$this->assertText($name, t('Name found.'));
$this->assertText($native, t('Native found.'));
$this->assertText($native, t('Test language added.'));
$this->assertRaw('"edit-site-default-' . $langcode .'"', t('Language code found.'));
$this->assertText(t($name), t('Test language added.'));
// Check if we can change the default language.
$path = 'admin/config/regional/language';
......@@ -99,17 +97,17 @@ class LocaleConfigurationTest extends DrupalWebTestCase {
// Check if we can disable a language.
$edit = array(
'enabled[en]' => FALSE,
'languages[en][enabled]' => FALSE,
);
$this->drupalPost($path, $edit, t('Save configuration'));
$this->assertNoFieldChecked('edit-enabled-en', t('Language disabled.'));
$this->assertNoFieldChecked('edit-languages-en-enabled', t('Language disabled.'));
// Set disabled language to be the default and ensure it is re-enabled.
$edit = array(
'site_default' => 'en',
);
$this->drupalPost(NULL, $edit, t('Save configuration'));
$this->assertFieldChecked('edit-enabled-en', t('Default language re-enabled.'));
$this->assertFieldChecked('edit-languages-en-enabled', t('Default language re-enabled.'));
// Ensure 'edit' link works.
$this->clickLink(t('edit'));
......@@ -149,10 +147,10 @@ class LocaleConfigurationTest extends DrupalWebTestCase {
// Delete a disabled language.
// Disable an enabled language.
$edit = array(
'enabled[fr]' => FALSE,
'languages[fr][enabled]' => FALSE,
);
$this->drupalPost($path, $edit, t('Save configuration'));
$this->assertNoFieldChecked('edit-enabled-fr', t('French language disabled.'));
$this->assertNoFieldChecked('edit-languages-fr-enabled', t('French language disabled.'));
// Get the count of enabled languages.
drupal_static_reset('language_list');
$enabled = language_list('enabled');
......@@ -294,12 +292,8 @@ class LocaleTranslationFunctionalTest extends DrupalWebTestCase {
t($name, array(), array('langcode' => $langcode));
// Reset locale cache.
locale_reset();
$this->assertText($langcode, t('Language code found.'));
$this->assertText($name, t('Name found.'));
$this->assertText($native, t('Native found.'));
// No t() here, we do not want to add this string to the database and it's
// surely not translated yet.
$this->assertText($native, t('Test language added.'));
$this->assertRaw('"edit-site-default-' . $langcode .'"', t('Language code found.'));
$this->assertText(t($name), t('Test language added.'));
$this->drupalLogout();
// Search for the name and translate it.
......@@ -1404,7 +1398,7 @@ class LocaleUserLanguageFunctionalTest extends DrupalWebTestCase {
$this->drupalPost('admin/config/regional/language/add', $edit, t('Add custom language'));
// Disable the language.
$edit = array(
'enabled[' . $langcode_disabled . ']' => FALSE,
'languages[' . $langcode_disabled . '][enabled]' => FALSE,
);
$this->drupalPost('admin/config/regional/language', $edit, t('Save configuration'));
$this->drupalLogout();
......@@ -1740,7 +1734,7 @@ class LocaleContentFunctionalTest extends DrupalWebTestCase {
// Disable second custom language.
$path = 'admin/config/regional/language';
$edit = array(
'enabled[' . $langcode_disabled . ']' => FALSE,
'languages[' . $langcode_disabled . '][enabled]' => FALSE,
);
$this->drupalPost($path, $edit, t('Save configuration'));
......@@ -2079,7 +2073,7 @@ class LocaleUrlRewritingTest extends DrupalWebTestCase {
$this->drupalPost('admin/config/regional/language/add', $edit, t('Add language'));
// Disable Italian language.
$edit = array('enabled[it]' => FALSE);
$edit = array('languages[it][enabled]' => FALSE);
$this->drupalPost('admin/config/regional/language', $edit, t('Save configuration'));
// Enable URL language detection and selection.
......
......@@ -472,7 +472,7 @@ class PathMonolingualTestCase extends DrupalWebTestCase {
$this->drupalPost('admin/config/regional/language', $edit, t('Save configuration'));
// Disable English.
$edit = array('enabled[en]' => FALSE);
$edit = array('languages[en][enabled]' => FALSE);
$this->drupalPost('admin/config/regional/language', $edit, t('Save configuration'));
// Verify that French is the only language.
......
......@@ -450,7 +450,7 @@ class SearchRankingTestCase extends DrupalWebTestCase {
function testHTMLRankings() {
// Login with sufficient privileges.
$this->drupalLogin($this->drupalCreateUser(array('create page content')));
// Test HTML tags with different weights.
$sorted_tags = array('h1', 'h2', 'h3', 'h4', 'a', 'h5', 'h6', 'notag');
$shuffled_tags = $sorted_tags;
......@@ -482,7 +482,7 @@ class SearchRankingTestCase extends DrupalWebTestCase {
// Refresh variables after the treatment.
$this->refreshVariables();
// Disable all other rankings.
$node_ranks = array('sticky', 'promote', 'recent', 'comments', 'views');
foreach ($node_ranks as $node_rank) {
......@@ -520,7 +520,7 @@ class SearchRankingTestCase extends DrupalWebTestCase {
// Assert the results.
$this->assertEqual($set[0]['node']->nid, $node->nid, 'Search tag ranking for "&lt;' . $tag . '&gt;" order.');
// Delete node so it doesn't show up in subsequent search results.
node_delete($node->nid);
}
......@@ -861,7 +861,7 @@ class SearchCommentTestCase extends DrupalWebTestCase {
$this->setRolePermissions(DRUPAL_AUTHENTICATED_RID, TRUE, TRUE);
$this->setRolePermissions($this->admin_role, TRUE, FALSE);
$this->checkCommentAccess('Admin user has access comments permission and no search permission, but comments should be indexed because admin user inherits authenticated user\'s permission to search', TRUE);
}
/**
......@@ -1938,9 +1938,9 @@ class SearchLanguageTestCase extends DrupalWebTestCase {
$edit = array('site_default' => 'fr');
$this->drupalPost(NULL, $edit, t('Save configuration'));
$this->assertNoFieldChecked('edit-site-default-en', t('Default language updated.'));
$edit = array('enabled[en]' => FALSE);
$edit = array('languages[en][enabled]' => FALSE);
$this->drupalPost('admin/config/regional/language', $edit, t('Save configuration'));
$this->assertNoFieldChecked('edit-enabled-en', t('Language disabled.'));
$this->assertNoFieldChecked('edit-languages-en-enabled', t('Language disabled.'));
// Check that there are again no languages displayed.
$this->drupalGet('search/node');
......
......@@ -31,7 +31,7 @@ class TranslationTestCase extends DrupalWebTestCase {
$this->addLanguage('it');
// Disable Italian to test the translation behavior with disabled languages.
$edit = array('enabled[it]' => FALSE);
$edit = array('languages[it][enabled]' => FALSE);
$this->drupalPost('admin/config/regional/language', $edit, t('Save configuration'));
// Set "Basic page" content type to use multilingual support with
......@@ -143,7 +143,7 @@ class TranslationTestCase extends DrupalWebTestCase {
// Leave just one language enabled and check that the translation overview
// page is still accessible.
$this->drupalLogin($this->admin_user);
$edit = array('enabled[es]' => FALSE);
$edit = array('languages[es][enabled]' => FALSE);
$this->drupalPost('admin/config/regional/language', $edit, t('Save configuration'));
$this->drupalLogin($this->translator);
$this->drupalGet('node/' . $node->nid . '/translate');
......@@ -197,7 +197,7 @@ class TranslationTestCase extends DrupalWebTestCase {
function testLanguageSwitcherBlockIntegration() {
// Enable Italian to have three items in the language switcher block.
$this->drupalLogin($this->admin_user);
$edit = array('enabled[it]' => TRUE);
$edit = array('languages[it][enabled]' => TRUE);
$this->drupalPost('admin/config/regional/language', $edit, t('Save configuration'));
$this->drupalLogin($this->translator);
......@@ -278,7 +278,7 @@ class TranslationTestCase extends DrupalWebTestCase {
// Check to make sure that language has not already been installed.
$this->drupalGet('admin/config/regional/language');
if (strpos($this->drupalGetContent(), 'enabled[' . $language_code . ']') === FALSE) {
if (strpos($this->drupalGetContent(), 'languages[' . $language_code . '][enabled]') === FALSE) {
// Doesn't have language installed so add it.
$edit = array();
$edit['langcode'] = $language_code;
......@@ -293,14 +293,14 @@ class TranslationTestCase extends DrupalWebTestCase {
$this->assertRaw(t('The language %language has been created and can now be used. More information is available on the <a href="@locale-help">help screen</a>.', array('%language' => $languages[$language_code]->name, '@locale-help' => url('admin/help/locale'))), t('Language has been created.'));
}
}
elseif ($this->xpath('//input[@type="checkbox" and @name=:name and @checked="checked"]', array(':name' => 'enabled[' . $language_code . ']'))) {
elseif ($this->xpath('//input[@type="checkbox" and @name=:name and @checked="checked"]', array(':name' => 'languages[' . $language_code . '][enabled]'))) {
// It's installed and enabled. No need to do anything.
$this->assertTrue(true, 'Language [' . $language_code . '] already installed and enabled.');
}
else {
// It's installed but not enabled. Enable it.
$this->assertTrue(true, 'Language [' . $language_code . '] already installed.');
$this->drupalPost(NULL, array('enabled[' . $language_code . ']' => TRUE), t('Save configuration'));
$this->drupalPost(NULL, array('languages[' . $language_code . '][enabled]' => TRUE), t('Save configuration'));
$this->assertRaw(t('Configuration saved.'), t('Language successfully enabled.'));
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment