title: magento - multilingual site + Add store codes to url - want to show flag icons
body: <p>I want to have a multi-language magento site use a flag image instead of a language selector box for user to select language of page. There is a nice article on this at <a href="http://www.atwix.com/magento/replace-language-selector-flag-icons/" rel="nofollow">http://www.atwix.com/magento/replace-language-selector-flag-icons/</a>
  Only issue is that we use "Add store codes to url" option.  I hacked this code, but it can use some refinement and make it more Magento looking.</p>
  
  <pre><code>    &lt;?php if(count($this-&gt;getStores())&gt;1): ?&gt;
      &lt;div class="form-language"&gt;
          &lt;div class="langs-wrapper"&gt;
          &lt;?php foreach ($this-&gt;getStores() as $_lang): ?&gt;
              &lt;?php if ($_lang-&gt;getCode() != 'default'): ?&gt;   
              &lt;?  
                  $base_url = Mage::getBaseUrl();
                  // remove language in base url
                  $base_url = str_replace('/en/' , "" , $base_url);       
                  $base_url = str_replace('/fr/' , "" , $base_url);                   
                  $current_url = $this-&gt;helper('core/url')-&gt;getCurrentUrl();
                  // take out base url and language code
                  $rest_of_url = str_replace($base_url , "" , $current_url);                  
                  $rest_of_url = str_replace('/en/' , "" , $rest_of_url);     
                  $rest_of_url = str_replace('/fr/' , "" , $rest_of_url);      
                  // assmble new url
                  $new_url = $base_url . '/' . $_lang-&gt;getCode()  . '/' . $rest_of_url;                       
              ?&gt;      
              &lt;a class="lang-flag" href="&lt;?php echo $new_url ;?&gt;"&gt;&lt;img src="&lt;?php echo $this-&gt;getSkinUrl('images/flags/' . $_lang-&gt;getCode() . '.png');?&gt;" alt=""&gt;&lt;/a&gt;
              &lt;?php endif;?&gt;
          &lt;?php endforeach;?&gt;
          &lt;/div&gt;
      &lt;/div&gt;
      &lt;?php endif;?&gt;
  </code></pre>