Magento – Multi Language and Auto Direction Setup

languagemagento-1.9

Magento 1.9.0.1

2 store views: dutch & english

Does it automatically show the correct language based on browser settings?

or would I nee to do something like this: http://www.magentocommerce.com/wiki/multi-store_set_up/how_to_automatically_redirect_to_a_store_view_based_on_the_browser_language

Thanks

Best Answer

Magento does not have something to redirect users based on location or language to a specific store view.
The code in the link you mentioned should work, in case you have different urls for both languages and both of them are different from the base url.
Here is an example:

Base URL: www.example.com/
En url www.example.com/en/
NL url www.example.com/nl

But if your en url is www.example.com/ and the NL url is www.example.com/nl it won't work. You will get an infinite loop when the user should see the EN language.
To make it work, remove this code:

if ($_SERVER['REQUEST_URI'] === '/') {
    header('Location: '.getStoreForLanguage()->getBaseUrl());
    exit;
}

and replace

Mage::run();

with

Mage::run(getStoreForLanguage()->getCode(), 'store');