Yii Framework Forum: redirecting home page and language - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

redirecting home page and language Rate Topic: -----

#1 User is offline   Pabs 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 69
  • Joined: 31-March 11

Posted 18 July 2012 - 09:21 PM

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/sit...e/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
0

#2 User is offline   Backslider 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 419
  • Joined: 23-July 09

Posted 19 July 2012 - 03:16 AM

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 :-)
We were all once expert at....... nothing.

yii-language-behavior

My Blog
0

#3 User is offline   bennouna 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,180
  • Joined: 05-January 12
  • Location:Morocco

Posted 19 July 2012 - 06:10 AM

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)
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users