Welcome Guest, Not a member yet? Register   Sign In
Internationalization and codeigniter
#1

[eluser]Unknown[/eluser]
Dear all,

It's my first post and i came here after not being able to find a solution after working on it for one week.

Multilingual codeigniter website. One hungarian, one romanian language. simple enough, i thought at first.

to cut to the chase, right now mylanguage.php looks like this:

Code:
class MyLanguage extends CI_Controller {

public function switchLanguage()
    {
  $lang = $this->uri->segment(3, 0);
  $times = $this->uri->segment(4, 0);
  
  if(!$times){
  
   redirect(current_url().'/2','refresh');
   }
  else{
  
  
  
  $newdata = array( 'lang'  => $lang );
  $this->session->set_userdata($newdata);
  unset($this->lang->is_loaded[array_search('hu_lang.php', $this->lang->is_loaded)]);
  unset($this->lang->is_loaded[array_search('ro_lang.php', $this->lang->is_loaded)]);
    redirect($this->session->userdata('current_url'), 'refresh');
    }
}
}

So this thing is working, on IE only, have no idea what black magic is behind it.
But, this is called with a url parameter to unset the language and set the cookie value so that the controller can load the language.

snippet from login controller:

Code:
public function __construct()
       {
            parent::__construct();
   $lang2= $this->session->userdata('lang');
   if(!$lang2){ $lang2='hu';}
  
   $newdata = array( 'lang'  => $lang2 );
   $this->session->set_userdata($newdata);

   $this->lang->load($lang2,'english') or die('Error loading the language file!');
   //print_r($this->lang->is_loaded);
       }

so idea is to get the language from the cookie (hu/ro, both stored in english folder) and the load the language (unsetted in the mylanguage controller)

And it's not working,i've tried a lot of variations on this, and none of them work. Strangely, on local machine it does work... but remote, it does not.

Anyone, any ideas?
How did you create a multilingual site powered by codeigniter?
Any and every help is very much appreciated, i am super frustrated with this now.

Thank you
Lehel
#2

[eluser]LuckyFella73[/eluser]
Have a look at this page:
http://maestric.com/doc/php/codeigniter_i18n




Theme © iAndrew 2016 - Forum software by © MyBB