Multilingual Urls

Hello! I’m trying to create multilingual application. I’ve implemented ability of translationable content and next step should be showing it to user. I want to have ability of changing language depending on URL. I’ve found a couple of components for those purposes but they all create urls which I don’t like. For example, my application’s default language is English and I have content which is translated into French. I have page “contacts”, for instance. And URLs which will be generated by application will be: mysite.com/en/contacts, mysite.com/fr/contacts, but I want to have mysite.com/contacts for default language and mysite.com/fr/contacts for French language. It’s simillar for site’s root too. mysite.com/ - for default language and mysite.com/fr for French.

Is there any methods for implementing these functionality?

provide additional routes that will handle default language routes (without language in URL, but with language provided as default parameter value in route definition).




//route with default language

'<controller:\w+>/<id:\d+>'=>array( '<controller>/view', 'defaultParams'=>array( 'lang'=>'en' ) ),

//route with language

'<lang:[a-z_]{2,6}>/<controller:\w+>/<id:\d+>'=>'<controller>/view',

...



–edit

oh, and add ‘matchValue’=>true in CUrlManager configuration so it can select proper routes for any language…