[eluser]xwero[/eluser]
@
michael : Sorry for the late answer, your post got lost during dinner
I just used it myself and it works great but i added an extra check
Code:
class MY_Language extends CI_Language
{
function MY_Language()
{
parent::CI_Language();
}
function switch_to($idiom)
{
$CI =& get_instance();
if(is_string($idiom) && $idiom != $CI->config->item('language'))
{
$CI->config->set_item('language',$idiom);
$loaded = $this->is_loaded;
$this->is_loaded = array();
foreach($loaded as $file)
{
$this->load(str_replace('_lang.php','',$file));
}
}
}
}
i use it as follows
Code:
// controller
class Admin extends Controller
{
function Admin()
{
parent::Controller();
$this->lang->load('cms_form_msg');
$this->lang->load('cms_form');
$this->lang->switch_to($this->session->userdata('language'));
}
function langswitch()
{
$this->session->set_userdata('language',$this->uri->segment(3));
redirect(str_replace('_','/',$this->uri->segment(4)));
}
}
// view (the site_url function replaces the forward slashes with underscores)
<a href="<?php echo site_url('admin/langswitch/english/'.this->uri->uri_string().'/'); ?>">English</a>
I'm using a session variable but nothing stops you to use an url segment.