Issue #1974048 by Gábor Hojtsy, vijaycs85, er.pushpinderrana, Sutharsan, penyaskito, bserem: Fixed Limited display of languages when going back in installer is confusing.
parent
68f576fe81
commit
7d5884101a
|
@ -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('<p>Translations will be downloaded from the <a href="http://localize.drupal.org">Drupal Translation website</a>.
|
||||
If you do not want this, select <a href="!english">English</a>.</p>', 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('<p>Translations will be downloaded from the <a href="http://localize.drupal.org">Drupal Translation website</a>.
|
||||
If you do not want this, select <a href="!english">English</a>.</p>', 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',
|
||||
|
|
|
@ -0,0 +1,49 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\system\Tests\Installer\InstallerLanguagePageTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\system\Tests\Installer;
|
||||
|
||||
use Drupal\simpletest\InstallerTestBase;
|
||||
|
||||
/**
|
||||
* Verifies that the installer language list combines local and remote languages.
|
||||
*
|
||||
* @group Installer
|
||||
*/
|
||||
class InstallerLanguagePageTest extends InstallerTestBase {
|
||||
|
||||
/**
|
||||
* Installer step: Select language.
|
||||
*/
|
||||
protected function setUpLanguage() {
|
||||
// Place a custom local translation in the translations directory.
|
||||
mkdir(DRUPAL_ROOT . '/' . $this->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);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue