Detect the browser preferred language

Go in Languages > Settings

Note that this option works when the language is chosen from the content, from the directory name in the url or from the subdomain. You need Polylang Pro for it to work when you use multiple domains.

The detect browser language option in the Polylang settings.

When activated, someone visiting your homepage for the first time is redirected to the homepage in the language according to his browser preferences. If his browser preferences do not include any language of your site, the default language is used.

Polylang sets a cookie for returning visitors to be redirected to the homepage in their last browsed language. Thus, if you want to test the functionality on your site, don’t forget to clear your cookies between each test.

Here are some examples with French as default language:

detect-browser-language-chromium-1

Case 1: None of the browser language preferences of your visitor match the website languages. The visitor is redirected to the French home page (default language). If his last browsed page is in English, he will be redirected to the English homepage at the second visit.

detect-browser-language-chromium-2

detect-browser-language-chromium-3

Cases 2 & 3: In both cases, English is the first language in the browser preferences of your visitor which matches one of your website languages. The visitor is redirected to the English home page.

Note: If you don’t want any redirection to occur, you must deactivate the browser preferred language detection and hide the default language code in URLs by checking the relevant option in the URL modifications settings.