0

I have changed languages for flags in Magento. But now for example I change language home page localhost/website/ I click in French flag page goes localhost/website/fr make translation now I select product go to localhost/website/index.php/fr/productname now here I change language for example Italian it goes to the home page and give me this url localhost/website/index.php/fr/it

Do this for all languages

I can not solve this problem if you can help me thank you.

Here is the code languages.phtml

<?php if(count($this->getStores())>1): ?>
<div class="form-language">
    <div class="langs-wrapper">
    <?php foreach ($this->getStores() as $_lang): ?>
        <?php if ($_lang->getCode() != 'default'): ?>
        <a class="lang-flag" href="<?php echo $this->getCurrentUrl().$_lang->getCode();?>" style="text-decoration:none;" title="<?php echo $_lang->getCode();?>">
            <img src="<?php echo $this->getSkinUrl('images/flags/'.$_lang->getCode().'.gif');?>" alt="<?php echo $_lang->getCode();?>">
        </a>
        <?php endif;?>
    <?php endforeach;?>
    </div>
</div>
<?php endif;?>

1 Answer 1

1

The problem is the href: <?php echo $this->getCurrentUrl().$_lang->getCode();?>

This just takes the current url and appends the language code to it.
Replace that with

 <?php echo $_lang->getCurrentUrl(); ?>
1
  • I have one more question if you can answer me why in the home page when pick a language for example: localhost/website/ select French the url now localhost/website/index.php/fr/?___from_store=us I want to remove this "?___from_store=us" just to show "localhost/website/index.php/fr/" for SEO. Thanks again for your help. Commented Aug 21, 2015 at 16:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.