Automatically switch language on your website

October 2016

Automatic language switching lets you create a multi-lingual website. Switching between multiple languages is done using special tags, plug-ins or an embedded code. The auto language switching plug-in lets users choose a language for the site, and enables the content to be displayed into the desired language.
Launching a multi-lingual website manually can be lengthy process based on basic Word Press, PHP.

An understanding of HTML helps a lot. Most of the WordPress backdrops and plug-ins are not set up properly for global and multi-lingual sites with automatic language switching. Steps to fix the issue are given on a language fixing link. The role of webmaster is important here, to activate a configuration file that translates the contents on display of the original webpage. PHP programming knowledge helps to fix some plug-in and backdrops.

There are various ways in which a website may prompt a user to select the language of their choice. Some prefer to ask you which country you are from before changing the language and others prefer to ask you directly the language in which you wish to display the website. However, there is also code that you can insert in a PHP file that will automatically detect the server that is being used by the visitor, and apply the changes in the language accordingly.

if (!isset($Language)) {      
$Language = explode(',',$_SERVER['HTTP_ACCEPT_LANGUAGE']);      
$Language = strtolower(substr(chop($Language[0]),0,2));      

The web master will have the choice to either redirect the visitor to another webpage that is linked to the website but that corresponds to the visitor's needs in term of language or they can activate a configuration file that will translate the contents that have been displayed on the original page.

Option 1: Redirect

<? else {      
header("Location: /index.php?Language=en");      
}  ?>

Option 2: Translate


Related :

This document entitled « Automatically switch language on your website » from CCM ( is made available under the Creative Commons license. You can copy, modify copies of this page, under the conditions stipulated by the license, as this note appears clearly.