Automatically load the translations

This commit is contained in:
Alex Tselegidis 2020-12-02 20:04:06 +02:00
parent 84ab6702b3
commit e7b4aeedab
11 changed files with 23 additions and 101 deletions

View file

@ -35,7 +35,6 @@ class Appointments extends EA_Controller {
$this->load->model('customers_model'); $this->load->model('customers_model');
$this->load->model('settings_model'); $this->load->model('settings_model');
$this->load->library('session');
$this->load->library('timezones'); $this->load->library('timezones');
$this->load->library('synchronization'); $this->load->library('synchronization');
$this->load->library('notifications'); $this->load->library('notifications');

View file

@ -37,20 +37,7 @@ class Backend extends EA_Controller {
$this->load->model('admins_model'); $this->load->model('admins_model');
$this->load->library('timezones'); $this->load->library('timezones');
$this->load->library('session');
$this->load->library('migration'); $this->load->library('migration');
if ($this->session->userdata('language'))
{
// Set user's selected language.
$this->config->set_item('language', $this->session->userdata('language'));
$this->lang->load('translations', $this->session->userdata('language'));
}
else
{
// Set the default language.
$this->lang->load('translations', $this->config->item('language'));
}
} }
/** /**

View file

@ -36,7 +36,6 @@ class Backend_api extends EA_Controller {
{ {
parent::__construct(); parent::__construct();
$this->load->library('session');
$this->load->model('roles_model'); $this->load->model('roles_model');
if ($this->session->userdata('role_slug')) if ($this->session->userdata('role_slug'))

View file

@ -17,15 +17,6 @@
* @package Controllers * @package Controllers
*/ */
class Captcha extends EA_Controller { class Captcha extends EA_Controller {
/**
* Class Constructor
*/
public function __construct()
{
parent::__construct();
$this->load->library('session');
}
/** /**
* Make a request to this method to get a captcha image. * Make a request to this method to get a captcha image.
*/ */

View file

@ -17,28 +17,6 @@
* @package Controllers * @package Controllers
*/ */
class Errors extends EA_Controller { class Errors extends EA_Controller {
/**
* Class Constructor
*/
public function __construct()
{
parent::__construct();
$this->load->library('session');
if ($this->session->userdata('language'))
{
// Set user's selected language.
$this->config->set_item('language', $this->session->userdata('language'));
$this->lang->load('translations', $this->session->userdata('language'));
}
else
{
// Set the default language.
$this->lang->load('translations', $this->config->item('language'));
}
}
/** /**
* Display the 404 error page. * Display the 404 error page.
*/ */

View file

@ -19,16 +19,6 @@
* @package Controllers * @package Controllers
*/ */
class Google extends EA_Controller { class Google extends EA_Controller {
/**
* Class Constructor
*/
public function __construct()
{
parent::__construct();
$this->load->library('session');
}
/** /**
* Authorize Google Calendar API usage for a specific provider. * Authorize Google Calendar API usage for a specific provider.
* *
@ -110,8 +100,6 @@ class Google extends EA_Controller {
$framework = get_instance(); $framework = get_instance();
// The user must be logged in. // The user must be logged in.
$framework->load->library('session');
if ($framework->session->userdata('user_id') == FALSE && is_cli() === FALSE) if ($framework->session->userdata('user_id') == FALSE && is_cli() === FALSE)
{ {
return; return;

View file

@ -20,26 +20,13 @@
*/ */
class Installation extends EA_Controller { class Installation extends EA_Controller {
/** /**
* Class Constructor * Installation constructor.
*/ */
public function __construct() public function __construct()
{ {
parent::__construct(); parent::__construct();
$this->load->helper('installation'); $this->load->helper('installation');
$this->load->library('session');
if ($this->session->userdata('language'))
{
// Set user's selected language.
$this->config->set_item('language', $this->session->userdata('language'));
$this->lang->load('translations', $this->session->userdata('language'));
}
else
{
// Set the default language.
$this->lang->load('translations', $this->config->item('language'));
}
} }
/** /**
@ -74,7 +61,6 @@ class Installation extends EA_Controller {
$this->load->model('settings_model'); $this->load->model('settings_model');
$this->load->model('services_model'); $this->load->model('services_model');
$this->load->model('providers_model'); $this->load->model('providers_model');
$this->load->library('session');
$this->load->library('migration'); $this->load->library('migration');
$this->load->helper('string'); $this->load->helper('string');

View file

@ -21,28 +21,6 @@ use EA\Engine\Types\NonEmptyText;
* @package Controllers * @package Controllers
*/ */
class User extends EA_Controller { class User extends EA_Controller {
/**
* Class Constructor
*/
public function __construct()
{
parent::__construct();
$this->load->library('session');
if ($this->session->userdata('language'))
{
// Set user's selected language.
$this->config->set_item('language', $this->session->userdata('language'));
$this->lang->load('translations', $this->session->userdata('language'));
}
else
{
// Set the default language.
$this->lang->load('translations', $this->config->item('language')); // default
}
}
/** /**
* Default Method * Default Method
* *

View file

@ -24,7 +24,6 @@
* @property CI_Session $session * @property CI_Session $session
* @property CI_Security $security * @property CI_Security $security
* @property CI_Migration $migration * @property CI_Migration $migration
* @property Admins_model $admins_model * @property Admins_model $admins_model
* @property Appointments_model $appointments_model * @property Appointments_model $appointments_model
* @property Consents_model $consents_model * @property Consents_model $consents_model
@ -44,5 +43,26 @@
* @property Timezones $timezones * @property Timezones $timezones
*/ */
class EA_Controller extends CI_Controller { class EA_Controller extends CI_Controller {
// /**
* EA_Controller constructor.
*/
public function __construct()
{
parent::__construct();
$this->configure_language();
}
/**
* Configure the language
*/
private function configure_language()
{
if ($this->session->has_userdata('language'))
{
$this->config->set_item('language');
}
$this->lang->load('translations');
}
} }

View file

@ -52,8 +52,6 @@ class Google_Sync {
{ {
$this->CI =& get_instance(); $this->CI =& get_instance();
$this->CI->load->library('session');
// Initialize google client and calendar service. // Initialize google client and calendar service.
$this->client = new Google_Client(); $this->client = new Google_Client();

View file

@ -472,8 +472,6 @@ class Timezones {
$this->CI = & get_instance(); $this->CI = & get_instance();
$this->CI->load->model('user_model'); $this->CI->load->model('user_model');
$this->CI->load->library('session');
} }
/** /**