0
Thanks

A few words of thanks would be greatly appreciated.

Automatically switch language on your website

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


<?       
include("language-".$Language.".inc.php");      
 ?>
0
Thanks

A few words of thanks would be greatly appreciated.

Ask a question
CCM is a leading international tech website. Our content is written in collaboration with IT experts, under the direction of Jeff Pillou, founder of CCM.net. CCM reaches more than 50 million unique visitors per month and is available in 11 languages.

Related

Published by . Latest update on by Paul Berentzen.

This document, titled "Automatically switch language on your website," is available under the Creative Commons license. Any copy, reuse, or modification of the content should be sufficiently credited to CCM (https://ccm.net/).

0 Comments