From: Marcin Haba Date: Wed, 1 Nov 2017 16:38:10 +0000 (+0100) Subject: baculum: Fix language setting in api X-Git-Tag: Release-9.0.5~9 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=aaa173c5a2c3794284c25bbec8f8157933889ac3;p=bacula%2Fbacula baculum: Fix language setting in api --- diff --git a/gui/baculum/protected/API/Class/APIConfig.php b/gui/baculum/protected/API/Class/APIConfig.php index 77c817d603..9c51e0a34b 100644 --- a/gui/baculum/protected/API/Class/APIConfig.php +++ b/gui/baculum/protected/API/Class/APIConfig.php @@ -30,6 +30,11 @@ Prado::using('Application.Common.Class.ConfigFileModule'); */ class APIConfig extends ConfigFileModule { + /** + * Default application language + */ + const DEFAULT_LANGUAGE = 'en'; + /** * API config file path */ diff --git a/gui/baculum/protected/API/Class/BaculumAPIPage.php b/gui/baculum/protected/API/Class/BaculumAPIPage.php index a105a0900b..00ec70655e 100644 --- a/gui/baculum/protected/API/Class/BaculumAPIPage.php +++ b/gui/baculum/protected/API/Class/BaculumAPIPage.php @@ -23,7 +23,15 @@ session_start(); Prado::using('Application.Common.Class.BaculumPage'); +Prado::using('Application.API.Class.APIConfig'); class BaculumAPIPage extends BaculumPage { + + public function onPreInit($param) { + parent::onPreInit($param); + $config = $this->getModule('api_config')->getConfig('api'); + $lang = array_key_exists('lang', $config) ? $config['lang'] : APIConfig::DEFAULT_LANGUAGE; + $this->Application->getGlobalization()->Culture = $lang; + } } ?> diff --git a/gui/baculum/protected/API/Pages/Panel/APIInstallWizard.php b/gui/baculum/protected/API/Pages/Panel/APIInstallWizard.php index 6156e27df0..f178ba9624 100644 --- a/gui/baculum/protected/API/Pages/Panel/APIInstallWizard.php +++ b/gui/baculum/protected/API/Pages/Panel/APIInstallWizard.php @@ -172,6 +172,7 @@ class APIInstallWizard extends BaculumAPIPage { $cfg_data['api']['client_id'] = $this->APIOAuth2ClientId->Text; } $cfg_data['api']['debug'] = isset($this->config['api']['debug']) ? $this->config['api']['debug'] : "0"; + $cfg_data['api']['lang'] = $_SESSION['language']; $cfg_data['db']['enabled'] = (integer)($this->DatabaseYes->Checked === true); $cfg_data['db']['type'] = $this->DBType->SelectedValue; $cfg_data['db']['name'] = $this->DBName->Text; @@ -299,7 +300,7 @@ class APIInstallWizard extends BaculumAPIPage { $_SESSION['language'] = $sender->SelectedValue; } - public function renderPanel($sender, $param) { + public function renderPanel($sender, $param) { $this->LoginValidator->Display = ($this->Login->Enabled === true) ? 'Dynamic' : 'None'; $this->PortValidator->Display = ($this->Port->Enabled === true) ? 'Dynamic' : 'None'; $this->IPValidator->Display = ($this->IP->Enabled === true) ? 'Dynamic' : 'None';