开发者

Change Language in Runtime

开发者 https://www.devze.com 2023-01-04 03:55 出处:网络
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:

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 wha开发者_开发问答t I need is change in realtime not changing the config of the framework.

Regards,

Pedro


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.


Use hooks instead of class constructor, or even extend the Controller to MY_Controller and call in it's constructor.

0

精彩评论

暂无评论...
验证码 换一张
取 消