views:

1082

answers:

2

Hi. 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.

+1  A: 

Read the developer guide, there are some things to consider:

  • "Language files must be named with _lang.php as the file extension." - your file is just called "message"
  • Use different files for different languages
  • Simply doing $this->lang->load("messages"); without second argument will load the default language
  • Show translated texts with $this->lang->line('some_key');
AndiDog
I'm doing it. One question, what must be at $config['languages']. Can you please show me an good example, please?
Bytes
Simply doing $this->lang->load("messages"); without second argument will load the default language -> and if I wanna load other language I can't do $this->lang->load("messages",'french'); ?
Bytes
Of course, that's how to do it. If you follow all the instructions in the developer guide, it should work just fine.
AndiDog
A: 
Phil Sturgeon
I don't wanna send languagem by URI. I just wanna that example.com/about display in english if user select english at footer or french if select french. No example.com/about?=en or whatever. Everytime /about
Bytes
You are missing the point I think. The hook performs several checks, one is a GET variable and another is the browser detection.The GET variable is used as a switch to manually set a language you want to use. Otherwise every time you access /about you will get whatever language is appropriate to the user based on their browser settings. If I am sat in a French internet cafe, I will see your site in French.Make more sense?
Phil Sturgeon