[SOLVED] Need help for multilanguage site |
[eluser]Unknown[/eluser]
Hi all, i want to make the site with multi languages and selecting the language with ajax and the different words will be selected from database and i want to use session[lang],and i don't want to use GET[lang]. i'm trying from 5 days to make this but i try so many variants and i'm confused now now i'm here: i have model -> Langs -> function set_langs($arg) { $this->session->unset_userdata('lang'); $this->session->set_userdata('lang', $arg); return $arg; } function get_langs() { return $this->session->userdata('lang'); } in the Home controller -> public function index(){ if($this->session->userdata('lang')==''){ $this->Langs->set_langs('en'); $glang['lang'] = $this->Langs->get_langs(); }else{ $glang['lang'] = $this->Langs->get_langs(); } $this->load->view('header', $glang); } public function set() { if($_POST && $_POST['lang'] != NULL) { $this->Langs->set_langs($_POST['lang']); $return['error'] = false; $return['msg'] = $this->session->userdata('lang').' ok!'; echo json_encode($return); }else{...} } and in the header.php -> in the JS -> $.ajax({ type: "POST", url: "index.php/home/set", dataType : 'json', data: "lang="+lang, success: function(data){ if(data.error === true){ $( "#dialog-message2" ).text(data.msg).dialog({ modal: true, buttons: { Ok: function() { $( this ).dialog( "close" );[removed]=location.href; } } }); }else{...} when the page refresh the language stil not changed but when return the message from ajax it work so where im wrong sorry for the bad english ![]() thanks *** the problem was -> system/libraries/Session.php (the original file from the CodeIgniter_2.0.2.zip) -> i download http://codeigniter.com/wiki/File:CI_1.5....ssion.zip/ and no problems |
Messages In This Thread |
[SOLVED] Need help for multilanguage site - by El Forum - 07-01-2011, 04:21 AM
|