1. Create new file, name it test.php and add this code:
2. Create new directory, with name lang (permission 777) then create inside a file test.php and add this code:
3. This code it copied from InBuzunar.Mobi - Internetul mai aproape de tine, acum si pe mobil but i'm not using anymore. Good luck
PHP Code:
<?php
if ( isset( $_SERVER["HTTP_ACCEPT_ENCODING"] ) && substr_count( $_SERVER["HTTP_ACCEPT_ENCODING"], "gzip" ) ) ob_start( "ob_gzhandler" ) ;
else ob_start() ;
session_start() ;
$lang = $_GET["lang"] ;
if ( isset( $lang ) ) {
setcookie( "language", $lang, time() - 1800, "/", ".YourSite.Com", 0 ) ;
setcookie( "language", $lang, time() + 1800, "/", ".YourSite.Com", 0 ) ;
} else {
if ( isset( $_COOKIE["language"] ) ) {
$lang = $_COOKIE["language"] ;
setcookie( "language", $lang, time() - 1800, "/", ".YourSite.Com", 0 ) ;
setcookie( "language", $lang, time() + 1800, "/", ".YourSite.Com", 0 ) ;
} else {
$lang = substr( $_SERVER["HTTP_ACCEPT_LANGUAGE"], 0, 2 ) ;
setcookie( "language", $lang, time() + 1800, "/", ".YourSite.Com", 0 ) ;
}
}
include ( "./lang/test.php" ) ;
echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n" ;
echo "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\">\n" ;
echo "<head>\n" ;
echo "<title>" . $test_title . "</title>\n" ;
echo "<meta name=\"description\" content=\"" . $test_description . "\"/>\n" ;
echo "<meta name=\"keywords\" content=\"" . $test_keywords . "\"/>\n" ;
echo "</head>\n" ;
echo "<body>\n" ;
echo "<center>\n" ;
echo $test_choose . "\n" ;
echo "<br/>\n" ;
if ( $lang == "ro" ) {
echo "Ro | <a href=\"?lang=en\">En</a>\n" ;
} else
if ( $lang == "en" ) {
echo "<a href=\"?lang=ro\">Ro</a> | En\n" ;
}
echo "</center>\n" ;
echo "</body>\n" ;
echo "</html>\n" ;
ob_end_flush() ;
?>
PHP Code:
<?php
if ( $lang == "en" ) {
$test_title = "Title of page" ;
$test_description = "Describe the page" ;
$test_keywords = "Keywords of page" ;
$test_choose = "Choose language:" ;
} else {
$test_title = "Titlul paginii" ;
$test_description = "Descrierea paginii" ;
$test_keywords = "Cuvintele cheie ale paginii" ;
$test_choose = "Alege limba:" ;
}
?>
Comment