Create your website multilingual

A lot of Websites all over the world have a lot of hits from foreign countries. In 99.9% of this cases the visitors are leaving after a few seconds because they are not able to read or understand the information you offer. How are you able to hold these visitors on your website?With a small script you are able to make your website multilingual. This script is reading a language variable from the URL, a so called GET parameter. In my example it is the variable „lang“. This variable is transmitted with the URL like in the example:

The script includes the different Website snippets related to the value of the variable. I created a folder named language_texts in the root folder of my webspace. In this folder are sub folders with the same name like the value of the lang variable, in this case for example it is DE. Here are all german elements saved. In the sub folder EN are all english elements stored and in FR all france elements.

To read this snippets there is only an one-liner:

function getSnippet($page, &$language) {
$path = './language_texts/'.$language.'/'.$page.'.php';
return $path;

$language is the subfolder (DE, EN, FR, etc.)
$page is the name of the php file, where the snippet is stored in.

An example how it can be used:

  function getSnippet($page, $language) {
    $path = './language_texts/'.$language.'/'.$page.'.php';
    return $path;
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <title>Website title</title>
    <?php include(getSnippet('index', $_GET['lang'])); ?>

Print Friendly, PDF & Email

One thought on “Create your website multilingual

Leave a Comment

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert.