I wanna make a multilanguage website, but I do not want that the language appear in URI like example.com/fr/about (I do not want this). I just want to change the text language. My problem is that the first load language that I do is for ever. why? If I do:
$this->config->set_item(‘language’,‘english’);
$this->lang->load(‘messages’);
$this->config->set_item(‘language’,‘french’);
$this->lang->load(‘messages’);
or
$this->lang->load(‘messages’,‘english’);
$this->lang->load(‘messages’,‘french’);
just the english appear. How can I fix this?
My config language autoload is empty.
Thank you for your help.
I use a hook for this.
Not only will that set the correct language for you but it will give you a constant CURRENT_LANGUAGE which contains the language they are using ('en', 'de', etc).
The available languages for this come from a config item:
This will pick up the correct language from GET (http://somesite.com/?lang=de), then check session variable (populated by a correct match) then checks the browser for accept-lang header.
Whichever has a match first will be used.
Read the developer guide, there are some things to consider:
$this->lang->load("messages");
without second argument will load the default language$this->lang->line('some_key');
You can clear the loaded languages by using:
This will let you load another language afterwards by using the $this->lang->load('language_file', 'language').
Hope this helps