diff -u b/core/includes/install.core.inc b/core/includes/install.core.inc --- b/core/includes/install.core.inc +++ b/core/includes/install.core.inc @@ -1307,7 +1307,6 @@ */ function install_select_language_form($form, &$form_state, $files) { include_once DRUPAL_ROOT . '/core/includes/standard.inc'; - include_once DRUPAL_ROOT . '/core/modules/language/language.module'; include_once DRUPAL_ROOT . '/core/modules/language/language.negotiation.inc'; $standard_languages = standard_language_list(); @@ -1369,6 +1368,7 @@ */ function install_select_language_form($form, &$form_state, $files) { include_once DRUPAL_ROOT . '/core/includes/standard.inc'; + include_once DRUPAL_ROOT . '/core/modules/language/language.module'; include_once DRUPAL_ROOT . '/core/modules/language/language.negotiation.inc'; $standard_languages = standard_language_list(); diff -u b/core/modules/language/language.admin.inc b/core/modules/language/language.admin.inc --- b/core/modules/language/language.admin.inc +++ b/core/modules/language/language.admin.inc @@ -821,7 +821,6 @@ $form = array(); // Initialize a language list to the ones available, including English. - drupal_static_reset('language_list'); $languages = language_list(); $existing_languages = array(); @@ -845,7 +844,6 @@ } $form['mappings'] = array( - '#type' => 'container', '#tree' => TRUE, '#theme' => 'language_negotiation_configure_browser_form_table', ); @@ -890,8 +888,6 @@ '#default_value' => '', ); - $form_state['redirect'] = 'admin/config/regional/language/detection'; - $form['actions']['#type'] = 'actions'; $form['actions']['submit'] = array( '#type' => 'submit', @@ -954,10 +950,10 @@ foreach ($mappings as $key => $data) { // Make sure browser_langcode is unique. if (array_key_exists($data['browser_langcode'], $unique_values)) { - form_set_error('mappings][' . $key . '][browser_langcode', 'Browser language codes must be unique.'); + form_set_error('mappings][' . $key . '][browser_langcode', t('Browser language codes must be unique.')); } elseif (preg_match('/[^a-z\-]/', $data['browser_langcode'])) { - form_set_error('mappings][' . $key . '][browser_langcode', 'Browser language codes can only contain lowercase letters and a hyphen(-).'); + form_set_error('mappings][' . $key . '][browser_langcode', t('Browser language codes can only contain lowercase letters and a hyphen(-).')); } $unique_values[$data['browser_langcode']] = $data['drupal_langcode']; } @@ -968,10 +964,10 @@ if (!empty($data['browser_langcode'])) { // Make sure browser_langcode is unique. if (array_key_exists($data['browser_langcode'], $unique_values)) { - form_set_error('mappings][' . $key . '][browser_langcode', 'Browser language codes must be unique.'); + form_set_error('mappings][' . $key . '][browser_langcode', t('Browser language codes must be unique.')); } elseif (preg_match('/[^a-z\-]/', $data['browser_langcode'])) { - form_set_error('mappings][' . $key . '][browser_langcode', 'Browser language codes can only contain lowercase letters and a hyphen(-).'); + form_set_error('mappings][' . $key . '][browser_langcode', t('Browser language codes can only contain lowercase letters and a hyphen(-).')); } $unique_values[$data['browser_langcode']] = $data['drupal_langcode']; } @@ -987,6 +983,7 @@ if (!empty($mappings)) { language_set_browser_drupal_langcode_mappings($mappings); } + $form_state['redirect'] = 'admin/config/regional/language/detection'; } /** diff -u b/core/modules/language/language.module b/core/modules/language/language.module --- b/core/modules/language/language.module +++ b/core/modules/language/language.module @@ -616,8 +616,7 @@ function language_get_browser_drupal_langcode_mappings() { $config = config('language.mappings'); if ($config->isNew()) { - config_install_default_config('module', 'language'); - $config = config('language.mappings'); + return array(); } return $config->get(); } diff -u b/core/modules/language/language.negotiation.inc b/core/modules/language/language.negotiation.inc --- b/core/modules/language/language.negotiation.inc +++ b/core/modules/language/language.negotiation.inc @@ -126,7 +126,10 @@ asort($browser_langcodes); foreach ($browser_langcodes as $langcode => $qvalue) { // For Chinese languages the generic tag is either zh-hans or zh-hant, so we - // need to handle this separately. + // need to handle this separately, we can not split $langcode on the + // first occurence of '-' otherwise we get a non-existing language zh. + // All other languages use a langcode without a '-', so we can safely split + // on the first occurence of it. $generic_tag = ''; if (strlen($langcode) > 7 && (substr($langcode, 0, 7) == 'zh-hant' || substr($langcode, 0, 7) == 'zh-hans')) { $generic_tag = substr($langcode, 0, 7); diff -u b/core/modules/language/lib/Drupal/language/Tests/LanguageBrowserDetectionUnitTest.php b/core/modules/language/lib/Drupal/language/Tests/LanguageBrowserDetectionUnitTest.php --- b/core/modules/language/lib/Drupal/language/Tests/LanguageBrowserDetectionUnitTest.php +++ b/core/modules/language/lib/Drupal/language/Tests/LanguageBrowserDetectionUnitTest.php @@ -184,7 +184,7 @@ $message = t('Are you sure you want to delete @browser_langcode?', array( '@browser_langcode' => $browser_langcode, )); - $this->assertRaw($message, 'Question found.'); + $this->assertRaw($message); // Confirm the delete. $edit = array(); @@ -199,12 +199,13 @@ 'new_mapping[drupal_langcode]' => 'en', ); $this->drupalPost('admin/config/regional/language/detection/browser', $edit, t('Save configuration')); + $this->drupalGet('admin/config/regional/language/detection/browser'); $this->assertField('edit-mappings-xx-browser-langcode', 'xx', 'Browser language code found.'); $this->assertField('edit-mappings-xx-drupal-langcode', 'en', 'Drupal language code found.'); // Add the same custom mapping again. $this->drupalPost('admin/config/regional/language/detection/browser', $edit, t('Save configuration')); - $this->assertText('Browser language codes must be unique.', 'Error message displayed.'); + $this->assertText('Browser language codes must be unique.'); // Change browser language code of our custom mapping to zh-sg. $edit = array( @@ -212,7 +213,7 @@ 'mappings[xx][drupal_langcode]' => 'en', ); $this->drupalPost('admin/config/regional/language/detection/browser', $edit, t('Save configuration')); - $this->assertText(t('Browser language codes must be unique.'), 'Error message displayed.'); + $this->assertText(t('Browser language codes must be unique.')); // Change Drupal language code of our custom mapping to zh-hans. $edit = array( @@ -220,6 +221,7 @@ 'mappings[xx][drupal_langcode]' => 'zh-hans', ); $this->drupalPost('admin/config/regional/language/detection/browser', $edit, t('Save configuration')); + $this->drupalGet('admin/config/regional/language/detection/browser'); $this->assertField('edit-mappings-xx-browser-langcode', 'xx', 'Browser language code found.'); $this->assertField('edit-mappings-xx-drupal-langcode', 'zh-hans', 'Drupal language code found.'); }