mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-27 21:58:52 +00:00
[ticket/17399] Fix selected language in installer
This fixes a bug where a user could have other languages in the installer but the language dropdown did not match the language shown. PHPBB-17399
This commit is contained in:
parent
8f8a93fa71
commit
8411da1819
3 changed files with 21 additions and 1 deletions
|
@ -19,7 +19,7 @@
|
|||
<form method="post" action="#" id="language_selector">
|
||||
<fieldset class="nobg">
|
||||
<label for="language">{L_SELECT_LANG}{L_COLON}</label>
|
||||
<select id="language" name="language">
|
||||
<select id="language" name="language">
|
||||
<!-- BEGIN language_select_item -->
|
||||
<option value="{language_select_item.VALUE}"<!-- IF language_select_item.SELECTED --> selected="selected"<!-- ENDIF -->>{language_select_item.NAME}</option>
|
||||
<!-- END language_select_item -->
|
||||
|
|
|
@ -339,6 +339,14 @@ class helper
|
|||
protected function render_language_select($selected_language = null)
|
||||
{
|
||||
$langs = $this->lang_helper->get_available_languages();
|
||||
|
||||
// The first language will be selected by default. Unless a user has consciously included
|
||||
// other languages in the installation process, it will be British English anyway.
|
||||
if ($selected_language === null && count($langs))
|
||||
{
|
||||
$selected_language = $langs[0]['iso'];
|
||||
}
|
||||
|
||||
foreach ($langs as $lang)
|
||||
{
|
||||
$this->template->assign_block_vars('language_select_item', array(
|
||||
|
|
|
@ -67,6 +67,18 @@ class language_file_helper
|
|||
);
|
||||
}
|
||||
|
||||
usort($available_languages, [$this, 'sort_by_local_name']);
|
||||
|
||||
return $available_languages;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sorts the languages by their name instead of iso code
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private static function sort_by_local_name($a, $b)
|
||||
{
|
||||
return $a['local_name'] > $b['local_name'];
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue