Url Rules Based On Language

My site has english and spanish content. If the user chooses to read the spanish content, then the urls are like www.exampleweb.com/es/contenido, and if the user chooses to read the english content, then the url has to be like www.exampleweb.com/en/content.

I already managed to change between the "es" and "en", but i cant change the word "contenido" for "content.

I have this on my main.php, but it doesnt work:


'<language:(es|en)>/Yii::t("translator","content")' => 'content/read'

Thank you for your time, i hope you can help me.

PD: I saw something similar on this site http://www.yiiframework.com/wiki/55/i18n-subdomains-and-url-rules/, but it doesnt fit for what i need.

Dear Friend

Kindly check whether the following is helpful.

Create a bahavior and put inside the components folder.

components/applicationBehavior.php




<?php

class applicationBehavior extends CBehavior

{       private $_owner;

        public function events() 

       {

              return  array(

                               'onBeginRequest'=>'addRule',

                           );

       }

        

        public function addRule()

        {  

             $owner=$this->_owner=$this->getOwner();

             if($owner->language=='en_us') 

               {

                 

                  $owner->urlManager->addRules(array(

                        //declare rules for english

                        ));

               }


            if($owner->language=='sp') // I assumed it.

               {

                 

                  $owner->urlManager->addRules(array(

                        //declare rules for spanish

                        ));

               }

        }               

}



Attach this behavior as a property to main configuration file.

main.php




..................................................

'behaviors'=>array(

'class'=>'application.components.applicationBehavior',

),

.....................................................



Regards

My friend, thank you for your time. Your solution doesnt work dinamically. The custom behavior is not checking which is the current language that the user selected, instead uses the language that is set statically in the main.php:


 'language' => 'es'

Is there a way to correct this?

Dear Friend

Can you add the logic here.




<?php

class applicationBehavior extends CBehavior

{       private $_owner;

        public function events() 

       {

              return  array(

                               'onBeginRequest'=>'addRule',

                           );

       }

        

        public function addRule()

        {  

             $owner=$this->_owner=$this->getOwner();


             if(something is true)  //Add the logic here by which you are assigning the laguage .

                $owner->language='en_us';


             if($owner->language=='en_us') 

               {

                 

                  $owner->urlManager->addRules(array(

                        //declare rules for english

                        ));

               }


            if($owner->language=='es')

               {

                 

                  $owner->urlManager->addRules(array(

                        //declare rules for spanish

                        ));

               }

        }               

}



Would you please share the means by which you are assigning language with us.

Are you using session?

Regards.

If i had the logic then it works. I used:


 

if($_GET['language'] = 'es') $owner->language='es';

else $owner->language='en'



I have different tables, and in each of them i use a column called "language", which tells me is that content is in spanish or in english.

Thank you!