redirecting home page and language

hi all

I have a yii application that uses 2 different languages (french and english)

if I use the following URL it works as it should

http://localhost/site2012/index.php?r=site/index&lang=en

but if I type

http://localhost/site2012/

it goes to the main page but does not recognize the language since it’s not passed in the URL…

it doesn’t even make it to my message file for translation.

how can I set the language by default so that it always has a language defined? or can I just redirect from my index page to a URL including the lang=en or lang=fr?

thanks

Pabs

I do it something like this:




	if(isset($_GET['lang'])) {

		Yii::app()->setLanguage($lang);

	}



You must remember that Yii already has language functionality, so make sure your own does not conflict with it, eg. I use en_us, pt_br, it … I’m sure its all documented :slight_smile:

See this wiki, it should help you (it’s very detailed) or give you at least interesting ideas:

SEO-conform Multilingual URLs + Language Selector Widget (i18n)