title: Yii 2 MULTILINGUAL WEBSITE
body: <p>I am trying to acvhieve multilinguial widget <a href="http://www.yiiframework.com/wiki/294/seo-conform-multilingual-urls-language-selector-widget-i18n/" rel="nofollow">like this</a> in Yii2</p>
  
  <p>I refereed <a href="http://www.yiiframework.com/forum/index.php/topic/56027-yii2-multilingual-website-url-rules/" rel="nofollow">this</a></p>
  
  <p>But I am stuck at the last part that is building selector widget. Can anyone list step by step process in Yii2?</p>
  
  <p>Below is my code for the language selector which returns nothing and breaks the layout for now</p>
  
  <pre><code>&lt;?php //languageselector.php
  use yii\helpers\Html;
  use yii\bootstrap\ActiveForm;
  
  ?&gt;
  
  &lt;div id="language-select"&gt;
  &lt;?php 
  if(sizeof($languages) &lt; 4) {
      // Render options as links
      $lastElement = end($languages);
      foreach($languages as $key=&gt;$lang) {
          if($key != $currentLang) {
             echo  $owners-&gt;createMultilanguageReturnUrl($key);
              echo Html::a(
                   $lang,
                   $owners-&gt;createMultilanguageReturnUrl($key));
          } else echo '&lt;b&gt;'.$lang.'&lt;/b&gt;';
          if($lang != $lastElement) echo ' | ';
      }
  }
  else {
      // Render options as dropDownList
      echo Html::form();
      foreach($languages as $key=&gt;$lang) {
          echo Html::hiddenField(
              $key, 
              $this-&gt;createMultilanguageReturnUrl($key));
      }
      echo Html::dropDownList('language', $currentLang, $languages,
          array(
              'submit'=&gt;'',
          )
      ); 
      echo Html::endForm();
      }
      ?&gt;
      &lt;/div&gt;
  </code></pre>