Yii Multilanguage

Hi,

I have a problem on multiple language URL routing

How to convert

localhost/testimonialDetails/pinturas-mataavenida/language/en

to

localhost/en/testimonialDetails/pinturas-mataavenida

problem is that when any "-" inside URL slug the createUrl() function not able to route this. is this problem on my code

i just call

<?= $this->createUrl("testimonialDetails/$testimonials->url") ?>

localhost/testimonialDetails/pinturas-mataavenida/language/en

if i replace "-" with "_" (underscore)

localhost/en/testimonialDetails/pinturas_mataavenida

then it working fine

my codding is

Override createUrl function

[b]

class UrlManager extends CUrlManager {

public function createUrl   (&#036;route, &#036;params = array(), &#036;ampersand = '&amp;') {


    if (&#33;isset(&#036;params['language'])) {


        if (Yii::app()-&gt;user-&gt;hasState('language'))


            Yii::app()-&gt;language = Yii::app()-&gt;user-&gt;getState('language');


        else if (isset(Yii::app()-&gt;request-&gt;cookies['language']))


            Yii::app()-&gt;language = Yii::app()-&gt;request-&gt;cookies['language']-&gt;value;


        &#036;params['language'] = Yii::app()-&gt;language;


    }


    return parent::createUrl(&#036;route, &#036;params, &#036;ampersand);


}

}[/b]

This is my urlManager Rule

‘<language:(es|da|en)>/testimonialDetails/<url:[\w-]+>’ => ‘testimonials/details’,

            '&lt;language:(es|da|en)&gt;/&lt;action:(contact)&gt;/*' =&gt; 'site/&lt;action&gt;',


            '&lt;language:(es|da|en)&gt;/&lt;controller:&#092;w+&gt;' =&gt; '&lt;controller&gt;',


            '&lt;language:(es|da|en)&gt;/&lt;controller:&#092;w+&gt;/&lt;id:&#092;d+&gt;' =&gt; '&lt;controller&gt;/view',


            '&lt;language:(es|da|en)&gt;/&lt;module:&#092;w+&gt;/&lt;controller:(admin|profileField)&gt;/&lt;id:&#092;d+&gt;' =&gt; '&lt;module&gt;/&lt;controller&gt;/view',


            '&lt;language:(es|da|en)&gt;/&lt;module:&#092;w+&gt;/&lt;controller:(admin|profileField)&gt;/&lt;action:&#092;w+&gt;/&lt;id:&#092;d+&gt;' =&gt; '&lt;module&gt;/&lt;controller&gt;/&lt;action&gt;',


            '&lt;language:(es|da|en)&gt;/&lt;module:&#092;w+&gt;/&lt;controller:&#092;w+&gt;/&lt;action:&#092;w+&gt;' =&gt; '&lt;module&gt;/&lt;controller&gt;/&lt;action&gt;',


            '&lt;language:(es|da|en)&gt;/&lt;controller:&#092;w+&gt;/&lt;action:&#092;w+&gt;/&lt;id:&#092;d+&gt;' =&gt; '&lt;controller&gt;/&lt;action&gt;',


            '&lt;language:(es|da|en)&gt;/&lt;controller:&#092;w+&gt;/&lt;action:&#092;w+&gt;/*' =&gt; '&lt;controller&gt;/&lt;action&gt;',

Did i miss something . Please help ,

sorry For my bad english

thanx in advance.

So what exactly is the problem? How is it not able to route it, what error message do you get?

Also: Please use the "code snippet" function when including code in your post. Makes it much easier to read!

You have to add escaped hyphen.


[\w\-]+

I did that but not working if "-" found inside the url then language parameter not working…