title: Yii urlManager language in URL
body: <p>I am trying to add a language to the url with following syntax:
      <a href="http://www.example.com/en/site/page/view/about" rel="nofollow noreferrer">http://www.example.com/en/site/page/view/about</a></p>
  
  <p>What I have so far works with short urls like:
      <a href="http://www.example.com/en/site/contact" rel="nofollow noreferrer">http://www.example.com/en/site/contact</a>
  but not with long once as in my first example</p>
  
  <p>Here is what I have so far:</p>
  
  <p>/config/main.php</p>
  
  <pre><code>'urlManager'=&gt;array(
      'class'=&gt;'application.components.MyCUrlManager',
      'urlFormat'=&gt;'path', 'showScriptName'=&gt;false,
      'rules'=&gt;array(
          '&lt;language:\w+&gt;/&lt;controller:\w+&gt;/&lt;id:\d+&gt;'=&gt;'&lt;controller&gt;/view',
          '&lt;language:\w+&gt;/&lt;controller:\w+&gt;/&lt;action:\w+&gt;/&lt;id:\d+&gt;'=&gt;'&lt;controller&gt;/&lt;action&gt;',
          '&lt;language:\w+&gt;/&lt;controller:\w+&gt;/&lt;action:\w+&gt;'=&gt;'&lt;controller&gt;/&lt;action&gt;',
      ),
  ),
  </code></pre>
  
  <hr>
  
  <pre><code>&lt;?php // components/MyCUrlManager.php
  
  class MyCUrlManager extends CUrlManager
  {
      public function createUrl($route,$params=array(),$ampersand='&amp;')
      {
          if(isset($_POST['_lang']))
          {
              Yii::app()-&gt;setLanguage($_POST['_lang']);
              $route['language']=Yii::app()-&gt;language;
          }
          elseif (!isset($route['language']))
          {
              $route['language']=Yii::app()-&gt;language;
          }
          else
          {
              Yii::app()-&gt;setLanguage($route['language']);
          }
          return parent::createUrl($route, $params, $ampersand);
      }
  }
  ?&gt;
  </code></pre>
  
  <hr>
  
  <pre><code>class LangBox extends CWidget {
  
      public function run() {
  
          $currentLang = Yii::app()-&gt;language;
          require_once 'Zend/Locale.php';
          $locale = new Zend_Locale();
          //$siteLanguages = $this-&gt;getLang();
          $siteLanguages = array('en','de','tr');
          foreach($siteLanguages as $value){
                  $list[$value] = $locale-&gt;getTranslation($value, 'Language', $value);
          }
          asort($list);
          $this-&gt;render('langBox', array('currentLang' =&gt; $currentLang, 'list'=&gt;$list));
      }
  }
  </code></pre>