How to make a multilingual web site in PHP
Making a multilingual web site
Collapse
X
-
If you're looking to code a multilingue website, this is a technique i used in many solutions, specially for text that is inside a php code.
<?php
/**
* index.php
* multilingual website
* lang/index.fr.php French translation
* lang/index.en.php English translation
*
* @author Hatem <hatem@php.net>
* @version 1.1.0 27 février 2002
*/
/**
* Detect and include language
*/
session_start();
if(!isset($lang)) {
$lang = getenv('HTTP_ACCEPT_LANGUAGE');
$lang_default = "en";
}
if (is_file("lang/index.$lang.php"))
{
$_SESSION["lang"] = $lang;
include("lang/index.$lang.php");
} else {
$_SESSION["lang"] = $lang_default;
include("lang/index.$lang_default.php");
}
/**
* Then code your website here
*/
echo _HELLO_;
echo "\n"._INFO_;
?>
<?php
/**
* lang/index.en.php
*/
define("_HELLO_", "Hello");
define("_INFO_", "This web site support english and french");
?>
<?php
/**
* lang/index.fr.php
*/
define("_HELLO_", "Salut");
define("_INFO_", "Ce site web supporte l'anglais et le français");
?> -
Best Web hostings
Good and Cheap Web Hosting, Let see the details.
- iPower : iPower offers the most complete Web Hosting Solution in the world. #1 in the World at only $7.95/month - includes Free Domain
- 1and1 Web Hosting :Easy. Fast. Reliable. Linux web hosting from 1&1 Sign up today!
- CHIhost : Best Hosting Deal 2500MB Disk Space 65GB Bandwidth only $6.95/mo
- StartLogic : StartLogic - Free setup/domain, Web builder, unlimited emails, PHP, mySQL, CGI, FrontPage. From $4.95/month.Click Here for more info.
- inMotion Hosting : $7.95 a month - Your Complete Hosting Solution
- iPowerWeb : Professional Web Hosting Solution for low cost ($7.95/mo)
- HostRocket : 1000MB 50GB Web Hosting for only $8.95/month with no contracts. PHP4, MYSQL, CGI, SSH all included. Click here!
- PowerWeb : "All in One" Web Hosting! - $7.77/month!
- HostGater : Unlimited Domain Hosting Only $6.95 a MonthComment
-
If you are creating a multi-lingual website you may also need to provide links to the other language versions of your site. If the page you are linking to is written in a different language to the current page, you need to let people using ***istive technologies know about this.Comment
Comment