diff -u b/core/modules/language/config/language.mappings.yml b/core/modules/language/config/language.mappings.yml --- b/core/modules/language/config/language.mappings.yml +++ b/core/modules/language/config/language.mappings.yml @@ -2,8 +2,8 @@ # these defaults handles the most common cases. -zh-tw: zh-hant-tw # Taiwan Chinese in traditional script -zh-hk: zh-hant-hk # Hong Kong Chinese in traditional script -zh-mo: zh-hant-mo # Macao Chinese in traditional script +zh-tw: zh-hant # Taiwan Chinese in traditional script +zh-hk: zh-hant # Hong Kong Chinese in traditional script +zh-mo: zh-hant # Macao Chinese in traditional script zh-cht: zh-hant # traditional Chinese -zh-cn: zh-hans-cn # PRC Mainland Chinese in simplified script -zh-sg: zh-hans-sg # Singapore Chinese in simplified script +zh-cn: zh-hans # PRC Mainland Chinese in simplified script +zh-sg: zh-hans # Singapore Chinese in simplified script zh-chs: zh-hans # simplified Chinese 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 @@ -820,6 +820,30 @@ function language_negotiation_configure_browser_form($form, &$form_state) { $form = array(); + // Initialize a language list to the ones available, including English. + drupal_static_reset('language_list'); + $languages = language_list(); + + $existing_languages = array(); + foreach ($languages as $langcode => $language) { + $existing_languages[$langcode] = $language->name; + } + + // If we have no languages available, present the list of predefined languages + // only. If we do have already added languages, set up two option groups with + // the list of existing and then predefined languages. + if (empty($existing_languages)) { + $language_options = language_admin_predefined_list(); + $default = key($language_options); + } + else { + $default = key($existing_languages); + $language_options = array( + t('Existing languages') => $existing_languages, + t('Languages not yet added') => language_admin_predefined_list() + ); + } + $form['mappings'] = array( '#type' => 'container', '#tree' => TRUE, @@ -836,9 +860,9 @@ '#required' => TRUE, ), 'drupal_langcode' => array( - '#type' => 'textfield', + '#type' => 'select', + '#options' => $language_options, '#default_value' => $drupal_langcode, - '#size' => 20, '#required' => TRUE, ), ); 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 @@ -196,11 +196,11 @@ // Add a new custom mapping. $edit = array( 'mappings[_new][browser_langcode]' => 'xx', - 'mappings[_new][drupal_langcode]' => 'yy', + 'mappings[_new][drupal_langcode]' => 'en', ); $this->drupalPost('admin/config/regional/language/detection/browser', $edit, t('Save configuration')); $this->assertField('edit-mappings-xx-browser-langcode', 'xx', 'Browser language code found.'); - $this->assertField('edit-mappings-xx-drupal-langcode', 'yy', 'Drupal 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')); @@ -217,7 +217,7 @@ // Add a new custom mapping with only a Drupal language code. $edit = array( 'mappings[_new][browser_langcode]' => '', - 'mappings[_new][drupal_langcode]' => 'yyyy', + 'mappings[_new][drupal_langcode]' => 'en', ); $this->drupalPost('admin/config/regional/language/detection/browser', $edit, t('Save configuration')); $this->assertText(t('Both browser and Drupal language codes must be provided.'), 'Error message displayed.'); @@ -226,17 +226,17 @@ $edit = array( 'mappings[xx][browser_langcode]' => 'zh-sg', - 'mappings[xx][drupal_langcode]' => 'yy', + '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.'); - // Change Drupal language code of our custom mapping to zh-hans-sg. + // Change Drupal language code of our custom mapping to zh-hans. $edit = array( 'mappings[xx][browser_langcode]' => 'xx', - 'mappings[xx][drupal_langcode]' => 'zh-hans-sg', + 'mappings[xx][drupal_langcode]' => 'zh-hans', ); $this->drupalPost('admin/config/regional/language/detection/browser', $edit, t('Save configuration')); $this->assertField('edit-mappings-xx-browser-langcode', 'xx', 'Browser language code found.'); - $this->assertField('edit-mappings-xx-drupal-langcode', 'zh-hans-sg', 'Drupal language code found.'); + $this->assertField('edit-mappings-xx-drupal-langcode', 'zh-hans', 'Drupal language code found.'); } }