I am working on my php portfolio and I noticed that there are a lot of clients that don't speak fluent English and it is quite funny when they use a web translator. So I decided that it would be worth it to make my site multilingual.
On my index page it says English, Espanol, Duetsch, and Francias. I have that image hot-spotted so that when you click on the American flag it goes to: main.php?pg=main&lang=eng and so on for all of the languages.
And this is the code in my main.php file:
<?php
switch($_GET[lang]){
default:
$pages = array(
"main" => "eng/main.html",
"services" => "eng/services.html",
"portfolio" => "eng/portfolio.html",
"contact" => "eng/contact.html",
"nav" => "eng/nav.html",
"copy" => "eng/copy.html"
);
break;
case "eng":
$pages = array(
"main" => "eng/main.html",
"services" => "eng/services.html",
"portfolio" => "eng/portfolio.html",
"contact" => "eng/contact.html",
"nav" => "eng/nav.html",
"copy" => "eng/copy.html"
);
break;
case "esp":
$pages = array(
"main" => "esp/main.html",
"services" => "esp/services.html",
"portfolio" => "esp/portfolio.html",
"contact" => "esp/contact.html",
"nav" => "esp/nav.html",
"copy" => "esp/copy.html"
);
break;
case "deu":
$pages = array(
"main" => "deu/main.html",
"services" => "deu/services.html",
"portfolio" => "deu/portfolio.html",
"contact" => "deu/contact.html",
"nav" => "deu/nav.html",
"copy" => "deu/copy.html"
);
break;
case "fre":
$pages = array(
"main" => "fre/main.html",
"services" => "fre/services.html",
"portfolio" => "fre/portfolio.html",
"contact" => "fre/contact.html",
"nav" => "fre/nav.html",
"copy" => "fre/copy.html"
);
break;
}
?>
It sets the array with the files for the differant languages.
And anytime I was to call a file into my layout I just do this:
<?php
include($pages[services]);
?>
So what do you think? Is there an easier or better way to do it?