]> git.sur5r.net Git - bacula/bacula/commitdiff
baculum: Fix language setting in api
authorMarcin Haba <marcin.haba@bacula.pl>
Wed, 1 Nov 2017 16:38:10 +0000 (17:38 +0100)
committerMarcin Haba <marcin.haba@bacula.pl>
Wed, 1 Nov 2017 17:15:49 +0000 (18:15 +0100)
gui/baculum/protected/API/Class/APIConfig.php
gui/baculum/protected/API/Class/BaculumAPIPage.php
gui/baculum/protected/API/Pages/Panel/APIInstallWizard.php

index 77c817d60359a7de966ae39f5d1cc1d2c09a1fee..9c51e0a34b5603119b880f67a54b5f0ea2c12a82 100644 (file)
@@ -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
         */
index a105a0900bd634c63ef4c8e2aa337b7bba3093fa..00ec70655e5f12a123ad68220a08ee87a71208d1 100644 (file)
 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;
+       }
 }
 ?>
index 6156e27df079c13714a68ca6f776f33ec17548a0..f178ba9624838781211724834d008d343236580b 100644 (file)
@@ -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';