You have a topic that was answered using PHP:
Step 1: Set up a folder tree structure like this:
Linguagens
-en
-lang.en.php
-fr
-lang.fr.php
-de
-lang.de.php
Continue making new folders with all the other languages you want.
Step 2: Create a folder with the language files, example: linguagens/en/lang.en.php
<?php
$lang['label'] = 'Value for this label';
$lang['firstname'] = 'First Name';
$lang['lastname'] = 'Last Name';
$lang['phone'] = 'Phone';
// ETC
?>
You would repeat this for any other language, for example, linguagens/fr/lang.fr.php
. Note Always after the $lang
the names remain the same in English.
<?php
$lang['label'] = 'Valeur pour ce label';
$lang['firstname'] = 'Prénom';
$lang['lastname'] = 'Nom de famille';
$lang['phone'] = 'Téléphone';
// ETC
?>
Step 3: Verify that the user has requested a language change through a url variable.
<?php
// Start a Session, You might start this somewhere else already.
session_start();
// What languages do we support
$available_langs = array('en','fr','de');
// Set our default language session
$_SESSION['lang'] = 'en';
if(isset($_GET['lang']) && $_GET['lang'] != ''){
// check if the language is one we support
if(in_array($_GET['lang'], $available_langs))
{
$_SESSION['lang'] = $_GET['lang']; // Set session
}
}
// Include active language
include('linguagens/'.$_SESSION['lang'].'/lang.'.$_SESSION['lang'].'.php');
?>
Step 4: You can access your language parts as such and change based on the language file you uploaded.
<?php
echo $lang['firstname'];
?>