Reputation: 2927
I'm trying to change the language of one webapp in realtime using codeigniter.
I follow the online documentation, create the folder for language2 with all the traductions, but when I do:
$this->config->set_item('language', 'portuguese');
It don't change the lang, the only way it works is changing the config file ex:
$config['language'] = "english";
But what I need is change in realtime not changing the config of the framework.
Regards,
Pedro
Upvotes: 1
Views: 1155
Reputation: 1613
you can use this code. (this example for ion_auth)
$this->config->set_item('language', 'portuguese');
$this->lang->is_loaded = array();
$this->lang->load('ion_auth', 'portuguese');
this code used in constractor .
$this->lang->is_loaded = array();
top line empty laded languages.
Upvotes: 2
Reputation: 2591
Use hooks instead of class constructor, or even extend the Controller to MY_Controller and call in it's constructor.
Upvotes: 1