Welcome Guest, Not a member yet? Register   Sign In
Dynamically change language
#1

[eluser]MaDe[/eluser]
Hi,

I'm trying to create a multi-language website. I want to include the current language into the URI (eg. http://www.test.com/en/contact or http://www.test.com/de/help). I already wrote a router to cope with the extra URI segment and modified my controller constructors to read the URI and switch the language for all calls to $this->lang->load(..., $current_language).

But then I found the problem, that any messages from other parts of CI (validation) came out in the default language. How can I set the current language for *ALL* CI components at run-time?

Regards,
Marc
#2

[eluser]Pascal Kriete[/eluser]
There is config variable that handles it. I almost always extend the controller class in my apps, so I just add:
Code:
$this->config->set_item('language', 'german');
#3

[eluser]sikkle[/eluser]
You realy need this : http://codeigniter.com/wiki/URI_Language_Identifier/

Good luck!
#4

[eluser]MaDe[/eluser]
Thanks, setting the config item was too easy, no way to find that one on my own Wink

Regards,
Marc
#5

[eluser]Cesar Kohl[/eluser]
Actually in the 1.7.2 version you need to change this in the config file:

Code:
$config['language']= "pt-br";




Theme © iAndrew 2016 - Forum software by © MyBB