I am using this multilanguage addon http://codeigniter.com/wiki/CodeIgniter_2.1_internationalization_i18n to make available my codeigniter sites in various idioms.
I have this php code with echo links to change the language
echo anchor($this->lang->switch_uri('en'),'English | ');
echo anchor($this->lang->switch_uri('es'),'Español | ');
echo anchor($this->lang->switch_uri('ro'),'Română');
It does the change with no problem, but it doesn’t remember it. When I change page, from home to about, will go back to browser’s language or Romanian if browser’s language is not defined.
So, what could go wrong? What and how should I do to remember that choice?
You could simply change the choice by using the session:
$this->session->set_userdata('language', 'en');See more details about using session data
Later refer to what the users choice is by calling:
$language = $this->session->userdata('language ');