![]() |
|
|
#1
|
||
|
Can be helpful sometimes.
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"); ?>
__________________
█ INCRIPT TECHNOLOGIES - webhosting India █ iTALKS FORUMS - Designing & Hosting Community |
|
|
|
||
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|