Welcome Guest, Not a member yet? Register   Sign In
switch language file with session[SOLVED]
#1

[eluser]Ngulo[/eluser]
hi all i've $this->problem():

i want to includethe language file that are into language folder

i switch the file_name with a function :
Code:
function lingua()
    {
    
    $lingua_scelta= $this->uri->segment(3);
        
    switch ($lingua_scelta)
    {
    case 'it':
            
        $this->session->set_userdata('lingua','define_IT.php');
      
    break;
    case'en':
            
        
            $this->session->set_userdata('lingua','define_EN.php');
      
    break;

        default:
            
            $this->session->set_userdata('lingua','define_IT.php');
      
            break;
        
    }



i make this first on all my controllers to load the session or not_session name_file:

Code:
if
              ($this->session->userdata('lingua'))
              {$this->load->file('language/'.$this->session->userdata('lingua'));}
          else
             {$this->load->file('language/define_IT.php');}

the problem is that i get this error:
Code:
An Error Was Encountered

Unable to load the requested file: define_EN
while the non_session name_file(define_IT.php) when the userdata('lingua') is FALSE

any suggestions?

thanks
#2

[eluser]Ngulo[/eluser]
guys, sorry I went into a panic, I found the solution, I really apologize

was enough to change this and the other ones:
Code:
$this->session->set_userdata('lingua','define_IT.php');

into
Code:
$this->session->set_userdata('lingua',"define_IT.php");

I did not put quotes




Theme © iAndrew 2016 - Forum software by © MyBB