Yii Framework Forum: Multilanguage URL - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • This topic is locked

Multilanguage URL Rate Topic: -----

#1 User is offline   sebas 

  • Advanced Member
  • Yii
  • Group: Yii Dev Team
  • Posts: 496
  • Joined: 28-October 08
  • Location:Buenos Aires, Argentina

Posted 11 May 2009 - 10:30 AM

Is there a way to make the URLs for the same action/controller change in diferent languages different?

For example:

http://www.mydomain....roller/MyAction


to:

http://www.mydomain....roller/MyAction


0

#2 User is offline   Sentinel 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 51
  • Joined: 04-March 09
  • Location:Russe, Bulgaria

Posted 11 May 2009 - 11:07 AM

I was working on this direction when I had to implement multilanguage interface... It appears that there is no easy way to do this without rewriteing (most of) CUrlManager. Finally I did it adding extra get parameter with the locale id for every link and attached a behaviour in the application to change the language according to this GET parameter... It is something simmilar to the approach in the Yii cookbook: http://www.yiiframew...oc/cookbook/26/
0

#3 User is offline   qiang 

  • Yii Project Lead
  • Yii
  • Group: Yii Dev Team
  • Posts: 5,876
  • Joined: 04-October 08
  • Location:DC, USA

Posted 11 May 2009 - 12:59 PM

You may extend CUrlManager and override its createUrl() method. At the beginning of the method, you can set $params['language']=Yii::app()->language.

Then add a URL rule as follows (requiring 1.0.5):

'<language:(en|es...)>/<route:[w\/]+>' => '<route>',

0

#4 User is offline   sebas 

  • Advanced Member
  • Yii
  • Group: Yii Dev Team
  • Posts: 496
  • Joined: 28-October 08
  • Location:Buenos Aires, Argentina

Posted 12 May 2009 - 09:04 AM

Thanks !!!

This framework is awesome!! :D
0

#5 User is offline   sebas 

  • Advanced Member
  • Yii
  • Group: Yii Dev Team
  • Posts: 496
  • Joined: 28-October 08
  • Location:Buenos Aires, Argentina

Posted 27 May 2009 - 01:11 PM

Hey, i try this and it doesn't work how i want, maybe (or surely) is my mistake,

in main.php config file:


the MyCurl class:



the error is this:

Page Not Found
Unable to resolve the request "en/company/index".

The requested URL was not found on this server. If you entered the URL manually please check your spelling and try again.

If you think this is a server error, please contact the webmaster.


Where is my mistake?
0

#6 User is offline   sebas 

  • Advanced Member
  • Yii
  • Group: Yii Dev Team
  • Posts: 496
  • Joined: 28-October 08
  • Location:Buenos Aires, Argentina

Posted 27 May 2009 - 01:13 PM

My Mistake on the route,

(en|es...) must be (en|es).

Sorry for that  :-[
0

#7 User is offline   romanoza 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 117
  • Joined: 17-April 09
  • Location:Moscow, Russia

Posted 18 June 2009 - 08:02 AM

thanx for this thing

defore this i have rules like this:
'users/<usertype:d+>'=>'user/list',


how do i need to change my rules after setup this one (language)?
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • This topic is locked

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