Skip to content

Commit

Permalink
Fix language setting in installation wizard
Browse files Browse the repository at this point in the history
  • Loading branch information
ganiuszka committed Jun 9, 2024
1 parent a6cb6f2 commit 0d5c912
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions API/Pages/Panel/APIInstallWizard.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,11 @@ class APIInstallWizard extends BaculumAPIPage
public function onPreInit($param)
{
parent::onPreInit($param);
if (isset($_SESSION['language'])) {
$this->Application->getGlobalization()->Culture = $_SESSION['language'];
$session = $this->Application->getSession();
// Open new session if no session exists
$session->open();
if ($session->contains('language')) {
$this->Application->getGlobalization()->Culture = $session->itemAt('language');
}
}

Expand All @@ -86,8 +89,9 @@ public function onInit($param)
$this->first_run = (count($this->config) === 0);
$oauth2_cfg = $this->getModule('oauth2_config')->getConfig();
$this->add_auth_params = (count($oauth2_cfg) === 0);
if (isset($_SESSION['language'])) {
$this->Lang->SelectedValue = $_SESSION['language'];
$session = $this->Application->getSession();
if ($session->contains('language')) {
$this->Lang->SelectedValue = $session->itemAt('language');
} elseif (!$this->first_run && isset($this->config['api']['lang'])) {
$this->Lang->SelectedValue = $this->config['api']['lang'];
}
Expand Down Expand Up @@ -233,8 +237,9 @@ public function wizardCompleted($sender, $param)
} elseif ($this->AuthOAuth2->Checked) {
$cfg_data['api']['auth_type'] = 'oauth2';
}
$session = $this->Application->getSession();
$cfg_data['api']['debug'] = $this->config['api']['debug'] ?? "0";
$cfg_data['api']['lang'] = $_SESSION['language'] ?? APIConfig::DEF_LANG;
$cfg_data['api']['lang'] = $session->itemAt('language') ?? APIConfig::DEF_LANG;
$cfg_data['db']['enabled'] = (int) ($this->DatabaseYes->Checked === true);
$cfg_data['db']['type'] = $this->DBType->SelectedValue;
$cfg_data['db']['name'] = $this->DBName->Text;
Expand Down Expand Up @@ -480,7 +485,8 @@ public function setDBPath($db)

public function setLang($sender, $param)
{
$_SESSION['language'] = $sender->SelectedValue;
$session = $this->Application->getSession();
$session->add('language', $sender->SelectedValue);
}

public function renderPanel($sender, $param)
Expand Down

0 comments on commit 0d5c912

Please sign in to comment.