How to set up the automatic language redirection

How to set up the automatic language redirection

How to set up the automatic language redirection
This tutorial is part of our MultilingualPress 2 documentation. In case you are using the newer version 3, please switch to MultilingualPress 3.
If you have a multilingual website, it is extremely important that your users get to the language they understand the most. The feature automatic language redirection in MultilingualPress is taking care of that. In the following text you can find information about how the automatic language redirection works and how you set it.

Table of Contents

How does the automatic language redirection work in multilingual websites?Browser settings for the languageMultilingualPress priorities for languagesHow to find out language of browser setting and MultilingualPress prioritiesHow to set the automatic language redirection in MultilingualPress
1. How does the automatic language redirection work in multilingual websites?
1.1. Browser settings for the language
Users can add their preferred languages in the settings of each browser so that multilingual websites can take them into account. So the user adds which languages he speaks and also indicates his preferred order.
The following screenshot shows the corresponding setting in firefox.
Firefox language setting
1.2. MultilingualPress priorities for languages
Additionally to the browser settings there is a MultilingualPress setting for the automatic language redirection. And we offer the possibility to point to the qualitiy of your translations by assigning priorities for each language.
To set the automatic language redirection, go to Network Administration → Settings → Language Manager. There you can see all languages being available in MultilingualPress by default. The column rightmost lists priority, where you can add numbers on a scale from 1 to 10 for each of your translations. The language with the translation of highest quality gets the 10. Attention: the worse the translation, the lower the priority.
Language Manager
1.3. How to find out language of browser setting and MultilingualPress priorities
MultilingualPress multiplies each browser setting with the priorities being indicated in the language administration and the rule for the language selection is: The higher value wins. Experts call this Language Negotiation. 
In case the language with the highest level complies with the current language, there is no language redirection. The user is redirected neither to another language in case he or she goes to another language through a link generated from MultilingualPress  (e.g. in the language widget, in quicklinks or in the menue).
You can find a very detailed description about the language redirection in this article.
2. How to set the automatic language redirection in MultilingualPress
Requirement: For the automatic language redirection you need to have created at least two sites in your multisite. Then you need to assign a language in the MultilingualPress Tab. Did that? Great. Morover, you need to link the sites with each other.
Automatic language redirection

Go to Network Administration and then to Settings → MultilingualPress. Then set a hook at HTTP Redirect.
HTTP Redirect – Redirect visitors according to browser language settings.
Go to Sites → All Sites and edit a website.
Click at the tab MultilingualPress and set a hook at Enable automatic redirection.
Enable automatic redirection
You need to do these steps for all websites that are linked to each other. In Sites → All Sites there should be a hook in the column Redirect for sites with activated language redirection.
Activated language redirection