title: Magento multilanguage - double change in language resuts in 404 (or how to change language within stores not views)
body: <p>I have a problem with a magento installation. I used Magento ver. 1.5.0.1, community edition to develop this website <a href="http://cissmarket.com/" rel="nofollow noreferrer">http://cissmarket.com/</a>.</p>
  
  <p>The problem appears when I change the language from the EU version to French and after that to German. The change to french is ok, but when in the same page i change to German i receive a 404 error. Also this is generation 404 errors in the Google webmaster tools and when i try for example to take this link and paste it in the browser it gives me also a 404 error. I have there some 50 products and ~550 404 errors in Google Webmaster tools. I understand that the problem is from what I described.</p>
  
  <p>Moreover I have a SEO problem since I have this page in french:</p>
  
  <p><a href="http://cissmarket.com/de/cartouches-refilables.html" rel="nofollow noreferrer">http://cissmarket.com/de/cartouches-refilables.html</a></p>
  
  <p>And when I switch to the german version of the website it takes me to this link </p>
  
  <p><a href="http://cissmarket.com/de/cartouches-refilables.html?___from_store=fr" rel="nofollow noreferrer">http://cissmarket.com/de/cartouches-refilables.html?___from_store=fr</a> (if i try now to switch to uk I will get the 404 mentioned above)</p>
  
  <p>instead of going to this one:</p>
  
  <p><a href="http://cissmarket.com/de/nachfullpatronen.html" rel="nofollow noreferrer">http://cissmarket.com/de/nachfullpatronen.html</a></p>
  
  <p>Already checked this <a href="https://stackoverflow.com/questions/7322121/404-error-when-switching-between-stores-when-in-a-category-on-magento">404 error when switching between stores when in a category on magento</a> but it does not relate to my problem.</p>
  
  <p>About settings:</p>
  
  <ul>
  <li>I use the caching service and also I did index all the content.</li>
  <li>The product or category I am trying to access is available and set active for all the languages.</li>
  <li>System > General > Web > URL options > Add Store Code to Urls is set
  to yes.</li>
  <li>System > General > Web > Search Engines Optimization > Use Web Server
  Rewrites is set to yes.</li>
  <li>No other changes has been made to the .htaccess file except for the
  ones that the system itself made.</li>
  </ul>
  
  <p>So to conclude: the problem is the 404 given by 2 succesive changes of the language and the bad url address when I switch from one page to another.</p>
  
  <p>Any suggestions would be appreciated.</p>
  
  <p>UPDATE: tried this <a href="http://www.activo.com/how-to-avoid-the-___from_store-query-parameter-when-switching-store-views-in-magento" rel="nofollow noreferrer">http://www.activo.com/how-to-avoid-the-___from_store-query-parameter-when-switching-store-views-in-magento</a> but it results in a 404 at the first language change </p>
  
  <p><strong>Edit #1:</strong></p>
  
  <p>Found the problem: file languages.phtml contained this code <code>&lt;?php echo str_replace ("/fr/","/de/",$_lang-&gt;getCurrentUrl()); ?&gt;</code> and actually did replace only the language code and not the whole url according to the corresponding translation.</p>
  
  <p>So applied to this</p>
  
  <blockquote>
    <p><a href="http://cissmarket.com/fr/cartouches-refilables.html" rel="nofollow noreferrer">http://cissmarket.com/fr/cartouches-refilables.html</a> </p>
  </blockquote>
  
  <p>it will return </p>
  
  <blockquote>
    <p><a href="http://cissmarket.com/de/cartouches-refilables.html" rel="nofollow noreferrer">http://cissmarket.com/de/cartouches-refilables.html</a></p>
  </blockquote>
  
  <p>So does anyone know how to get the corresponding URL of the current page for the other languages available in the store?</p>
  
  <p>Edit #2 (using @Vinai solution):</p>
  
  <p>It works on the product pages but not on the category yet.</p>