Redirecting visitors to their own language preference based on browser language or IP address is a feature that’s been often requested by our TranslatePress users. Now this is possible using our newest add-on Automatic User Language Detection.
First time visitors expect to see the website in a language they understand. With such a short attention span it’s easy to lose users who are not finding the language switcher soon enough. This is why it is important not only to have their language available, but to automatically redirect to it.
The last visited language is remembered through a cookie, so that returning visitors will always visit your website directly in their chosen language.
Automatic User Language Detection works out of the box
The Automatic User Language Detection add-on works out-of-the-box, with no required setup steps. There is no need to register for IP address language services, because the language recognition based on IP happens locally with the help of GeoLite2 databases from MaxMind.
There are two ways of finding out what languages the visitors speak: either by browser language setting or by IP address. In the community, the browser language is seen as the most reliable information, but it depends on who your targeted audience is in order to decide which works best for your website.
If you want to change the default setting of taking into account the browser language first and then IP address, you can do so with a simple select found in Settings -> TranslatePress. You can choose to determine language based solely on IP address or solely on browser language, or a combination between these two.
Hard redirects vs. soft redirects. A technical issue
We chose not to have any hard redirects in place for several reasons. Hard redirects, meaning those that happen on the server side, simply do not work with caching systems, be it a WP plugin, or host caching system. The page served from cache would not take into account the correct language for each visitor, since the code on the server never gets executed.
So how is our add-on solving all of these issues caused by the hard redirects?
The Automatic User Language Detection add-on uses only soft redirects, which happen on the client side. But there’s a problem: finding out the language preference sent by the browsers through the Accept-Language request HTTP header can only be read on the server side. The solution is to make a fast custom ajax request internally to get our needed information, all without using the slow loading WordPress environment.
A well-thought-out solution
The final result is a versatile and fast solution, that works well with a wide range of environments seen both on server side and on client side. See how you can take advantage of the Automatic User Language Detection Add-on and other useful features that TranslatePress offers.
Keep in touch!
We'll only notify you of new articles, special promotions and updates. No spam!