From 7d5884101ac768777c7a6508d86ec46ae9a1ba1e Mon Sep 17 00:00:00 2001 From: webchick Date: Thu, 28 Aug 2014 23:29:55 -0700 Subject: [PATCH] =?UTF-8?q?Issue=20#1974048=20by=20G=C3=A1bor=20Hojtsy,=20?= =?UTF-8?q?vijaycs85,=20er.pushpinderrana,=20Sutharsan,=20penyaskito,=20bs?= =?UTF-8?q?erem:=20Fixed=20Limited=20display=20of=20languages=20when=20goi?= =?UTF-8?q?ng=20back=20in=20installer=20is=20confusing.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Installer/Form/SelectLanguageForm.php | 43 +++++++--------- .../Installer/InstallerLanguagePageTest.php | 49 +++++++++++++++++++ 2 files changed, 68 insertions(+), 24 deletions(-) create mode 100644 core/modules/system/src/Tests/Installer/InstallerLanguagePageTest.php diff --git a/core/lib/Drupal/Core/Installer/Form/SelectLanguageForm.php b/core/lib/Drupal/Core/Installer/Form/SelectLanguageForm.php index 6285c399e51..5a00f24ccea 100644 --- a/core/lib/Drupal/Core/Installer/Form/SelectLanguageForm.php +++ b/core/lib/Drupal/Core/Installer/Form/SelectLanguageForm.php @@ -45,21 +45,19 @@ class SelectLanguageForm extends FormBase { // Build a select list with language names in native language for the user // to choose from. And build a list of available languages for the browser // to select the language default from. + // Select lists based on all standard languages. + foreach ($standard_languages as $langcode => $language_names) { + $select_options[$langcode] = $language_names[1]; + $browser_options[$langcode] = $langcode; + } + // Add languages based on language files in the translations directory. if (count($files)) { - // Select lists based on available language files. foreach ($files as $langcode => $uri) { $select_options[$langcode] = isset($standard_languages[$langcode]) ? $standard_languages[$langcode][1] : $langcode; - $browser_options[] = $langcode; + $browser_options[$langcode] = $langcode; } } - else { - // Select lists based on all standard languages. - foreach ($standard_languages as $langcode => $language_names) { - $select_options[$langcode] = $language_names[1]; - $browser_options[] = $langcode; - } - } - + asort($select_options); $request = Request::createFromGlobals(); $browser_langcode = UserAgent::getBestMatchingLangcode($request->server->get('HTTP_ACCEPT_LANGUAGE'), $browser_options); $form['langcode'] = array( @@ -70,21 +68,18 @@ class SelectLanguageForm extends FormBase { // Use the browser detected language as default or English if nothing found. '#default_value' => !empty($browser_langcode) ? $browser_langcode : 'en', ); - - if (empty($files)) { - $form['help'] = array( - '#type' => 'item', - '#markup' => String::format('

Translations will be downloaded from the Drupal Translation website. - If you do not want this, select English.

', array( - '!english' => install_full_redirect_url(array('parameters' => array('langcode' => 'en'))), - )), - '#states' => array( - 'invisible' => array( - 'select[name="langcode"]' => array('value' => 'en'), - ), + $form['help'] = array( + '#type' => 'item', + '#markup' => String::format('

Translations will be downloaded from the Drupal Translation website. + If you do not want this, select English.

', array( + '!english' => install_full_redirect_url(array('parameters' => array('langcode' => 'en'))), + )), + '#states' => array( + 'invisible' => array( + 'select[name="langcode"]' => array('value' => 'en'), ), - ); - } + ), + ); $form['actions'] = array('#type' => 'actions'); $form['actions']['submit'] = array( '#type' => 'submit', diff --git a/core/modules/system/src/Tests/Installer/InstallerLanguagePageTest.php b/core/modules/system/src/Tests/Installer/InstallerLanguagePageTest.php new file mode 100644 index 00000000000..4c74ddcef39 --- /dev/null +++ b/core/modules/system/src/Tests/Installer/InstallerLanguagePageTest.php @@ -0,0 +1,49 @@ +siteDirectory . '/files/translations', 0777, TRUE); + touch(DRUPAL_ROOT . '/' . $this->siteDirectory . '/files/translations/drupal-8.0.0.xoxo.po'); + + // Check that all predefined languages show up with their native names. + $this->drupalGet($GLOBALS['base_url'] . '/core/install.php'); + foreach (\Drupal::languageManager()->getStandardLanguageList() as $langcode => $names) { + $this->assertOption('edit-langcode', $langcode); + $this->assertRaw('>' . $names[1] . '<'); + } + + // Check that our custom one shows up with the file name indicated language. + $this->assertOption('edit-langcode', 'xoxo'); + $this->assertRaw('>xoxo<'); + + parent::setUpLanguage(); + } + + /** + * Confirms that the installation succeeded. + */ + public function testInstalled() { + $this->assertUrl('user/1'); + $this->assertResponse(200); + } + +}